File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ type options struct {
21
21
cluster bool
22
22
group string
23
23
consumer string
24
+ maxLength int64
24
25
}
25
26
26
27
// WithAddr setup the addr of redis
@@ -30,6 +31,13 @@ func WithAddr(addr string) Option {
30
31
}
31
32
}
32
33
34
+ // WithMaxLength setup the max length for publish messages
35
+ func WithMaxLength (m int64 ) Option {
36
+ return func (w * options ) {
37
+ w .maxLength = m
38
+ }
39
+ }
40
+
33
41
// WithPassword redis password
34
42
func WithDB (db int ) Option {
35
43
return func (w * options ) {
Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ func (w *Worker) queue(data interface{}) error {
208
208
// Publish a message.
209
209
err := w .rdb .XAdd (ctx , & redis.XAddArgs {
210
210
Stream : w .opts .streamName ,
211
- MaxLen : 0 ,
211
+ MaxLen : w . opts . maxLength ,
212
212
Values : data ,
213
213
}).Err ()
214
214
You can’t perform that action at this time.
0 commit comments