From caca3c00c647b65da69b531423aefc7fe15b3108 Mon Sep 17 00:00:00 2001 From: yechun Date: Wed, 22 Feb 2023 14:22:40 +0800 Subject: [PATCH] [ISSUE #999] add timeoutMillis param --- admin/admin.go | 6 +++--- examples/admin/group/main.go | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/admin/admin.go b/admin/admin.go index 4b7a501a..487c8b44 100644 --- a/admin/admin.go +++ b/admin/admin.go @@ -34,7 +34,7 @@ type Admin interface { CreateTopic(ctx context.Context, opts ...OptionCreate) error DeleteTopic(ctx context.Context, opts ...OptionDelete) error - GetAllSubscriptionGroup(ctx context.Context, brokerAddr string) (*SubscriptionGroupWrapper, error) + GetAllSubscriptionGroup(ctx context.Context, brokerAddr string, timeoutMillis time.Duration) (*SubscriptionGroupWrapper, error) FetchAllTopicList(ctx context.Context) (*TopicList, error) //GetBrokerClusterInfo(ctx context.Context) (*remote.RemotingCommand, error) FetchPublishMessageQueues(ctx context.Context, topic string) ([]*primitive.MessageQueue, error) @@ -109,10 +109,10 @@ func NewAdmin(opts ...AdminOption) (*admin, error) { }, nil } -func (a *admin) GetAllSubscriptionGroup(ctx context.Context, brokerAddr string) (*SubscriptionGroupWrapper, error) { +func (a *admin) GetAllSubscriptionGroup(ctx context.Context, brokerAddr string, timeoutMillis time.Duration) (*SubscriptionGroupWrapper, error) { cmd := remote.NewRemotingCommand(internal.ReqGetAllSubscriptionGroupConfig, nil, nil) a.cli.RegisterACL() - response, err := a.cli.InvokeSync(ctx, brokerAddr, cmd, 3*time.Second) + response, err := a.cli.InvokeSync(ctx, brokerAddr, cmd, timeoutMillis) if err != nil { rlog.Error("Get all group list error", map[string]interface{}{ rlog.LogKeyUnderlayError: err, diff --git a/examples/admin/group/main.go b/examples/admin/group/main.go index 2a4b510d..6aefe97e 100644 --- a/examples/admin/group/main.go +++ b/examples/admin/group/main.go @@ -20,6 +20,7 @@ package main import ( "context" "fmt" + "time" "github.com/apache/rocketmq-client-go/v2/admin" "github.com/apache/rocketmq-client-go/v2/primitive" @@ -39,7 +40,7 @@ func main() { ) // group list - result, err := testAdmin.GetAllSubscriptionGroup(context.Background(), brokerAddr) + result, err := testAdmin.GetAllSubscriptionGroup(context.Background(), brokerAddr, 3*time.Second) if err != nil { fmt.Println("GetAllSubscriptionGroup error:", err.Error()) }