Commit Graph

52 Commits

Author SHA1 Message Date
lovelly
fd04722706 Fix tcp check no ttl error 2018-10-09 10:40:24 +08:00
Asim Aslam
9968c7d007 Add Init to all things, use init in cmd package to initialise 2018-08-08 18:57:29 +01:00
Asim Aslam
af328ee7b4 Support connect native registration 2018-08-06 17:12:34 +01:00
Shulhan
44b934d458 registry: rename context key "consul_register_tcp_check" to "consul_tcp_check" 2018-03-21 21:57:04 +07:00
Shulhan
65a90f5a21 registry.Register: use local variable to get context value 2018-03-21 18:18:48 +07:00
Shulhan
68ab671bd0 Use registry.options.Context to set Consul TCP check option 2018-03-19 20:34:56 +07:00
Shulhan
f4cdfaf27f Fix TCP address and port on service check registration 2018-03-19 20:34:12 +07:00
Shulhan
1599d717af Add option to enable TCP check with Consul registry
One disadvantage of using TTL based health check is the high network
traffic between Consul agent (either between servers, or between server
and client).

In order for the services considered alive by Consul, microservices must
send an update TTL to Consul every n seconds (currently 30 seconds).

Here is the explanation about TTL check from Consul documentation [1]

    Time to Live (TTL) - These checks retain their last known state for a
    given TTL. The state of the check must be updated periodically over
    the HTTP interface. If an external system fails to update the status
    within a given TTL, the check is set to the failed state. This
    mechanism, conceptually similar to a dead man's switch, relies on the
    application to directly report its health. For example, a healthy app
    can periodically PUT a status update to the HTTP endpoint; if the app
    fails, the TTL will expire and the health check enters a critical
    state. The endpoints used to update health information for a given
    check are the pass endpoint and the fail endpoint. TTL checks also
    persist their last known status to disk. This allows the Consul agent
    to restore the last known status of the check across restarts.
    Persisted check status is valid through the end of the TTL from the
    time of the last check.


Hint:

    TTL checks also persist their last known status to disk. This allows
    the Consul agent to restore the last known status of the check
    across restarts.

When microservices update the TTL, Consul will write to disk. Writing to
disk means all other slaves need to replicate it, which means master need
to inform other standby Consul to pull the new catalog. Hence, the
increased traffic.

More information about this issue can be viewed at Consul mailing list [2].

[1] https://www.consul.io/docs/agent/checks.html
[2] https://groups.google.com/forum/#!topic/consul-tool/84h7qmCCpjg
2018-03-14 19:40:59 +07:00
Asim Aslam
982e6068cf support services without version 2018-03-01 17:35:13 +00:00
Asim Aslam
d0d9582b81
Merge pull request #206 from darren-west/master
Added Options() to registry interface
2018-02-19 20:52:28 +00:00
Asim Aslam
02260dcaa3 Add watch options 2018-02-19 17:12:37 +00:00
Siyun Wu
7c8d6087de add https support for consul
using enviroment variables

for example:
export CONSUL_HTTP_SSL=1
export CONSUL_HTTP_ADDR="https://example.com"
export CONSUL_CLIENT_CERT="/Users/foo/.ssh/consul/consul.cert"
export CONSUL_CLIENT_KEY="/Users/foo/.ssh/consul/consul.key"
export CONSUL_CACERT="/Users/foo/.ssh/consul/ca.cert"
2017-11-20 15:34:52 +08:00
darren-west
d970586a29 Added Options() to registry interface 2017-09-28 11:16:56 +01:00
Sergey Sarbash
db0df07fd6 Check for uninitialized *config.HttpClient 2017-08-15 10:49:24 +03:00
Sergey Sarbash
fd01ead575 Fixes nil pointer dereferencing for Consul TLS transport 2017-08-15 09:27:39 +03:00
Asim
c289f6acaa Make use of consul 0.7 deregister field. Now auto reaps dead services 2016-11-25 11:23:37 +01:00
chriss
fabdd4a704 Remove consul token helper method.
A Consul config struct can be passed using the `Config` helper making this helper redundant.
2016-11-21 16:16:24 +00:00
Asim
f9709ffa6e ensure the code does not panic 2016-11-18 07:30:50 +00:00
chriss
8a25723fe0 Set consul token via registry options.
Optionally configure a token to use with the consul client.
2016-11-18 00:07:12 +00:00
chriss
3d7187f405 Add the ability to pass consul client config via registry options.
This can be used when you need to configure the consul client to use a specific configuration (E.G to pass a Token if consul is using ACL policies)
2016-11-17 23:24:14 +00:00
Jelmer Snoeck
e59f7a7ace
ConsulRegistry: use health checks to select nodes.
Consul sees a healthcheck that is in the warning state as a "failed"
node. This means that when we ask Consul for services that are passing,
it would not return nodes that have warning healthchecks.

