pubsub

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package pubsub contains various implementation for event dispatcher.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher interface {
	// Dispatch sends the outbox rows to the underlying queuing system.
	Dispatch(ctx context.Context, rows []event.OutboxRow) error

	io.Closer
}

Dispatcher should be implemented by client which dispatches the outbox rows to its Queuing Server.

type Option

type Option func(mq *RabbitMQ) error

Option is functional type to provide an easy way for composing RabbitMQ dispatcher.

func WithTLS

func WithTLS(t *tls.Config) Option

WithTLS sets the TLS configuration to RabbitMQ instance.

type RabbitMQ

type RabbitMQ struct {
	// contains filtered or unexported fields
}

RabbitMQ represents the RabbitMQ specific Dispatcher.

func NewRabbitMQ

func NewRabbitMQ(amqpURL string, sw Sweeper, logger *zap.Logger, opts ...Option) (*RabbitMQ, error)

NewRabbitMQ creates a RabbitMQ dispatcher.

func (*RabbitMQ) Close

func (r *RabbitMQ) Close() error

Close gracefully closes the underlying amqp.Connection through angora.

func (*RabbitMQ) Dispatch

func (r *RabbitMQ) Dispatch(ctx context.Context, rows []event.OutboxRow) (err error)

Dispatch relays the message to RabbitMQ exchange. Successful publish is considered when publish confirm is received, and then sweeper sweeps the successful outbox rows. Failed to publish are immediately marked as "Failed" by sweeper.

type SimpleQueueService

type SimpleQueueService struct {
	// contains filtered or unexported fields
}

SimpleQueueService represents the SimpleQueueService specific Dispatcher.

func NewSimpleQueueService

func NewSimpleQueueService(sqsConn *sqs.SQS, sw Sweeper, logger *zap.Logger) (*SimpleQueueService, error)

NewSimpleQueueService creates a SimpleQueueService dispatcher.

func (*SimpleQueueService) Close

func (s *SimpleQueueService) Close() error

Close Not implemented yet. No documentation found for closing AWS session.

func (*SimpleQueueService) Dispatch

func (s *SimpleQueueService) Dispatch(ctx context.Context, rows []event.OutboxRow) (err error)

Dispatch relays the message to SQS queue. Successful publish is considered soon after SendMessageWithContext returns no error, and then sweeper sweeps the successful outbox rows.

Failed to publish are immediately marked as "Failed" by sweeper.

type Sweeper

type Sweeper interface {
	// Sweep delete the outbox rows from the configured datastore.
	Sweep(ctx context.Context, dispatchedIDs, failedIDs []int) error
}

Sweeper represents the datastore containing outbox rows/events.

Directories

Path Synopsis
Package sweepermock is a generated GoMock package.
Package sweepermock is a generated GoMock package.

Jump to

Keyboard shortcuts

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