events

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: 13 Imported by: 0

Documentation

Index

Constants

View Source
const Interval = 1

Interval represents the number of seconds to wait between to heartbeat rounds.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {

	// Query allows directly querying the API
	Query(string, string, interface{}, string) (*client.Response, string, error)

	// Websocket allows directly connection to API websockets
	Websocket(path string) (*websocket.Conn, error)
}

Client represents a way to interact with the server API

type Cluster

type Cluster interface {
	db.ClusterTransactioner
}

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

type Endpoints

type Endpoints interface {

	// NetworkAddress returns the network addresss of the network endpoint, or an
	// empty string if there's no network endpoint
	NetworkAddress() string

	// NetworkCert returns the full TLS certificate information for this endpoint.
	NetworkCert() *cert.Info
}

Endpoints are in charge of bringing up and down the HTTP endpoints for serving the RESTful API.

type EventHook

type EventHook func(int64, interface{})

EventHook is called when an event is dispatched

type Events

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

Events starts a task that continuously monitors the list of cluster nodes and maintains a pool of websocket connections against all of them, in order to get notified about events.

Whenever an event is received the given hook is invoked.

func New

func New(endpoints Endpoints, cluster Cluster, hook EventHook, options ...Option) *Events

New creates a new event listener with sane defaults

func (*Events) Run

func (e *Events) Run() (task.Func, task.Schedule)

Run returns a task function that performs event listener checks against all nodes in the cluster.

type EventsSource

type EventsSource interface {

	// GetEvents connects to monitoring interface
	GetEvents() (*events.EventListener, error)
}

EventsSource returns the raw messages from the server API

type EventsSourceProvider

type EventsSourceProvider interface {

	// New creates a new events source for a given address
	Events(string, *cert.Info) (Client, EventsSource, error)
}

EventsSourceProvider creates a new EventsSource

type Option

type Option func(*options)

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

func WithClock

func WithClock(clock clock.Clock) Option

WithClock sets the clock on the option

func WithEventsSourceProvider

func WithEventsSourceProvider(eventsSourceProvider EventsSourceProvider) Option

WithEventsSourceProvider sets the eventsSourceProvider on the option

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger sets the logger on the option

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