Debian Codegraph @

third-party/libhv-v1.3.3/examples/consul/consul.h

raw
1 #ifndef CONSUL_H_
2 #define CONSUL_H_
3
4 #include <vector>
5 #include <string.h>
6
7 typedef struct consul_node_s {
8 // node
9 char ip[64];
10 int port;
11
12 consul_node_s() {
13 strcpy(ip, "127.0.0.1");
14 port = 8500;
15 }
16 } consul_node_t;
17
18 typedef struct consul_service_s {
19 // service
20 char name[64];
21 char ip[64];
22 int port;
23
24 consul_service_s() {
25 name[0] = '\0';
26 strcpy(ip, "127.0.0.1");
27 port = 0;
28 }
29 } consul_service_t;
30
31 typedef struct consul_health_s {
32 // check
33 char protocol[32]; // TCP,HTTP
34 char url[256];
35 char status[32]; // any,passing,warning,critical
36
37 int interval; // ms
38 int timeout; // ms
39
40 consul_health_s() {
41 strcpy(protocol, "TCP");
42 url[0] = '\0';
43 strcpy(status, "passing");
44 interval = 10000;
45 timeout = 3000;
46 }
47 } consul_health_t;
48
49 int register_service(consul_node_t* node, consul_service_t* service, consul_health_t* health);
50 int deregister_service(consul_node_t* node, consul_service_t* service);
51 int discover_services(consul_node_t* node, const char* service_name, std::vector<consul_service_t>& services);
52
53 #endif // CONSUL_H_