pubsub

package module
v0.0.0-...-3b2e18c Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: NCSA Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	EndPayload = "[[END]]"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection interface {
	Close() error
	Options() Options
}

type Message

type Message interface {
	// Messages implement io.Reader to access the payload data.
	io.Reader

	Unmarshal(v interface{}) error

	// Done indicates the client is finished with the message, and the
	// underlying implementation may free its resources. Clients should ensure
	// to call Done for every received message.
	Done() error
}

Message is a minimal interface to describe payloads received by subscribers. Clients may type-assert to more concrete types (e.g. pubsub/kafka.Message) to get access to more specific behaviors.

type Option

type Option func(*Options)

func Endpoints

func Endpoints(addrs []string) Option

func Password

func Password(s string) Option

func Serializer

func Serializer(s serializer.Serializer) Option

func TLSCertificate

func TLSCertificate(s string) Option

func TLSConfig

func TLSConfig(t *tls.Config) Option

func Username

func Username(s string) Option

func UsernamePassword

func UsernamePassword(u string, p string) Option

type Options

type Options struct {
	Endpoints  []string
	Username   string
	Password   string
	TLSConfig  *tls.Config
	Serializer serializer.Serializer
	Context    context.Context
}

type PublishOption

type PublishOption func(*PublishOptions)

type PublishOptions

type PublishOptions struct {
	Context context.Context
}

type Publisher

type Publisher interface {
	// Publish a single message, described by an interface using the serializer.
	Publish(key string, i interface{}) error

	// Publish a single message, described by an io.Reader, to the given key.
	PublishReader(key string, r io.Reader) error

	// End the publisher on channel.
	End(key string) error

	// Stop the publisher.
	Stop() error
}

Publisher is a minimal interface for publishing messages to a pool of subscribers. Publishers are probably (but not necessarily) sending to a message bus.

Most paramaterization of the publisher (topology restrictions like a topic, exchange, or specific message type; queue or buffer sizes; etc.) should be done in the concrete constructor.

type SubscribeOption

type SubscribeOption func(*SubscribeOptions)

type SubscribeOptions

type SubscribeOptions struct {
	Context context.Context
}

type Subscriber

type Subscriber interface {
	// Start returns a channel of messages that the caller should consume.
	// Failure to keep up with the incoming messages will have different
	// consequences depending on the concrete implementation of the subscriber.
	//
	// The channel will be closed when the subscriber encounters an error, or
	// when the caller invokes Stop, whichever comes first.
	Start() <-chan Message

	// Err returns the error that was responsible for closing the channel of
	// incoming messages.
	Err() error

	// Stop the subscriber, closing the channel that was returned by Start.
	Stop() error
}

Subscriber is a minimal interface for subscribing to published messages. Subscribers are probably (but not necessarily) receiving from a message bus.

Most paramaterization of the subscriber (topology restrictions like a topic, exchange, or specific message type; queue or buffer sizes; etc.) should be done in the concrete constructor.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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