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(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(value peerresolver.Provider) options.Opt
WithPeerResolver sets the peer resolver that chooses the peer from a discovered list of peers.
ConnectEvent is a request to connect to the server
type ConnectEvent struct { ErrCh chan<- error FromBlockNum uint64 }
func NewConnectEvent(errch chan<- error) *ConnectEvent
NewConnectEvent creates a new ConnectEvent
ConnectedEvent indicates that the client has connected to the server
type ConnectedEvent struct { }
func NewConnectedEvent() *ConnectedEvent
NewConnectedEvent creates a new ConnectedEvent
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.
type ConnectionEvent struct { Connected bool Err DisconnectedError }
func NewConnectionEvent(connected bool, err DisconnectedError) *ConnectionEvent
NewConnectionEvent returns a new ConnectionEvent
ConnectionReg is a connection registration
type ConnectionReg struct { Eventch chan<- *ConnectionEvent }
DisconnectEvent is a request to disconnect to the server
type DisconnectEvent struct { Errch chan<- error }
func NewDisconnectEvent(errch chan<- error) *DisconnectEvent
NewDisconnectEvent creates a new DisconnectEvent
DisconnectedError is the error that is associated with the disconnect.
type DisconnectedError interface { error // IsFatal returns true if the error is fatal, meaning that a reconnect attempt would not succeed IsFatal() bool }
DisconnectedEvent indicates that the client has disconnected from the server
type DisconnectedEvent struct { Err DisconnectedError }
func NewDisconnectedEvent(cause error) *DisconnectedEvent
NewDisconnectedEvent creates a new DisconnectedEvent
func NewFatalDisconnectedEvent(cause error) *DisconnectedEvent
NewFatalDisconnectedEvent creates a new DisconnectedEvent which indicates that a reconnect is not possible
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.
type Dispatcher struct { *esdispatcher.Dispatcher // contains filtered or unexported fields }
func New(context context.Client, chConfig fab.ChannelCfg, discoveryService fab.DiscoveryService, connectionProvider api.ConnectionProvider, opts ...options.Opt) *Dispatcher
New creates a new dispatcher
func (ed *Dispatcher) ChannelConfig() fab.ChannelCfg
ChannelConfig returns the channel configuration
func (ed *Dispatcher) ConnectedPeer() fab.Peer
ConnectedPeer returns the connected peer
func (ed *Dispatcher) Connection() api.Connection
Connection returns the connection to the event server
func (ed *Dispatcher) HandleConnectEvent(e esdispatcher.Event)
HandleConnectEvent initiates a connection to the event server
func (ed *Dispatcher) HandleConnectedEvent(e esdispatcher.Event)
HandleConnectedEvent sends a 'connected' event to any registered listener
func (ed *Dispatcher) HandleDisconnectEvent(e esdispatcher.Event)
HandleDisconnectEvent disconnects from the event server
func (ed *Dispatcher) HandleDisconnectedEvent(e esdispatcher.Event)
HandleDisconnectedEvent sends a 'disconnected' event to any registered listener
func (ed *Dispatcher) HandleRegisterConnectionEvent(e esdispatcher.Event)
HandleRegisterConnectionEvent registers a connection listener
func (ed *Dispatcher) HandleStopEvent(e esdispatcher.Event)
HandleStopEvent handles a Stop event by clearing all registrations and stopping the listener
func (p *Dispatcher) SetPeerMonitorPeriod(value time.Duration)
func (p *Dispatcher) SetPeerResolver(value peerresolver.Provider)
func (ed *Dispatcher) Start() error
Start starts the dispatcher
RegisterConnectionEvent is a request to register for connection events
type RegisterConnectionEvent struct { esdispatcher.RegisterEvent Reg *ConnectionReg }
func NewRegisterConnectionEvent(eventch chan<- *ConnectionEvent, regch chan<- fab.Registration, errch chan<- error) *RegisterConnectionEvent
NewRegisterConnectionEvent creates a new RegisterConnectionEvent