-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Supervised connection #53
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
It might be better to use a single connection settings map that a host and port gets merged into. The broker can send additional cluster endpoints in info messages after the initial handshake, which only includes host and port. Is support for that planned? Which connection settings would get applied to those? |
@quixoten I was planning to let client code support that use with something like: nats_hosts = ["node1", "node2", "node3"]
connection_settings = Enum.map(nats_hosts, fn(host) -> %{host: host, port: 4222, username: "user", password: "pass"} end)
ConnectionSupervisor.start_link(%{name: :gnat, connection_settings: connection_settings}) It seemed easier for the client code to do custom logic for rather than having the library match things up together. Do you think that works or should we support something at the library level? |
So would the INFO messages get forwarded to the client? |
I don't follow, are you thinking we would notify another process whenever the connection was established? In a future PR I'm hoping to support persistent subscriptions like RPC server with a model similar to that, but this PR is mostly just about try to keep an gnat connection open whenever possible. |
I nats cluster can be completely liquid, for example, in a containerized infrastructure. You might get an initial list of servers from consul, or etcd, but as nodes leave and enter the cluster, the brokers will send additional INFO messages containing additional servers, at least if the client reports that it supports it:
To support that, I think it would be better to have a shared set of connection settings. |
Here's an example from a netcat session. Connected to one node, than added another node to the cluster:
|
@quixoten I'll open an issue to discuss that. I'm sure we don't currently support it. I think we were only handling |
Addresses #44
This introduces a new module (with docs) that users can put into their supervision tree to get an automatically reconnecting
Gnat
connection. They can pass it a list of locations they want to connect to and let it roll./cc @newellista @tallguy-hackett @jjcarstens @film42 @quixoten