Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GoQueueOption ¶
type GoQueueOption struct { // NumberOfConsumer is the number of consumer/worker/goroutine that will be spawned in one GoQueue instance. NumberOfConsumer int // Consumer is the consumer implementation that will be used by the GoQueue instance. Consumer consumer.Consumer // Publisher is the publisher implementation that will be used by the GoQueue instance. Publisher publisher.Publisher // MessageHandler is the inbound message handler that will be used by the GoQueue instance. MessageHandler interfaces.InboundMessageHandler }
GoQueueOption represents the options for configuring a GoQueue instance.
func DefaultGoQueueOption ¶
func DefaultGoQueueOption() *GoQueueOption
type GoQueueOptionFunc ¶
type GoQueueOptionFunc func(opt *GoQueueOption)
GoQueueOptionFunc used for option chaining
func WithConsumer ¶
func WithConsumer(c consumer.Consumer) GoQueueOptionFunc
WithConsumer sets the consumer for the GoQueueOption. It takes a consumer.Consumer as a parameter and returns a GoQueueOptionFunc. The GoQueueOptionFunc sets the Consumer field of the GoQueueOption.
func WithMessageHandler ¶
func WithMessageHandler(h interfaces.InboundMessageHandler) GoQueueOptionFunc
WithMessageHandler sets the inbound message handler for the GoQueueOption. The inbound message handler is responsible for processing incoming messages. It takes an instance of the interfaces.InboundMessageHandler interface as a parameter. Example usage:
WithMessageHandler(func(message interfaces.InboundMessage) { // Process the incoming message })
func WithNumberOfConsumer ¶
func WithNumberOfConsumer(n int) GoQueueOptionFunc
WithNumberOfConsumer sets the number of consumers for the GoQueue. It takes an integer value 'n' as input and updates the NumberOfConsumer field of the GoQueueOption struct. This option determines how many goroutines will be created to consume items from the queue concurrently.
func WithPublisher ¶
func WithPublisher(p publisher.Publisher) GoQueueOptionFunc
WithPublisher sets the publisher for the GoQueueOption. It takes a publisher.Publisher as a parameter and returns a GoQueueOptionFunc. The returned GoQueueOptionFunc sets the Publisher field of the GoQueueOption to the provided publisher.