MCPcopy Create free account
hub / github.com/apache/brpc / RegisterCompressHandler

Function RegisterCompressHandler

src/brpc/compress.cpp:30–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28static CompressHandler s_handler_map[MAX_HANDLER_SIZE] = { { NULL, NULL, NULL } };
29
30int RegisterCompressHandler(CompressType type,
31 CompressHandler handler) {
32 if (NULL == handler.Compress || NULL == handler.Decompress) {
33 LOG(FATAL) << "Invalid parameter: handler function is NULL";
34 return -1;
35 }
36 int index = type;
37 if (index < 0 || index >= MAX_HANDLER_SIZE) {
38 LOG(FATAL) << "CompressType=" << type << " is out of range";
39 return -1;
40 }
41 if (s_handler_map[index].Compress != NULL) {
42 LOG(FATAL) << "CompressType=" << type << " was registered";
43 return -1;
44 }
45 s_handler_map[index] = handler;
46 return 0;
47}
48
49// Find CompressHandler by type.
50// Returns NULL if not found

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected