Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DelayFn ¶
var ( // ExponentialBackoffDelayFn is a delay function that implements exponential backoff. // It takes the number of retries as input and returns the delay in seconds. ExponentialBackoffDelayFn DelayFn = func(currenRetries int64) (delay int64) { return 2 << (currenRetries - 1) } // LinearDelayFn is a delay function that implements linear delay. // It takes the number of retries as input and returns the delay in seconds. LinearDelayFn DelayFn = func(currenRetries int64) (delay int64) { return currenRetries } // NoDelayFn is a DelayFn implementation that returns 0 delay for retries. NoDelayFn DelayFn = func(currenRetries int64) (delay int64) { return 0 } DefaultDelayFn DelayFn = LinearDelayFn )
type InboundMessage ¶
type InboundMessage struct {
Message
RetryCount int64 `json:"retryCount"`
Metadata map[string]interface{} `json:"metadata"`
// Ack is used for confirming the message. It will drop the message from the queue.
Ack func(ctx context.Context) (err error) `json:"-"`
// Nack is used for rejecting the message. It will requeue the message to be re-delivered again.
Nack func(ctx context.Context) (err error) `json:"-"`
// MoveToDeadLetterQueue is used for rejecting the message same with Nack, but instead of requeueing the message,
// Read how to configure dead letter queue in each queue provider.
// eg RabbitMQ: https://www.rabbitmq.com/docs/dlx
MoveToDeadLetterQueue func(ctx context.Context) (err error) `json:"-"`
// Requeue is used to put the message back to the tail of the queue after a delay.
RetryWithDelayFn func(ctx context.Context, delayFn DelayFn) (err error) `json:"-"`
}
type InboundMessageHandler ¶
type InboundMessageHandler interface {
HandleMessage(ctx context.Context, m InboundMessage) (err error)
}
type InboundMessageHandlerFunc ¶
type InboundMessageHandlerFunc func(ctx context.Context, m InboundMessage) (err error)
func (InboundMessageHandlerFunc) HandleMessage ¶
func (mhf InboundMessageHandlerFunc) HandleMessage(ctx context.Context, m InboundMessage) (err error)
type InboundMessageHandlerMiddlewareFunc ¶
type InboundMessageHandlerMiddlewareFunc func(next InboundMessageHandlerFunc) InboundMessageHandlerFunc
type Message ¶
type Message struct {
ID string `json:"id"`
Action string `json:"action"`
Topic string `json:"topic"`
Data any `json:"data"`
ContentType headerVal.ContentType `json:"-"`
Timestamp time.Time `json:"timestamp"`
Headers map[string]interface{} `json:"-"`
ServiceAgent headerVal.GoquServiceAgent `json:"-"`
// contains filtered or unexported fields
}
Message represents a message that will be published to the queue It contains the message ID, action, topic, data, content type, timestamp, headers, and service agent. The schema version is set by the SetSchemaVersion method. The message is used to publish messages to the queue. Read the concept of message publishing in the documentation, here: TODO(bxcodec): Add link to the documentation
func (*Message) GetSchemaVersion ¶
func (*Message) SetSchemaVersion ¶
type PublisherFunc ¶
PublisherFunc is a function type that represents a publisher function. It takes a context and a message as input parameters and returns an error.
type PublisherHandler ¶
PublisherHandler is an interface that defines the behavior of a message publisher.
type PublisherMiddlewareFunc ¶
type PublisherMiddlewareFunc func(next PublisherFunc) PublisherFunc
Click to show internal directories.
Click to hide internal directories.