-
Notifications
You must be signed in to change notification settings - Fork 70
/
client_api.cpp
57 lines (43 loc) · 1.76 KB
/
client_api.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "client_common.h"
bool TankClient::process_msg(connection *const c, const uint8_t msg, const uint8_t *const content, const size_t len) {
enum {
trace = false,
};
if (trace) {
SLog("About to process message of type ", msg, ", len = ", len, "\n");
}
switch (TankAPIMsgType(msg)) {
case TankAPIMsgType::Produce:
return process_produce(c, content, len);
case TankAPIMsgType::Consume:
#ifdef TANK_CLIENT_FAST_CONSUME
#ifdef TANK_THROW_SWITCH_EXCEPTIONS
throw Switch::runtime_error("Unexpected message");
#else
throw std::runtime_error("Unexpected Message");
#endif
#else
return process_consume(c, content, len);
#endif
case TankAPIMsgType::DiscoverTopics:
return process_discover_topics(c, content, len);
case TankAPIMsgType::DiscoverTopology:
return process_discover_topology(c, content, len);
case TankAPIMsgType::DiscoverPartitions:
return process_discover_partitions(c, content, len);
case TankAPIMsgType::ReloadConf:
return process_reload_partition_conf(c, content, len);
case TankAPIMsgType::CreateTopic:
return process_create_topic(c, content, len);
case TankAPIMsgType::Status:
return process_srv_status(c, content, len);
case TankAPIMsgType::Ping:
if (trace) {
SLog("PING\n");
}
return true;
default:
shutdown(c, __LINE__);
return false;
}
}