28 #include "aossl/consul/include/consul_interface.h" 30 #ifndef AOSSL_CONSUL_INCLUDE_SERVICE_H_ 31 #define AOSSL_CONSUL_INCLUDE_SERVICE_H_ 42 std::vector<std::string> tags;
49 Service() : id(
""), name(
""), address(
""), port(
"") {check.
url =
"";check.
ttl =
"";}
52 Service(std::string new_id, std::string new_name) : id(new_id), \
53 name(new_name), address(
""), port(
"") {check.
url =
"";check.
ttl =
"";}
56 Service(std::string new_id, std::string new_name, std::string new_address, \
57 std::string new_port) : id(new_id), name(new_name), address(new_address), \
58 port(new_port) {check.
url =
"";check.
ttl =
"";}
61 Service(std::string new_id, std::string new_name, std::string new_address, \
62 std::string new_port, std::vector<std::string> new_tags) : id(new_id), \
63 name(new_name), address(new_address), port(new_port) \
64 {tags = new_tags;check.
url =
"";check.
ttl =
"";}
73 std::string
get_id()
const {
return id;}
85 void set_id(std::string new_id) {
id = new_id;}
88 void set_name(std::string new_name) {name = new_name;}
91 void set_address(std::string new_address) {address = new_address;}
94 void set_port(std::string new_port) {port = new_port;}
97 std::vector<std::string>
get_tags() {
return tags;}
99 void add_tag(std::string new_tag) {tags.push_back(new_tag);}
108 inline void set_check(std::string http_url,
int interval_seconds) {
109 check.
url = http_url;
110 check.
interval = std::to_string(interval_seconds) +
"s";
111 check.
ttl = std::to_string(interval_seconds + 5) +
"s";
114 inline void set_check(std::string http_url,
int interv_seconds,
int interv_ttl) {
115 check.
url = http_url;
116 check.
interval = std::to_string(interv_seconds) +
"s";
117 check.
ttl = std::to_string(interv_ttl) +
"s";
123 #endif // AOSSL_CONSUL_INCLUDE_SERVICE_H_ void clear_tags()
Clear the tags.
Definition: service.h:101
std::string to_json() const
Convert the Service into a JSON Message.
std::string ttl
The TTL for the health check.
Definition: consul_interface.h:48
HealthCheck get_check()
Get the health checks.
Definition: service.h:106
std::string interval
The interval for the health check.
Definition: consul_interface.h:45
A struct to hold health check information which can be added to a service.
Definition: consul_interface.h:40
int num_tags() const
How many tags are there?
Definition: service.h:103
std::string get_id() const
Get the Service ID.
Definition: service.h:73
Service()
Construct a Service.
Definition: service.h:49
std::string url
The HTTP URL to hit with a GET request for the healthcheck.
Definition: consul_interface.h:42
void set_port(std::string new_port)
Set the Service Port.
Definition: service.h:94
A Service class which can be registered with Consul for each app instance.
Definition: service.h:39
A Service class which can be registered with Consul for each app instance.
Definition: consul_interface.h:57
Service(std::string new_id, std::string new_name, std::string new_address, std::string new_port, std::vector< std::string > new_tags)
Construct a Service.
Definition: service.h:61
void set_check(std::string http_url, int interval_seconds)
Add a check.
Definition: service.h:108
Service(std::string new_id, std::string new_name, std::string new_address, std::string new_port)
Construct a Service.
Definition: service.h:56
std::string get_address() const
Get the Service Address.
Definition: service.h:79
void set_id(std::string new_id)
Set the Service ID.
Definition: service.h:85
void set_check(std::string http_url, int interv_seconds, int interv_ttl)
Add a check.
Definition: service.h:114
void set_name(std::string new_name)
Set the Service Name.
Definition: service.h:88
Service(std::string new_id, std::string new_name)
Construct a Service.
Definition: service.h:52
std::vector< std::string > get_tags()
Get the tags.
Definition: service.h:97
void set_address(std::string new_address)
Set the Service Address.
Definition: service.h:91
void add_tag(std::string new_tag)
Add a tag.
Definition: service.h:99
std::string get_port() const
Get the Service Port.
Definition: service.h:82
std::string get_name() const
Get the Service Name.
Definition: service.h:76