pubsub

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: Apache-2.0 Imports: 2 Imported by: 4

README

atlas-pubsub

Build Status Code Coverage GoDoc

Pub/Sub implementations

Each package within this directory is a different implementation of a pub/sub message broker that complies with the interface declared in interface.go.

aws

This package provides a SNS+SQS implementation that can be used by providing AWS credentials.

grpc

This package provides a gRPC server implementation that wraps a pub/sub broker implementation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message interface {
	// MessageID returns the ID that uniquely identifies this message. You can use
	// this to Ack or extend the ack deadline from the Subscriber
	MessageID() string
	// Message returns the payload from the message
	Message() []byte
	// Metadata returns the metadata associated with this message
	Metadata() map[string]string
	// ExtendAckDeadline extends the duration that a message can remain in-flight
	// before it will get added back to the message queue for redelivery. Call
	// this if processing the message will take longer than the existing time window.
	ExtendAckDeadline(time.Duration) error
	// Ack will signal to the message broker that this given message has been
	// processed and can be deleted
	Ack() error
}

Message contains the payload for a message with at-least-once delivery semantics

type Option added in v0.2.1

type Option func(*Options)

Option function

func Filter added in v0.2.1

func Filter(filter map[string]string) Option

Filter will only show messages based on the filter

func RetentionPeriod added in v0.2.1

func RetentionPeriod(timeDuration time.Duration) Option

RetentionPeriod sets the default retention period for a subscriber, in other words the length of time a message can stay in the queue

func VisibilityTimeout added in v0.2.1

func VisibilityTimeout(timeDuration time.Duration) Option

VisibilityTimeout will postpone resending the message in-flight for the specified duration, period of time during which subsriber prevents other consumers from receiving and processing the message

type Options added in v0.2.1

type Options struct {
	VisibilityTimeout time.Duration
	RetentionPeriod   time.Duration
	Filter            map[string]string
}

Options defines functional options available to a Subscriber

type Publisher

type Publisher interface {
	// Publishes the given message to the message broker. The topic should be
	// known to the publisher prior to making this call
	Publish(context.Context, []byte, map[string]string) error

	//DeleteTopic free all resources associated with topic
	DeleteTopic(ctx context.Context) error
}

Publisher defines the basic interface for publishing messages to a message broker

type Subscriber

type Subscriber interface {
	// Start creates a channel to the message broker for receiving messages
	Start(ctx context.Context, options ...Option) (<-chan Message, <-chan error)
	// AckMessage will delete the given message from its respective message queue
	AckMessage(ctx context.Context, messageID string) error
	// ExtendAckDeadline will postpone resending the given in-flight message for
	// the specified duration
	ExtendAckDeadline(ctx context.Context, messageID string, newDuration time.Duration) error

	//DeleteSubscription free all resources associated with subscription
	DeleteSubscription(ctx context.Context) error
}

Subscriber defines the interface for a subscriber with at-least- once message delivery semantics

Directories

Path Synopsis
examples
Package grpc is a generated protocol buffer package.
Package grpc is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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