outbox

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package outbox provides an inbound pipeline stage that ensures message idempotence by employing the "outbox pattern".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deduplicator

type Deduplicator struct {
	Repository Repository
	Next       endpoint.InboundPipeline
}

Deduplicator is an inbound pipeline stage that provides message idempotency using the "outbox" pattern.

See http://gistlabs.com/2014/05/the-outbox/

func (*Deduplicator) Accept

Accept passes env to the next pipeline stage only if it has not been processed previously.

If it has been processed previously, the messages that were produced the first time are sent using s.

func (*Deduplicator) Initialize

func (d *Deduplicator) Initialize(ctx context.Context, ep *endpoint.Endpoint) error

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 {
	// LoadOutbox loads the unsent outbound messages that were produced when the
	// message identified by id was first processed.
	//
	// ok is false if the message has not yet been successfully processed.
	LoadOutbox(
		ctx context.Context,
		ds persistence.DataStore,
		id ax.MessageID,
	) (envs []endpoint.OutboundEnvelope, ok bool, err error)

	// SaveOutbox saves a set of unsent outbound messages that were produced
	// when the message identified by id was processed.
	SaveOutbox(
		ctx context.Context,
		tx persistence.Tx,
		id ax.MessageID,
		envs []endpoint.OutboundEnvelope,
	) error

	// MarkAsSent marks a message as sent, removing it from the outbox.
	MarkAsSent(
		ctx context.Context,
		tx persistence.Tx,
		env endpoint.OutboundEnvelope,
	) error
}

Repository is an interface for manipulating the outgoing messages that comprise an incoming message's outbox.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL