dispatcher

package
Version: v1.0.0-alpha3 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2018 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLoadBalancePolicy

func WithLoadBalancePolicy(value lbp.LoadBalancePolicy) options.Opt

WithLoadBalancePolicy sets the load-balance policy to use when choosing an event endpoint from a set of endpoints

Types

type ConnectEvent

type ConnectEvent struct {
	ErrCh        chan<- error
	FromBlockNum uint64
}

ConnectEvent is a request to connect to the server

func NewConnectEvent

func NewConnectEvent(errch chan<- error) *ConnectEvent

NewConnectEvent creates a new ConnectEvent

type ConnectedEvent

type ConnectedEvent struct {
}

ConnectedEvent indicates that the client has connected to the server

func NewConnectedEvent

func NewConnectedEvent() *ConnectedEvent

NewConnectedEvent creates a new ConnectedEvent

type ConnectionEvent

type ConnectionEvent struct {
	Connected bool
	Err       error
}

ConnectionEvent is sent when the client disconnects from or reconnects to the event server. Connected == true means that the client has connected, whereas Connected == false means that the client has disconnected. In the disconnected case, Err contains the disconnect error.

func NewConnectionEvent

func NewConnectionEvent(connected bool, err error) *ConnectionEvent

NewConnectionEvent returns a new ConnectionEvent

type ConnectionReg

type ConnectionReg struct {
	Eventch chan<- *ConnectionEvent
}

ConnectionReg is a connection registration

type DisconnectEvent

type DisconnectEvent struct {
	Errch chan<- error
}

DisconnectEvent is a request to disconnect to the server

func NewDisconnectEvent

func NewDisconnectEvent(errch chan<- error) *DisconnectEvent

NewDisconnectEvent creates a new DisconnectEvent

type DisconnectedEvent

type DisconnectedEvent struct {
	Err error
}

DisconnectedEvent indicates that the client has disconnected from the server

func NewDisconnectedEvent

func NewDisconnectedEvent(err error) *DisconnectedEvent

NewDisconnectedEvent creates a new DisconnectedEvent

type Dispatcher

type Dispatcher struct {
	esdispatcher.Dispatcher
	// contains filtered or unexported fields
}

Dispatcher is responsible for handling all events, including connection and registration events originating from the client, and events originating from the event server. All events are processed in a single Go routine in order to avoid any race conditions and to ensure that events are processed in the order that they are received. This avoids the need for synchronization.

func New

func New(context context.Client, chConfig fab.ChannelCfg, connectionProvider api.ConnectionProvider, opts ...options.Opt) *Dispatcher

New creates a new dispatcher

func (*Dispatcher) ChannelConfig

func (ed *Dispatcher) ChannelConfig() fab.ChannelCfg

ChannelConfig returns the channel configuration

func (*Dispatcher) Connection

func (ed *Dispatcher) Connection() api.Connection

Connection returns the connection to the event server

func (*Dispatcher) HandleConnectEvent

func (ed *Dispatcher) HandleConnectEvent(e esdispatcher.Event)

HandleConnectEvent initiates a connection to the event server

func (*Dispatcher) HandleConnectedEvent

func (ed *Dispatcher) HandleConnectedEvent(e esdispatcher.Event)

HandleConnectedEvent sends a 'connected' event to any registered listener

func (*Dispatcher) HandleDisconnectEvent

func (ed *Dispatcher) HandleDisconnectEvent(e esdispatcher.Event)

HandleDisconnectEvent disconnects from the event server

func (*Dispatcher) HandleDisconnectedEvent

func (ed *Dispatcher) HandleDisconnectedEvent(e esdispatcher.Event)

HandleDisconnectedEvent sends a 'disconnected' event to any registered listener

func (*Dispatcher) HandleRegisterConnectionEvent

func (ed *Dispatcher) HandleRegisterConnectionEvent(e esdispatcher.Event)

HandleRegisterConnectionEvent registers a connection listener

func (*Dispatcher) HandleStopEvent

func (ed *Dispatcher) HandleStopEvent(e esdispatcher.Event)

HandleStopEvent handles a Stop event by clearing all registrations and stopping the listener

func (*Dispatcher) SetLoadBalancePolicy

func (p *Dispatcher) SetLoadBalancePolicy(value lbp.LoadBalancePolicy)

func (*Dispatcher) Start

func (ed *Dispatcher) Start() error

Start starts the dispatcher

type RegisterConnectionEvent

type RegisterConnectionEvent struct {
	esdispatcher.RegisterEvent
	Reg *ConnectionReg
}

RegisterConnectionEvent is a request to register for connection events

func NewRegisterConnectionEvent

func NewRegisterConnectionEvent(eventch chan<- *ConnectionEvent, regch chan<- fab.Registration, errch chan<- error) *RegisterConnectionEvent

NewRegisterConnectionEvent creates a new RegisterConnectionEvent

Jump to

Keyboard shortcuts

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