Documentation ¶
Overview ¶
Package delayedmessage provides tools for delaying the sending of messages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultPollInterval = 15 * time.Second
DefaultPollInterval is the duration to wait before checking for new messages to send.
Functions ¶
This section is empty.
Types ¶
type Interceptor ¶
type Interceptor struct { Repository Repository Next endpoint.OutboundPipeline }
Interceptor is an outbound pipeline stage that intercepts messages that are not ready to be sent.
func (*Interceptor) Accept ¶
func (i *Interceptor) Accept(ctx context.Context, env endpoint.OutboundEnvelope) error
Accept passes env to the next pipeline stage only if it is ready to send now, otherwise it stores it to be sent in the future.
func (*Interceptor) Initialize ¶
Initialize is called during initialization of the endpoint, after the transport is initialized. It can be used to inspect or further configure the endpoint as per the needs of the pipeline.
type Repository ¶
type Repository interface { // LoadNextMessage loads the next that is scheduled to be sent. LoadNextMessage( ctx context.Context, ds persistence.DataStore, ) (endpoint.OutboundEnvelope, bool, error) // SaveMessage saves a message to be sent at a later time. // If does NOT return an error if the message already exists in the repository. SaveMessage( ctx context.Context, tx persistence.Tx, env endpoint.OutboundEnvelope, ) error // MarkAsSent marks a message as sent, removing it from the repository. MarkAsSent( ctx context.Context, tx persistence.Tx, env endpoint.OutboundEnvelope, ) error }
Repository is an interface for
type Sender ¶
type Sender struct { DataStore persistence.DataStore Repository Repository OutboundPipeline endpoint.OutboundPipeline PollInterval time.Duration }
Sender is a service that sends delayed messages when they become ready to be sent.