backend

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2018 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Publish added in v0.2.7

func Publish(publish func() error, canRetry func(err error) bool, retry Backoff) error

Publish may be used by Backend implementations to provide backoff and retry for network problems.

func Register

func Register(name string, fn Constructor) error

Register register a new broker backend under a name. It is tipically used in init functions.

Types

type Backend

type Backend interface {
	Publish(topic string, data []byte) error

	// Subscribe associates a message handler function to a particular topic.
	// The backend must handle the messages to all the subscribers. The message
	// must only be regarded as consumed when all the handlers have returned and
	// none of them returned a non-nil value.
	Subscribe(topic string, cb Handler)

	// Verify the availability of a topic.
	Check(topic string) error

	Close() error
}

Backend is a low-level interface used to interact with RDSS brokers.

func Dial

func Dial(name string, opts ...DialOpts) (Backend, error)

Dial dials the named broker backend using the dial options opts.

type Backoff added in v0.2.7

type Backoff interface {
	NextBackOff() time.Duration
}

Backoff wraps a network retry backoff type to control backoff periods. Typically we want the 3rd-party backoff structure, but others, e.g. a test version can be used instead.

type Constructor

type Constructor func(*Opts) (Backend, error)

Constructor is a function that initializes and returns a Backend implementation with the given options.

type DialOpts

type DialOpts func(*Opts) error

DialOpts is a daisy-chaining mechanism for setting options to a backend during Dial.

func WithKeyValue

func WithKeyValue(key, value string) DialOpts

WithKeyValue sets a key-value pair as option. If called multiple times with the same key, the last one wins.

func WithOptions

func WithOptions(options string) DialOpts

WithOptions parses a string in the format "key1=value1,key2=value2,..." where keys and values are specific to each storage backend. Neither key nor value may contain the characters "," or "=". Use WithKeyValue repeatedly if these characters need to be used.

type Handler

type Handler func([]byte) error

Handler is a message handler for a particular topic.

type Opts

type Opts struct {
	Opts map[string]string
}

Opts holds configuration for the broker backend. It is meant to be used by implementations of Storage

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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