...

Package dispatcher

import "github.com/hyperledger/fabric-sdk-go/pkg/fab/events/client/dispatcher"
Overview
Index

Overview ▾

Index ▾

func WithLoadBalancePolicy(value lbp.LoadBalancePolicy) options.Opt
func WithPeerMonitorPeriod(value time.Duration) options.Opt
func WithPeerResolver(value peerresolver.Provider) options.Opt
type ConnectEvent
    func NewConnectEvent(errch chan<- error) *ConnectEvent
type ConnectedEvent
    func NewConnectedEvent() *ConnectedEvent
type ConnectionEvent
    func NewConnectionEvent(connected bool, err DisconnectedError) *ConnectionEvent
type ConnectionReg
type DisconnectEvent
    func NewDisconnectEvent(errch chan<- error) *DisconnectEvent
type DisconnectedError
type DisconnectedEvent
    func NewDisconnectedEvent(cause error) *DisconnectedEvent
    func NewFatalDisconnectedEvent(cause error) *DisconnectedEvent
type Dispatcher
    func New(context context.Client, chConfig fab.ChannelCfg, discoveryService fab.DiscoveryService, connectionProvider api.ConnectionProvider, opts ...options.Opt) *Dispatcher
    func (ed *Dispatcher) ChannelConfig() fab.ChannelCfg
    func (ed *Dispatcher) ConnectedPeer() fab.Peer
    func (ed *Dispatcher) Connection() api.Connection
    func (ed *Dispatcher) HandleConnectEvent(e esdispatcher.Event)
    func (ed *Dispatcher) HandleConnectedEvent(e esdispatcher.Event)
    func (ed *Dispatcher) HandleDisconnectEvent(e esdispatcher.Event)
    func (ed *Dispatcher) HandleDisconnectedEvent(e esdispatcher.Event)
    func (ed *Dispatcher) HandleRegisterConnectionEvent(e esdispatcher.Event)
    func (ed *Dispatcher) HandleStopEvent(e esdispatcher.Event)
    func (p *Dispatcher) SetPeerMonitorPeriod(value time.Duration)
    func (p *Dispatcher) SetPeerResolver(value peerresolver.Provider)
    func (ed *Dispatcher) Start() error
type RegisterConnectionEvent
    func NewRegisterConnectionEvent(eventch chan<- *ConnectionEvent, regch chan<- fab.Registration, errch chan<- error) *RegisterConnectionEvent

Package files

dispatcher.go events.go opts.go registrations.go

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.

type ConnectEvent

ConnectEvent is a request to connect to the server

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

func NewConnectEvent

func NewConnectEvent(errch chan<- error) *ConnectEvent

NewConnectEvent creates a new ConnectEvent

type ConnectedEvent

ConnectedEvent indicates that the client has connected to the server

type ConnectedEvent struct {
}

func NewConnectedEvent

func NewConnectedEvent() *ConnectedEvent

NewConnectedEvent creates a new ConnectedEvent

type ConnectionEvent

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

func NewConnectionEvent(connected bool, err DisconnectedError) *ConnectionEvent

NewConnectionEvent returns a new ConnectionEvent

type ConnectionReg

ConnectionReg is a connection registration

type ConnectionReg struct {
    Eventch chan<- *ConnectionEvent
}

type DisconnectEvent

DisconnectEvent is a request to disconnect to the server

type DisconnectEvent struct {
    Errch chan<- error
}

func NewDisconnectEvent

func NewDisconnectEvent(errch chan<- error) *DisconnectEvent

NewDisconnectEvent creates a new DisconnectEvent

type DisconnectedError

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
}

type DisconnectedEvent

DisconnectedEvent indicates that the client has disconnected from the server

type DisconnectedEvent struct {
    Err DisconnectedError
}

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

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

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

RegisterConnectionEvent is a request to register for connection events

type RegisterConnectionEvent struct {
    esdispatcher.RegisterEvent
    Reg *ConnectionReg
}

func NewRegisterConnectionEvent

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

NewRegisterConnectionEvent creates a new RegisterConnectionEvent