events

package
v0.0.0-...-0e2b5c9 Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package events is a generated GoMock package.

Package events is a generated GoMock package.

Package events is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrListenerNotFound = errors.New("listener not found")
)

events errors

View Source
var (
	// EventChanBufferSize is the maximum number of events to be retained on an listener event channel
	EventChanBufferSize = 100
)

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher interface {
	AddListener(Listener)
	RemoveListener(Listener) error
	Listeners() []Listener
	Dispatch(Event)
}

Dispatcher defines a component able to dispatch an event to all subscribed listeners

func NewDispatcher

func NewDispatcher(logger log.FieldLogger) Dispatcher

NewDispatcher returns a new instance of an event dispatcher

type Event

type Event struct {
	Type      EventType
	Source    string
	Target    string
	Timestamp time.Time
}

Event defines an interface for a generic system event

type EventType

type EventType int

EventType defines a custom type for describing events

const (
	Undefined EventType = iota
	ClientSubscribed
	ClientUnsubscribed
)

List of event types

type Factory

type Factory interface {
	NewClientSubscribedEvent(source string, target string) Event
	NewClientUnsubscribedEvent(source string, target string) Event
}

Factory allows to create events

func NewFactory

func NewFactory() Factory

NewFactory creates a new event factory

type Listener

type Listener interface {
	C() <-chan Event
	Close() error
	Send(Event)
}

Listener defines a type listening for events

func NewListener

func NewListener(dispatcher Dispatcher) Listener

NewListener creates a new Listener and register it on the dispatcher It holds an internal buffered channel for events, of size EventChanBufferSize.

type MockDispatcher

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

MockDispatcher is a mock of Dispatcher interface

func NewMockDispatcher

func NewMockDispatcher(ctrl *gomock.Controller) *MockDispatcher

NewMockDispatcher creates a new mock instance

func (*MockDispatcher) AddListener

func (m *MockDispatcher) AddListener(arg0 Listener)

AddListener mocks base method

func (*MockDispatcher) Dispatch

func (m *MockDispatcher) Dispatch(arg0 Event)

Dispatch mocks base method

func (*MockDispatcher) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockDispatcher) Listeners

func (m *MockDispatcher) Listeners() []Listener

Listeners mocks base method

func (*MockDispatcher) RemoveListener

func (m *MockDispatcher) RemoveListener(arg0 Listener) error

RemoveListener mocks base method

type MockDispatcherMockRecorder

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

MockDispatcherMockRecorder is the mock recorder for MockDispatcher

func (*MockDispatcherMockRecorder) AddListener

func (mr *MockDispatcherMockRecorder) AddListener(arg0 interface{}) *gomock.Call

AddListener indicates an expected call of AddListener

func (*MockDispatcherMockRecorder) Dispatch

func (mr *MockDispatcherMockRecorder) Dispatch(arg0 interface{}) *gomock.Call

Dispatch indicates an expected call of Dispatch

func (*MockDispatcherMockRecorder) Listeners

func (mr *MockDispatcherMockRecorder) Listeners() *gomock.Call

Listeners indicates an expected call of Listeners

func (*MockDispatcherMockRecorder) RemoveListener

func (mr *MockDispatcherMockRecorder) RemoveListener(arg0 interface{}) *gomock.Call

RemoveListener indicates an expected call of RemoveListener

type MockFactory

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

MockFactory is a mock of Factory interface

func NewMockFactory

func NewMockFactory(ctrl *gomock.Controller) *MockFactory

NewMockFactory creates a new mock instance

func (*MockFactory) EXPECT

func (m *MockFactory) EXPECT() *MockFactoryMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockFactory) NewClientSubscribedEvent

func (m *MockFactory) NewClientSubscribedEvent(arg0, arg1 string) Event

NewClientSubscribedEvent mocks base method

func (*MockFactory) NewClientUnsubscribedEvent

func (m *MockFactory) NewClientUnsubscribedEvent(arg0, arg1 string) Event

NewClientUnsubscribedEvent mocks base method

type MockFactoryMockRecorder

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

MockFactoryMockRecorder is the mock recorder for MockFactory

func (*MockFactoryMockRecorder) NewClientSubscribedEvent

func (mr *MockFactoryMockRecorder) NewClientSubscribedEvent(arg0, arg1 interface{}) *gomock.Call

NewClientSubscribedEvent indicates an expected call of NewClientSubscribedEvent

func (*MockFactoryMockRecorder) NewClientUnsubscribedEvent

func (mr *MockFactoryMockRecorder) NewClientUnsubscribedEvent(arg0, arg1 interface{}) *gomock.Call

NewClientUnsubscribedEvent indicates an expected call of NewClientUnsubscribedEvent

type MockListener

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

MockListener is a mock of Listener interface

func NewMockListener

func NewMockListener(ctrl *gomock.Controller) *MockListener

NewMockListener creates a new mock instance

func (*MockListener) C

func (m *MockListener) C() <-chan Event

C mocks base method

func (*MockListener) Close

func (m *MockListener) Close() error

Close mocks base method

func (*MockListener) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockListener) Send

func (m *MockListener) Send(arg0 Event)

Send mocks base method

type MockListenerMockRecorder

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

MockListenerMockRecorder is the mock recorder for MockListener

func (*MockListenerMockRecorder) C

C indicates an expected call of C

func (*MockListenerMockRecorder) Close

func (mr *MockListenerMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close

func (*MockListenerMockRecorder) Send

func (mr *MockListenerMockRecorder) Send(arg0 interface{}) *gomock.Call

Send indicates an expected call of Send

Jump to

Keyboard shortcuts

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