Comments (3)
I am wondering if a resolver
interface would be good here
Something like
resolver := ClusterResolver([]string{
"amqp://usr:[email protected]:5672",
"amqp://usr:[email protected]:5673",
"amqp://usr:[email protected]:5674",
})
conn, err := rabbitmq.NewClusterConn(
resolver,
rabbitmq.WithConnectionOptionsLogging,
)
Where a resolver is an interface:
type Resolver interface {
Resolve() ([]string, error)
}
The idea behind this is you could support service discovery for clusters this way. For example you could have ConsulResolver
or a SRVResolver
for looking up hosts via SRV record in DNS.
Only one implementation should be in the library and would be just a ClusterResovlver
Something lile
type ClusterResolver struct {
uris []string
random bool
}
Randomize says that each call to Resolve
would shuffle the list.
I am happy to contribute here with a PR if it feels like a good direction?
from go-rabbitmq.
It doesn't look like the base AMQP library supports clustered connections either: streadway/amqp#339
I'm happy to support this if someone wants to open a PR. I believe the implementation should just be that multiple urls can be specified. The first is always used, but on reconnection it just cycles through the list
from go-rabbitmq.
Yeah base library doesn't support reconnects either. With clustering you just need to connect to one of the nodes in the cluster. So on reconnect you would try to (potentially) connect to another server.
So it makes sense that the base AMQP library doesn't support it (if you accept their narrow view of what the library should do).
I believe the implementation should just be that multiple urls can be specified. The first is always used, but on reconnection it just cycles through the list
I agree this should be the base functionality but also why i propose the specifying alternative ways of reconnecting. For me a list is no good as the backend systems are going to be dynamic (think kubernetes) and needs to be accessed via service discovery.
This is similar to the HostProvider
in the go-zookeeper/zk although much simpler. I think the "hostprovider" or whatever it should me named just always return a list to cycle through on each reconnect.
I do think that a single implementation of this should be in this library with other implementations could be provided by the caller unique to their environment.
from go-rabbitmq.
Related Issues (20)
- Race condition when calling PublishWithDeferredConfirmWithContext HOT 1
- get message in a variable like github.com/streadway/amqp HOT 2
- error on ack HOT 1
- Retry Publish Option HOT 5
- Direct reply-to HOT 2
- rabbitmq-manager no consumers HOT 2
- only reconnecting some consumers HOT 1
- Shutdown after a fixed number of reconnection attempts HOT 2
- Support for Dead Letter Exchange HOT 1
- Cluster support HOT 1
- Declare queue without consuming messages HOT 2
- My business requires batch processing of messages. Currently, the Consumer can only provide one callback at a time. Can I open up chan (msgs)? I want to handle message callbacks myself HOT 1
- received 'direct' but current is 'topic'" HOT 1
- A queue can accept multiple bindings from multiple exchanges HOT 1
- memory leak HOT 12
- how to gracefully shutdown mq consumers?
- Docs specify `WithPublisherOptionsExchangeDeclare` *stops* this library from declaring the exchanges existance
- Asynchronous reconnection
- NotifyPublish ReconnectCount - how is it intended to be used? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-rabbitmq.