/
option.go
579 lines (477 loc) · 13.5 KB
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
/*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package admin
func updateTopicConfig() TopicConfigCreate {
opts := TopicConfigCreate{}
return opts
}
func defaultTopicConfigCreate() TopicConfigCreate {
opts := TopicConfigCreate{
DefaultTopic: "defaultTopic",
ReadQueueNums: 8,
WriteQueueNums: 8,
Perm: 6,
TopicFilterType: "SINGLE_TAG",
TopicSysFlag: 0,
Order: false,
}
return opts
}
type TopicConfigCreate struct {
Topic string
BrokerAddr string
DefaultTopic string
ReadQueueNums int
WriteQueueNums int
Perm int
TopicFilterType string
TopicSysFlag int
Order bool
ClusterName string
NamesrvAddr string
}
type OptionCreate func(*TopicConfigCreate)
func WithTopicClusterName(clustername string) OptionCreate {
return func(opts *TopicConfigCreate) {
opts.ClusterName = clustername
}
}
func WithTopicCreate(Topic string) OptionCreate {
return func(opts *TopicConfigCreate) {
opts.Topic = Topic
}
}
func WithBrokerAddrCreate(BrokerAddr string) OptionCreate {
return func(opts *TopicConfigCreate) {
opts.BrokerAddr = BrokerAddr
}
}
func WithReadQueueNums(ReadQueueNums int) OptionCreate {
return func(opts *TopicConfigCreate) {
opts.ReadQueueNums = ReadQueueNums
}
}
func WithWriteQueueNums(WriteQueueNums int) OptionCreate {
return func(opts *TopicConfigCreate) {
opts.WriteQueueNums = WriteQueueNums
}
}
func WithPerm(Perm int) OptionCreate {
return func(opts *TopicConfigCreate) {
opts.Perm = Perm
}
}
func WithTopicFilterType(TopicFilterType string) OptionCreate {
return func(opts *TopicConfigCreate) {
opts.TopicFilterType = TopicFilterType
}
}
func WithTopicSysFlag(TopicSysFlag int) OptionCreate {
return func(opts *TopicConfigCreate) {
opts.TopicSysFlag = TopicSysFlag
}
}
func WithOrder(Order bool) OptionCreate {
return func(opts *TopicConfigCreate) {
opts.Order = Order
}
}
func defaultTopicConfigDelete() TopicConfigDelete {
opts := TopicConfigDelete{}
return opts
}
type TopicConfigDelete struct {
Topic string
ClusterName string
NameSrvAddr []string
BrokerAddr string
}
type OptionDelete func(*TopicConfigDelete)
func WithTopicDelete(Topic string) OptionDelete {
return func(opts *TopicConfigDelete) {
opts.Topic = Topic
}
}
func WithBrokerAddrDelete(BrokerAddr string) OptionDelete {
return func(opts *TopicConfigDelete) {
opts.BrokerAddr = BrokerAddr
}
}
func WithClusterName(ClusterName string) OptionDelete {
return func(opts *TopicConfigDelete) {
opts.ClusterName = ClusterName
}
}
func WithNameSrvAddr(NameSrvAddr []string) OptionDelete {
return func(opts *TopicConfigDelete) {
opts.NameSrvAddr = NameSrvAddr
}
}
type OptionTopicList func(*OptionTopicListConfig)
type OptionTopicListConfig struct {
Cluster string
Nameserver string
}
func defaultTopicList() OptionTopicListConfig {
opts := OptionTopicListConfig{}
return opts
}
func WithClusterTopicList(cluster string) OptionTopicList {
return func(opts *OptionTopicListConfig) {
opts.Cluster = cluster
}
}
func WithNameserver(nameserver string) OptionTopicList {
return func(opts *OptionTopicListConfig) {
opts.Nameserver = nameserver
}
}
type OptionQueryTopicConsume func(config *QueryTopicConsumeConfig)
type QueryTopicConsumeConfig struct {
Brokeraddr string
Topic string
}
func defaultQueryTopicConsume() QueryTopicConsumeConfig {
opts := QueryTopicConsumeConfig{}
return opts
}
func WithBrokeraddr(broker string) OptionQueryTopicConsume {
return func(opts *QueryTopicConsumeConfig) {
opts.Brokeraddr = broker
}
}
func WithTopic(topic string) OptionQueryTopicConsume {
return func(opts *QueryTopicConsumeConfig) {
opts.Topic = topic
}
}
type OptionClusterList func(*ClusterListConfig)
type ClusterListConfig struct {
NamesvrAddr string
}
func defaultClusterList() ClusterListConfig {
opts := ClusterListConfig{}
return opts
}
type OptionUpdatesubGroup func(config *OptionUpdatesubGroupConfig)
type OptionUpdatesubGroupConfig struct {
BrokerAddr string
ClusterName string
GroupName string
BrokerId string
NamesrvAddr string
RetryQueueNums int
RetryMaxTimes int64
ConsumeEnable bool
ConsumeFromMinEnable bool
ConsumeBroadcastEnable bool
}
func defaultOptionUpdatesubGroup() OptionUpdatesubGroupConfig {
opts := OptionUpdatesubGroupConfig{}
return opts
}
func WithGroupName(groupname string) OptionUpdatesubGroup {
return func(opts *OptionUpdatesubGroupConfig) {
opts.GroupName = groupname
}
}
func WithGroupClusterName(clustername string) OptionUpdatesubGroup {
return func(opts *OptionUpdatesubGroupConfig) {
opts.ClusterName = clustername
}
}
func WithConsumeFromMin(t bool) OptionUpdatesubGroup {
return func(opts *OptionUpdatesubGroupConfig) {
opts.ConsumeFromMinEnable = t
}
}
func WithConsumeBroadcast(t bool) OptionUpdatesubGroup {
return func(opts *OptionUpdatesubGroupConfig) {
opts.ConsumeBroadcastEnable = t
}
}
func WithNamesrvAddr(nameserver string) OptionUpdatesubGroup {
return func(opts *OptionUpdatesubGroupConfig) {
opts.NamesrvAddr = nameserver
}
}
func WithBrokerAddr(broker string) OptionUpdatesubGroup {
return func(opts *OptionUpdatesubGroupConfig) {
opts.BrokerAddr = broker
}
}
type OptionConsumerInfo func(config *OptionConsumerInfoConfig)
type OptionConsumerInfoConfig struct {
ConsumerGroup string
BrokerAddr string
}
func defaultOptionConsumerInfo() OptionConsumerInfoConfig {
opts := OptionConsumerInfoConfig{}
return opts
}
func WithConsumerGroup(group string) OptionConsumerInfo {
return func(opts *OptionConsumerInfoConfig) {
opts.ConsumerGroup = group
}
}
func WithConsumerBrokerAddr(broker string) OptionConsumerInfo {
return func(opts *OptionConsumerInfoConfig) {
opts.BrokerAddr = broker
}
}
type OptionDeleteSubGroup func(*OptionDeleteSubGroupConfig)
type OptionDeleteSubGroupConfig struct {
GroupName string
ClusterName string
BrokerAddr string
}
func defaultDeleteSubGroup() OptionDeleteSubGroupConfig {
opts := OptionDeleteSubGroupConfig{}
return opts
}
func WithDeleteSubGroup(group string) OptionDeleteSubGroup {
return func(opts *OptionDeleteSubGroupConfig) {
opts.GroupName = group
}
}
func WithDeleteCluster(cluster string) OptionDeleteSubGroup {
return func(opts *OptionDeleteSubGroupConfig) {
opts.ClusterName = cluster
}
}
func WithDeletebrokeraddr(broker string) OptionDeleteSubGroup {
return func(opts *OptionDeleteSubGroupConfig) {
opts.BrokerAddr = broker
}
}
type OptionConsumerOffset func(*OptionConsumerOffsetConfig)
type OptionConsumerOffsetConfig struct {
ConsumerGroup string
Topic string
QueueId int
BrokerAddr string
}
func defaultConsumerOffset() OptionConsumerOffsetConfig {
opts := OptionConsumerOffsetConfig{}
return opts
}
func WithConsumeroffsetBrokerAddr(broker string) OptionConsumerOffset {
return func(opts *OptionConsumerOffsetConfig) {
opts.BrokerAddr = broker
}
}
func WithConsumerOffsetGroup(group string) OptionConsumerOffset {
return func(opts *OptionConsumerOffsetConfig) {
opts.ConsumerGroup = group
}
}
func WithConsumerOffsetTopic(topic string) OptionConsumerOffset {
return func(opts *OptionConsumerOffsetConfig) {
opts.Topic = topic
}
}
func WithQueId(queid int) OptionConsumerOffset {
return func(opts *OptionConsumerOffsetConfig) {
opts.QueueId = queid
}
}
type OptionQueryConsumeQueueConfig struct {
Topic string
QueueId string
Index int
Count int
ConsumerGroup string
}
type OptionQueryConsumeQueue func(*OptionQueryConsumeQueueConfig)
func defaultOptionQueryConsumeQueue() OptionQueryConsumeQueueConfig {
opts := OptionQueryConsumeQueueConfig{
Index: 8,
QueueId: "1",
}
return opts
}
func WithQueryTopic(topic string) OptionQueryConsumeQueue {
return func(opts *OptionQueryConsumeQueueConfig) {
opts.Topic = topic
}
}
func WithQueryConsumerGroup(group string) OptionQueryConsumeQueue {
return func(opts *OptionQueryConsumeQueueConfig) {
opts.ConsumerGroup = group
}
}
type OptionWipeWritePermConfig struct {
BrokerName string
NamesrvAddr string
}
type OptionWipeWritePerm func(*OptionWipeWritePermConfig)
func defaultOptionWipeWritePerm() OptionWipeWritePermConfig {
opts := OptionWipeWritePermConfig{}
return opts
}
func WithBrokerName(brokername string) OptionWipeWritePerm {
return func(opts *OptionWipeWritePermConfig) {
opts.BrokerName = brokername
}
}
func WithWipeWritePermNamesvr(nameserver string) OptionWipeWritePerm {
return func(opts *OptionWipeWritePermConfig) {
opts.NamesrvAddr = nameserver
}
}
type OptionGetRouteInfoConfig struct {
Topic string
NamesrvAddr string
}
type OptionGetRouteInfo func(*OptionGetRouteInfoConfig)
func defaultOptionGetRouteInfo() OptionGetRouteInfoConfig {
opts := OptionGetRouteInfoConfig{}
return opts
}
func WithTopicRoute(topic string) OptionGetRouteInfo {
return func(opts *OptionGetRouteInfoConfig) {
opts.Topic = topic
}
}
func WithNamesrvAddrRoute(nameserver string) OptionGetRouteInfo {
return func(opts *OptionGetRouteInfoConfig) {
opts.NamesrvAddr = nameserver
}
}
type OptionGetConsumeStatsConfig struct {
ConsumerGroup string
Topic string
BrokerAddr string
}
type OptionGetConsumeStats func(*OptionGetConsumeStatsConfig)
func defaultOptionGetConsumeStats() OptionGetConsumeStatsConfig {
opts := OptionGetConsumeStatsConfig{}
return opts
}
func WithBrokerAddrGetConsume(broker string) OptionGetConsumeStats {
return func(opts *OptionGetConsumeStatsConfig) {
opts.BrokerAddr = broker
}
}
func WithConsumerGroupGetConsume(group string) OptionGetConsumeStats {
return func(opts *OptionGetConsumeStatsConfig) {
opts.ConsumerGroup = group
}
}
func WithTopicGroupGetConsume(topic string) OptionGetConsumeStats {
return func(opts *OptionGetConsumeStatsConfig) {
opts.Topic = topic
}
}
type OptionConsumeStatsInBrokerConfig struct {
IsOrder bool
BrokerAddr string
}
type OptionConsumeStatsInBroker func(config *OptionConsumeStatsInBrokerConfig)
func defaultOptionConsumeStatsInBroker() OptionConsumeStatsInBrokerConfig {
opts := OptionConsumeStatsInBrokerConfig{}
return opts
}
func WithConsumeStatsInBrokerBroker(broker string) OptionConsumeStatsInBroker {
return func(opts *OptionConsumeStatsInBrokerConfig) {
opts.BrokerAddr = broker
}
}
func WithConsumerStatsInIsOrder(b bool) OptionConsumeStatsInBroker {
return func(opts *OptionConsumeStatsInBrokerConfig) {
opts.IsOrder = b
}
}
type OptionUpdateConsumerOffsetConfig struct {
ConsumerGroup string
Topic string
QueueId int
CommitOffset int64
BrokerAddr string
}
type OptionUpdateConsumerOffset func(config *OptionUpdateConsumerOffsetConfig)
func defaultOptionUpdateConsumerOffset() OptionUpdateConsumerOffsetConfig {
opts := OptionUpdateConsumerOffsetConfig{}
return opts
}
func WithUpdateoffsetConsumerGroup(group string) OptionUpdateConsumerOffset {
return func(opts *OptionUpdateConsumerOffsetConfig) {
opts.ConsumerGroup = group
}
}
func WithUpdateoffsetTopic(topic string) OptionUpdateConsumerOffset {
return func(opts *OptionUpdateConsumerOffsetConfig) {
opts.Topic = topic
}
}
func WithUpdateoffsetQueueId(queueid int) OptionUpdateConsumerOffset {
return func(opts *OptionUpdateConsumerOffsetConfig) {
opts.QueueId = queueid
}
}
func WithUpdateoffsetCommitoffset(commitoffset int64) OptionUpdateConsumerOffset {
return func(opts *OptionUpdateConsumerOffsetConfig) {
opts.CommitOffset = commitoffset
}
}
func WithUpdateoffsetBrokerAddr(broker string) OptionUpdateConsumerOffset {
return func(opts *OptionUpdateConsumerOffsetConfig) {
opts.BrokerAddr = broker
}
}
type OptionRegisterBrokerConfig struct {
BrokerName string
BrokerAddr string
ClusterName string
HaServerAddr string
BrokerId int
compressed bool
NameSrvAddr string
}
type OptionRegisterBroker func(broker *OptionRegisterBrokerConfig)
func defaultRegisterBroker() OptionRegisterBrokerConfig {
opts := OptionRegisterBrokerConfig{}
return opts
}
func WithRegistBrokerName(broker string) OptionRegisterBroker {
return func(opts *OptionRegisterBrokerConfig) {
opts.BrokerName = broker
}
}
func WithRegistBrokerAddr(brokerAddr string) OptionRegisterBroker {
return func(opts *OptionRegisterBrokerConfig) {
opts.BrokerAddr = brokerAddr
}
}
func WithRegistClusterName(cluster string) OptionRegisterBroker {
return func(opts *OptionRegisterBrokerConfig) {
opts.ClusterName = cluster
}
}
func WithRegistBrokerId(id int) OptionRegisterBroker {
return func(opts *OptionRegisterBrokerConfig) {
opts.BrokerId = id
}
}
func WithRegistHasrvAddr(haserveraddr string) OptionRegisterBroker {
return func(opts *OptionRegisterBrokerConfig) {
opts.HaServerAddr = haserveraddr
}
}
func WithRegistNamesrvAddr(naserveraddr string) OptionRegisterBroker {
return func(opts *OptionRegisterBrokerConfig) {
opts.NameSrvAddr = naserveraddr
}
}