dispatcher

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 14 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

func WithPeerMonitorPeriod

func WithPeerMonitorPeriod(value time.Duration) options.Opt

WithPeerMonitorPeriod is the period with which the connected peer is monitored to see whether or not it should be disconnected.

func WithPeerResolver

func WithPeerResolver(value peerresolver.Provider) options.Opt

WithPeerResolver sets the peer resolver that chooses the peer from a discovered list of peers.

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       DisconnectedError
}

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 DisconnectedError) *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 DisconnectedError

type DisconnectedError interface {
	error

	// IsFatal returns true if the error is fatal, meaning that a reconnect attempt would not succeed
	IsFatal() bool
}

DisconnectedError is the error that is associated with the disconnect.

type DisconnectedEvent

type DisconnectedEvent struct {
	Err DisconnectedError
}

DisconnectedEvent indicates that the client has disconnected from the server

func NewDisconnectedEvent

func NewDisconnectedEvent(cause error) *DisconnectedEvent

NewDisconnectedEvent creates a new DisconnectedEvent

func NewFatalDisconnectedEvent

func NewFatalDisconnectedEvent(cause error) *DisconnectedEvent

NewFatalDisconnectedEvent creates a new DisconnectedEvent which indicates that a reconnect is not possible

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, discoveryService fab.DiscoveryService, 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) ConnectedPeer

func (ed *Dispatcher) ConnectedPeer() fab.Peer

ConnectedPeer returns the connected peer

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) SetPeerMonitorPeriod

func (p *Dispatcher) SetPeerMonitorPeriod(value time.Duration)

func (*Dispatcher) SetPeerResolver

func (p *Dispatcher) SetPeerResolver(value peerresolver.Provider)

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