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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Actor

type Actor interface {

	// ID returns the unique ID for the actor
	ID() string

	// Types returns the underlying types the actor subscribes to
	Types() []string

	// Write pushes information to the actor
	Write([]byte) error

	// Close the actor
	Close()

	// NoForward decides if messages should be forwarded to the actor
	NoForward() bool

	// Done returns if the actor is done messaging.
	Done() bool
}

Actor defines an broker between event messages and nodes

type ActorGroup

type ActorGroup interface {

	// Add an actor to a group
	Add(a Actor)

	// Prune removes any done actors
	Prune() bool

	// Walk over the actors with in the group one by one (order is not
	// guaranteed).
	Walk(func(Actor) error) error
}

ActorGroup holds a group of actors

type Client

type Client interface {

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

Client represents a way to interact with the server API

type EventBroadcaster

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

EventBroadcaster allows messages to be dispatched to other actors.

func NewEventBroadcaster

func NewEventBroadcaster(actorGroup ActorGroup, logger log.Logger) *EventBroadcaster

NewEventBroadcaster creates a new EventBroadcaster

func (*EventBroadcaster) Dispatch

func (e *EventBroadcaster) Dispatch(event map[string]interface{}) error

Dispatch an event to other awaiting actors.

type EventListener

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

EventListener struct is used to interact with a event stream

func (*EventListener) ActiveChan

func (e *EventListener) ActiveChan() chan bool

ActiveChan returns the underlying channel

func (*EventListener) AddHandler

func (e *EventListener) AddHandler(types []string, function func(interface{})) *EventTarget

AddHandler adds a function to be called whenever an event is received

func (*EventListener) Disconnect

func (e *EventListener) Disconnect()

Disconnect must be used once done listening for events

func (*EventListener) Err

func (e *EventListener) Err() error

Err return the potentially underlying error

func (*EventListener) IsActive

func (e *EventListener) IsActive() bool

IsActive returns true if this listener is still connected, false otherwise.

func (*EventListener) RemoveHandler

func (e *EventListener) RemoveHandler(target *EventTarget) error

RemoveHandler removes a function to be called whenever an event is received

func (*EventListener) Wait

func (e *EventListener) Wait() error

Wait hangs until the server disconnects the connection or Disconnect() is called

type EventTarget

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

EventTarget struct is returned to the caller of AddHandler and used in RemoveHandler

type Events

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

Events represents the API for the Events

func NewEvents

func NewEvents(client Client, options ...Option) *Events

NewEvents creates an Events API with sane defaults

func (*Events) GetEvents

func (e *Events) GetEvents() (*EventListener, error)

GetEvents connects to monitoring interface

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 WithLogger

func WithLogger(logger log.Logger) Option

WithLogger sets the logger on the option

Jump to

Keyboard shortcuts

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