@@ -33,9 +33,9 @@ import (
3333type Admin interface {
3434 CreateTopic (ctx context.Context , opts ... OptionCreate ) error
3535 DeleteTopic (ctx context.Context , opts ... OptionDelete ) error
36- //TODO
37- GroupList (ctx context.Context , brokerAddr string ) (* remote. RemotingCommand , error )
38- TopicList (ctx context.Context ) (* remote. RemotingCommand , error )
36+
37+ GetAllSubscriptionGroup (ctx context.Context , brokerAddr string ) (* SubscriptionGroupWrapper , error )
38+ FetchAllTopicList (ctx context.Context ) (* TopicList , error )
3939 //GetBrokerClusterInfo(ctx context.Context) (*remote.RemotingCommand, error)
4040 FetchPublishMessageQueues (ctx context.Context , topic string ) ([]* primitive.MessageQueue , error )
4141 Close () error
@@ -109,7 +109,7 @@ func NewAdmin(opts ...AdminOption) (*admin, error) {
109109 }, nil
110110}
111111
112- func (a * admin ) GroupList (ctx context.Context , brokerAddr string ) (* remote. RemotingCommand , error ) {
112+ func (a * admin ) GetAllSubscriptionGroup (ctx context.Context , brokerAddr string ) (* SubscriptionGroupWrapper , error ) {
113113 cmd := remote .NewRemotingCommand (internal .ReqGetAllSubscriptionGroupConfig , nil , nil )
114114 a .cli .RegisterACL ()
115115 response , err := a .cli .InvokeSync (ctx , brokerAddr , cmd , 3 * time .Second )
@@ -121,25 +121,37 @@ func (a *admin) GroupList(ctx context.Context, brokerAddr string) (*remote.Remot
121121 } else {
122122 rlog .Info ("Get all group list success" , map [string ]interface {}{})
123123 }
124- rpsCmd := remote .NewRemotingCommand (internal .ReqGetAllSubscriptionGroupConfig , nil , response .Body )
125-
126- return rpsCmd , nil
124+ var subscriptionGroupWrapper SubscriptionGroupWrapper
125+ _ , err = subscriptionGroupWrapper .Decode (response .Body , & subscriptionGroupWrapper )
126+ if err != nil {
127+ rlog .Error ("Get all group list decode error" , map [string ]interface {}{
128+ rlog .LogKeyUnderlayError : err ,
129+ })
130+ return nil , err
131+ }
132+ return & subscriptionGroupWrapper , nil
127133}
128134
129- func (a * admin ) TopicList (ctx context.Context ) (* remote. RemotingCommand , error ) {
135+ func (a * admin ) FetchAllTopicList (ctx context.Context ) (* TopicList , error ) {
130136 cmd := remote .NewRemotingCommand (internal .ReqGetAllTopicListFromNameServer , nil , nil )
131137 response , err := a .cli .InvokeSync (ctx , a .cli .GetNameSrv ().AddrList ()[0 ], cmd , 3 * time .Second )
132138 if err != nil {
133- rlog .Error ("Get all topic list error" , map [string ]interface {}{
139+ rlog .Error ("Fetch all topic list error" , map [string ]interface {}{
134140 rlog .LogKeyUnderlayError : err ,
135141 })
136142 return nil , err
137143 } else {
138- rlog .Info ("Get all topic list success" , map [string ]interface {}{})
144+ rlog .Info ("Fetch all topic list success" , map [string ]interface {}{})
139145 }
140- rpsCmd := remote .NewRemotingCommand (internal .ReqGetAllTopicListFromNameServer , nil , response .Body )
141-
142- return rpsCmd , nil
146+ var topicList TopicList
147+ _ , err = topicList .Decode (response .Body , & topicList )
148+ if err != nil {
149+ rlog .Error ("Fetch all topic list decode error" , map [string ]interface {}{
150+ rlog .LogKeyUnderlayError : err ,
151+ })
152+ return nil , err
153+ }
154+ return & topicList , nil
143155}
144156
145157// CreateTopic create topic.
0 commit comments