Documentation ¶
Index ¶
Constants ¶
const ( DelayedUntilKey = "_watermill_delayed_until" DelayedForKey = "_watermill_delayed_for" )
Variables ¶
This section is empty.
Functions ¶
func Message ¶
Message sets the delay metadata on the message.
IMPORTANT: Delay doesn't work with all Pub/Subs! Using it won't have any effect on Pub/Subs that don't support it. See the list of supported Pub/Subs in the documentation: https://watermill.io/advanced/delayed-messages/
func NewPublisher ¶
NewPublisher wraps a publisher with a delay mechanism. A message can be published with delay metadata set in the context by using the WithContext function. If the message doesn't have the delay metadata set, the default delay will be applied, if provided.
func WithContext ¶
WithContext returns a new context with the given delay. If used together with a publisher wrapped with NewPublisher, the delay will be applied to the message.
IMPORTANT: Delay doesn't work with all Pub/Subs! Using it won't have any effect on Pub/Subs that don't support it. See the list of supported Pub/Subs in the documentation: https://watermill.io/advanced/delayed-messages/
Types ¶
type Delay ¶
type Delay struct {
// contains filtered or unexported fields
}
Delay represents a message's delay. It can be either a delay until a specific time or a delay for a specific duration. The zero value of Delay is a zero delay.
IMPORTANT: Delay doesn't work with all Pub/Subs! Using it won't have any effect on Pub/Subs that don't support it. See the list of supported Pub/Subs in the documentation: https://watermill.io/advanced/delayed-messages/
type PublisherConfig ¶
type PublisherConfig struct { // DefaultDelayGenerator is a function that generates the default delay for a message. // If the message doesn't have the delay metadata set, the default delay will be applied. DefaultDelayGenerator func(params DefaultDelayGeneratorParams) (Delay, error) // AllowNoDelay allows publishing messages without a delay set. // By default, the publisher returns an error when a message is published without a delay and no default delay generator is provided. AllowNoDelay bool }
PublisherConfig is a configuration for the delay publisher.