In the cache, we only check on critical to skip for nodes. This makes
the cache out of sync with the non-cache implementation.

This patch reworks the non-cache implementation to ask for all nodes
(even unhealthy ones) and does the same check as within the cache, skip
nodes that have critical healthchecks.

We've noticed this issue when we deployed custom healthchecks where the
cache was acting properly, but after 1 minute we saw "None Available"
errors. This is due to the TTL expiry on the cache, which is then
followed by doing a non cached request.
2016-08-26 08:36:45 +01:00
Asim
e2855c4bc2 Fix some mapping issues while we're at it 2016-04-09 22:19:03 +01:00
Asim
9d7bd3f424 God damn you nil map 2016-04-09 21:34:45 +01:00
Asim
b3fbd36ba7 Don't re-register if the state hasn't changed 2016-04-09 21:30:31 +01:00
Asim
61178d1b45 Update encoding to be backwards compatible. 2016-03-29 17:44:46 +01:00
Asim
e941796234 Add encoding that does not throw warns 2016-03-16 21:23:41 +00:00
Asim
f088074f29 Registry init 2016-03-15 22:20:21 +00:00
Asim
61094fefe8 If TTL is nil it might bail 2016-01-27 00:32:16 +00:00
Asim
55145d08a1 Use agent service for this 2016-01-27 00:15:46 +00:00
Asim
5ec9d561a6 meh 2016-01-26 23:32:27 +00:00
Asim
cd13f0389f Fix this cruft 2016-01-26 20:44:29 +00:00
Asim
822cc0e5da Use ServiceID as node.ID rather than Node.... in time remove Node/Address completely 2016-01-26 20:30:05 +00:00
Asim
a6ce435a07 If secure or tlsconfig not nil then secure 2016-01-17 00:33:07 +00:00
Asim
ae2ab911ed Access tls config 2016-01-16 23:39:47 +00:00
Asim
60ee085cbc Add secure option to registry 2016-01-16 20:25:18 +00:00
Asim
be43d827c7 Add String method to all interfaces 2015-12-19 21:56:14 +00:00
Asim
d7b3765c71 Allow setting of timeout for registry 2015-12-19 18:28:08 +00:00
Asim
d4f3a6070c Update the watch interface 2015-12-05 01:12:29 +00:00
Asim
9b23729eac add default port where none is specified 2015-11-16 12:11:03 +00:00
Asim
0320fc1b55 Update registry so version is surfaced 2015-11-08 01:48:48 +00:00
Asim
d9ae100524 Fix registry address usage 2015-10-26 20:23:57 +00:00
Asim
fcbd2acdde add endpoint data for consul registry 2015-10-11 12:05:20 +01:00
Asim
113cc8a9cb Remove service id so nodes are also removed from catalog 2015-08-15 23:03:50 +01:00
Asim
09c784d294 add support for streaming requests. cleanup watcher initilisation 2015-06-01 18:55:27 +01:00
Asim
36b5ca46fe Change initialisation and add metadata 2015-05-26 22:39:48 +01:00
Asim
7aa2c82ced Service and node should be structs rather than interface 2015-05-25 22:14:28 +01:00
Asim
74fd1fc989 Restructure go-micro layout and plugins 2015-05-23 20:04:16 +01:00
Asim
0e7bd77f4c Allow configurable addresses for everything 2015-05-16 00:34:02 +01:00
Asim
52f140da5f Add support for listing services, very rough 2015-04-03 00:52:49 +02:00
Asim
4b494966fb Add consul watcher 2015-02-14 23:00:47 +00:00