notifier

package
v0.0.0-...-d2438c5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster interface {
	db.ClusterTransactioner

	// EnterExclusive acquires a lock on the cluster db, so any successive call to
	// Transaction will block until ExitExclusive has been called.
	EnterExclusive() error

	// ExitExclusive runs the given transaction and then releases the lock acquired
	// with EnterExclusive.
	ExitExclusive(func(*db.ClusterTx) error) error

	// NodeID sets the the node NodeID associated with this cluster instance. It's used for
	// backward-compatibility of all db-related APIs that were written before
	// clustering and don't accept a node NodeID, so in those cases we automatically
	// use this value as implicit node NodeID.
	NodeID(int64)
}

Cluster mediates access to data stored in the cluster dqlite database.

type Node

type Node interface {
	db.NodeTransactioner
}

Node mediates access to the data stored in the node-local SQLite database.

type Notifier

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

Notifier is a function that invokes the given function against each node in the cluster excluding the invoking one.

func New

func New(state State, cert *cert.Info, nodeConfigSchema config.Schema, options ...Option) *Notifier

New builds a Notifier that can be used to notify other peers using the given policy.

func (*Notifier) Run

func (n *Notifier) Run(fn func(*client.Client) error, policy Policy) error

Run is a function that invokes the given function against each node in the cluster excluding the invoking one.

type Option

type Option func(*options)

Option to be passed to Connect to customize the resulting instance.

func WithCert

func WithCert(certInfo *cert.Info) Option

WithCert sets the certInfo on the options

func WithClock

func WithClock(clock clock.Clock) Option

WithClock sets the clock on the option

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient sets the httpClient on the option

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger sets the logger on the option

func WithState

func WithState(state State) Option

WithState sets the state on the options

type Policy

type Policy int

Policy can be used to tweak the behavior of NewNotifier in case of some nodes are down.

const (
	NotifyAll   Policy = iota // Requires that all nodes are up.
	NotifyAlive               // Only notifies nodes that are alive
)

Possible notification policies.

type State

type State interface {
	// Node returns the underlying Node
	Node() Node

	// Cluster returns the underlying Cluster
	Cluster() Cluster
}

State is a gateway to the two main stateful components, the database and the operating system. It's typically used by model entities in order to perform changes.

Directories

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

Jump to

Keyboard shortcuts

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