From 9462ea81043d90c3d7e96ee70739d115a2037342 Mon Sep 17 00:00:00 2001 From: Vincent Lee Date: Tue, 8 Oct 2024 17:41:20 +0800 Subject: [PATCH] [ISSUE #1136] should also set Credentials for nameserver in admin and pull consumer (#1137) * should also set Credentials for nameserver in admin and pull consumer * should set Credentials for nameserver --- admin/admin.go | 3 +++ consumer/pull_consumer.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/admin/admin.go b/admin/admin.go index 62175af4..a92a25c7 100644 --- a/admin/admin.go +++ b/admin/admin.go @@ -102,6 +102,9 @@ func NewAdmin(opts ...AdminOption) (*admin, error) { if err != nil { return nil, err } + if !defaultOpts.Credentials.IsEmpty() { + namesrv.SetCredentials(defaultOpts.Credentials) + } cli := internal.GetOrNewRocketMQClient(defaultOpts.ClientOptions, nil) if cli == nil { diff --git a/consumer/pull_consumer.go b/consumer/pull_consumer.go index a64c1638..c66ffb7a 100644 --- a/consumer/pull_consumer.go +++ b/consumer/pull_consumer.go @@ -92,6 +92,9 @@ func NewPullConsumer(options ...Option) (*defaultPullConsumer, error) { if err != nil { return nil, errors.Wrap(err, "new Namesrv failed.") } + if !defaultOpts.Credentials.IsEmpty() { + srvs.SetCredentials(defaultOpts.Credentials) + } defaultOpts.Namesrv = srvs dc := &defaultConsumer{