@@ -2,14 +2,22 @@ package consumer
22
33import "github.com/bxcodec/goqueue"
44
5+ const (
6+ DefaultMaxRetryFailedMessage = 3
7+ DefaultBatchMessageSize = 1
8+ )
9+
510// Option represents the configuration options for the consumer.
611type Option struct {
712 // BatchMessageSize specifies the maximum number of messages to be processed in a single batch.
813 BatchMessageSize int
914 // QueueName specifies the name of the queue to consume messages from.
1015 QueueName string
1116 // Middlewares is a list of middleware functions to be applied to the inbound message handler.
12- Middlewares []goqueue.InboundMessageHandlerMiddlewareFunc
17+ Middlewares []goqueue.InboundMessageHandlerMiddlewareFunc
18+ ActionsPatternSubscribed []string
19+ TopicName string
20+ MaxRetryFailedMessage int64
1321}
1422
1523// OptionFunc is a function type that takes an `opt` parameter of type `*Option`.
@@ -40,3 +48,28 @@ func WithMiddlewares(middlewares ...goqueue.InboundMessageHandlerMiddlewareFunc)
4048 opt .Middlewares = middlewares
4149 }
4250}
51+
52+ // WithActionsPatternSubscribed sets the actions that the consumer will subscribe to.
53+ // It takes a variadic parameter `actions` which represents the actions to be subscribed.
54+ // The actions are stored in the `ActionsPatternSubscribed` field of the `Option` struct.
55+ func WithActionsPatternSubscribed (actions ... string ) OptionFunc {
56+ return func (opt * Option ) {
57+ opt .ActionsPatternSubscribed = actions
58+ }
59+ }
60+
61+ // WithTopicName sets the topic name for the consumer option.
62+ func WithTopicName (name string ) OptionFunc {
63+ return func (opt * Option ) {
64+ opt .TopicName = name
65+ }
66+ }
67+
68+ // WithMaxRetryFailedMessage sets the maximum number of retries for failed messages.
69+ // It takes an integer parameter 'n' and returns an OptionFunc.
70+ // The OptionFunc updates the 'MaxRetryFailedMessage' field of the Option struct.
71+ func WithMaxRetryFailedMessage (n int64 ) OptionFunc {
72+ return func (opt * Option ) {
73+ opt .MaxRetryFailedMessage = n
74+ }
75+ }
0 commit comments