amqpextra icon indicating copy to clipboard operation
amqpextra copied to clipboard

Dialer pool.

Open makasim opened this issue 4 years ago • 0 comments

Maintain several connections to different RabbitMQ servers under the hood. Serve to clients only healthy connections. Exclude unhealthy until recovered.

package main

import (
	"github.com/makasim/amqpextra"
	"github.com/makasim/amqpextra/publisher"
)

func main() {
	d1, _ := amqpextra.NewDialer(
		amqpextra.WithURL("amqp://guest:guest@foo-rabbitmq:5672/"),
	)
	d2, _ := amqpextra.NewDialer(
		amqpextra.WithURL("amqp://guest:guest@bar-rabbitmq2:5672/"),
	)

	connCh := amqpextra.NewDialerPool(d1, d2)

	p, _ := amqpextra.NewPublisher(connCh)
	p.Publish(publisher.Message{
		Exchange: "foo",
	})
}

fixes https://github.com/makasim/amqpextra/issues/48

TODO:

  • [ ] tests
  • [ ] doc

makasim avatar Nov 15 '20 18:11 makasim