-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
consul.h
53 lines (43 loc) · 1.15 KB
/
consul.h
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
#ifndef CONSUL_H_
#define CONSUL_H_
#include <vector>
#include <string.h>
typedef struct consul_node_s {
// node
char ip[64];
int port;
consul_node_s() {
strcpy(ip, "127.0.0.1");
port = 8500;
}
} consul_node_t;
typedef struct consul_service_s {
// service
char name[64];
char ip[64];
int port;
consul_service_s() {
name[0] = '\0';
strcpy(ip, "127.0.0.1");
port = 0;
}
} consul_service_t;
typedef struct consul_health_s {
// check
char protocol[32]; // TCP,HTTP
char url[256];
char status[32]; // any,passing,warning,critical
int interval; // ms
int timeout; // ms
consul_health_s() {
strcpy(protocol, "TCP");
url[0] = '\0';
strcpy(status, "passing");
interval = 10000;
timeout = 3000;
}
} consul_health_t;
int register_service(consul_node_t* node, consul_service_t* service, consul_health_t* health);
int deregister_service(consul_node_t* node, consul_service_t* service);
int discover_services(consul_node_t* node, const char* service_name, std::vector<consul_service_t>& services);
#endif // CONSUL_H_