Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher[T IOutboxMessage] struct { // contains filtered or unexported fields }
Dispatcher is responsible for dispatching outbox messages.
func NewDispatcher ¶
func NewDispatcher[T IOutboxMessage](call func(context.Context, T) error, opts ...DispatcherOption[T]) *Dispatcher[T]
NewDispatcher creates a new Dispatcher with the provided options.
func NewDispatcherWithClient ¶
func NewDispatcherWithClient[T IOutboxMessage](client IOutboxDispatcherClient, call func(context.Context, T) error, opts ...DispatcherOption[T]) *Dispatcher[T]
NewDispatcherWithClient creates a new Dispatcher with the provided client and options.
func (*Dispatcher[T]) Name ¶
func (d *Dispatcher[T]) Name() string
Name returns the name of the dispatcher.
type DispatcherOption ¶
type DispatcherOption[T IOutboxMessage] func(*Dispatcher[T])
DispatcherOption represents a configuration option for the Dispatcher.
func WithBatchSize ¶
func WithBatchSize[T IOutboxMessage](batchSize int) DispatcherOption[T]
WithBatchSize sets the batch size for reading messages.
func WithErrorLogger ¶
func WithErrorLogger[T IOutboxMessage](logger Logger) DispatcherOption[T]
WithErrorLogger sets the logger for error messages.
func WithInterval ¶
func WithInterval[T IOutboxMessage](interval time.Duration) DispatcherOption[T]
WithInterval sets the interval between dispatching attempts.
func WithMaxRetry ¶
func WithMaxRetry[T IOutboxMessage](maxRetry int) DispatcherOption[T]
WithMaxRetry sets the maximum number of retries for a message.
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator is responsible for generating outbox messages.
func NewGenerator ¶
func NewGenerator(opts ...GeneratorOption) *Generator
NewGenerator creates a new Generator with the provided options.
func NewGeneratorWithClient ¶
func NewGeneratorWithClient(client IOutboxGeneratorClient, opts ...GeneratorOption) *Generator
NewGeneratorWithClient creates a new Generator with the provided client and options.
type GeneratorOption ¶
type GeneratorOption func(*Generator)
GeneratorOption represents a configuration option for the Generator.
func WithGeneratorClient ¶
func WithGeneratorClient(client IOutboxGeneratorClient) GeneratorOption
WithGeneratorClient sets the client for the Generator.
type IOutboxDispatcherClient ¶
type IOutboxDispatcherClient interface { ReadBatch(ctx context.Context, messageType string, batchSize int) ([]Message, error) SetDone(ctx context.Context, m Message) error IncRetry(ctx context.Context, m Message) error SetBroken(ctx context.Context, m Message) error WithTransaction(ctx context.Context, fn func(context.Context) error) (err error) }
IOutboxDispatcherClient defines the interface for the outbox dispatcher client.
type IOutboxGeneratorClient ¶
IOutboxGeneratorClient defines the interface for the outbox generator client.
type IOutboxMessage ¶
IOutboxMessage defines the interface for an outbox message.
type Logger ¶
type Logger func(string, ...interface{})
Logger is a function type for logging messages.
type Message ¶
type Message struct { ID int64 // ID is the unique identifier of the message. MessageType string // MessageType is the type of the message. Body []byte // Body is the content of the message. AggregateKey string // AggregateKey is the key used to group related messages. Status Status // Status is the current status of the message. RetryCount int // RetryCount is the number of times the message has been retried. }
Message represents an outbox message.