From 37ae91ee20c77a93035406b35b39b777266ea933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Catt=C4=AB=20Cr=C5=ABd=C4=93l=C4=93s?= <17695588+wzy9607@users.noreply.github.com> Date: Tue, 2 Jul 2024 15:46:14 +0800 Subject: [PATCH] fix: pass shuffle param to StaticResolver --- connection.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/connection.go b/connection.go index 0b9c5a8..4e14560 100644 --- a/connection.go +++ b/connection.go @@ -4,6 +4,7 @@ import ( "math/rand" amqp "github.com/rabbitmq/amqp091-go" + "github.com/wagslane/go-rabbitmq/internal/connectionmanager" ) @@ -26,8 +27,8 @@ type Config amqp.Config type Resolver = connectionmanager.Resolver type StaticResolver struct { - urls []string - shuffe bool + urls []string + shuffle bool } func (r *StaticResolver) Resolve() ([]string, error) { @@ -35,7 +36,7 @@ func (r *StaticResolver) Resolve() ([]string, error) { var urls []string urls = append(urls, r.urls...) - if r.shuffe { + if r.shuffle { rand.Shuffle(len(urls), func(i, j int) { urls[i], urls[j] = urls[j], urls[i] }) @@ -44,7 +45,7 @@ func (r *StaticResolver) Resolve() ([]string, error) { } func NewStaticResolver(urls []string, shuffle bool) *StaticResolver { - return &StaticResolver{urls: urls} + return &StaticResolver{urls: urls, shuffle: shuffle} } // NewConn creates a new connection manager