Cluster.Strategy.DynamicSrv (libcluster_dynamic_srv v1.1.0)
View SourceThis implements a libcluster strategy that utilizes DNS SRV records in a generic way. The K8s SRV strategy is too prescriptive to use generically because of the way it formulates its SRV hostnames.
For this strategy to work the SRV records should be in the format of <node-name>.<service-domain-name>.
This works with Consul by specifying the node-name
as a label and the service-domain-name is service.consul by default.
You can read more about Consul's DNS SRV records here.
While this was implemented to work with Consul, it can be used with any DNS service that supports SRV records and tagging of the hostname.
Configuration
service(required) — the DNS SRV service name to query.polling_interval(optional, default5000) — how often to poll DNS, in milliseconds.disconnect_on_deregister(optional, defaulttrue) — whentrue, nodes are disconnected as soon as they disappear from DNS. Whenfalse, a node that has left DNS but still has a live distribution connection is left connected; it will only be disconnected once the connection drops naturally. Setting this tofalseavoids spurious:globalpartition-prevention cascades during graceful shutdowns that use a deregistration delay.
Example Configuration:
config :libcluster,
topologies: [
dyn_srv: [
strategy: Cluster.Strategy.DynamicSrv,
config: [
service: "my-service-name.service.consul",
disconnect_on_deregister: false
]
]
]
Summary
Functions
Returns a specification to start this module under a supervisor.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.