fabric-sdk-go: github.com/hyperledger/fabric-sdk-go/pkg/fab/events/service/dispatcher Index | Files

package dispatcher

import "github.com/hyperledger/fabric-sdk-go/pkg/fab/events/service/dispatcher"

Index

Package Files

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

func NewBlockEvent Uses

func NewBlockEvent(block *cb.Block, sourceURL string) *fab.BlockEvent

NewBlockEvent creates a new BlockEvent

func NewChaincodeEvent Uses

func NewChaincodeEvent(chaincodeID, eventName, txID string, payload []byte, blockNum uint64, sourceURL string) *fab.CCEvent

NewChaincodeEvent creates a new ChaincodeEvent

func NewFilteredBlockEvent Uses

func NewFilteredBlockEvent(fblock *pb.FilteredBlock, sourceURL string) *fab.FilteredBlockEvent

NewFilteredBlockEvent creates a new FilteredBlockEvent

func NewTxStatusEvent Uses

func NewTxStatusEvent(txID string, txValidationCode pb.TxValidationCode, blockNum uint64, sourceURL string) *fab.TxStatusEvent

NewTxStatusEvent creates a new TxStatusEvent

func WithEventConsumerBufferSize Uses

func WithEventConsumerBufferSize(value uint) options.Opt

WithEventConsumerBufferSize sets the size of the registered consumer's event channel.

func WithEventConsumerTimeout Uses

func WithEventConsumerTimeout(value time.Duration) options.Opt

WithEventConsumerTimeout is the timeout when sending events to a registered consumer. If < 0, if buffer full, unblocks immediately and does not send. If 0, if buffer full, will block and guarantee the event will be sent out. If > 0, if buffer full, blocks util timeout.

func WithSnapshot Uses

func WithSnapshot(value fab.EventSnapshot) options.Opt

WithSnapshot sets the given TxStatus registrations.

type BlockReg Uses

type BlockReg struct {
    Filter  fab.BlockFilter
    Eventch chan<- *fab.BlockEvent
}

BlockReg contains the data for a block registration

type ChaincodeReg Uses

type ChaincodeReg struct {
    ChaincodeID string
    EventFilter string
    EventRegExp *regexp.Regexp
    Eventch     chan<- *fab.CCEvent
}

ChaincodeReg contains the data for a chaincode registration

type Dispatcher Uses

type Dispatcher struct {
    // 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 channel event service. 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 in which they are received. This also avoids the need for synchronization. The lastBlockNum member MUST be first to ensure it stays 64-bit aligned on 32-bit machines.

func New Uses

func New(opts ...options.Opt) *Dispatcher

New creates a new Dispatcher.

func (*Dispatcher) EventCh Uses

func (ed *Dispatcher) EventCh() (chan<- interface{}, error)

EventCh returns the channel to which events may be posted

func (*Dispatcher) HandleBlock Uses

func (ed *Dispatcher) HandleBlock(block *cb.Block, sourceURL string)

HandleBlock handles a block event

func (*Dispatcher) HandleFilteredBlock Uses

func (ed *Dispatcher) HandleFilteredBlock(fblock *pb.FilteredBlock, sourceURL string)

HandleFilteredBlock handles a filtered block event

func (*Dispatcher) HandleStopAndTransferEvent Uses

func (ed *Dispatcher) HandleStopAndTransferEvent(e Event)

HandleStopAndTransferEvent stops the dispatcher and transfers all event registrations into a EventSnapshot. The Dispatcher is no longer usable.

func (*Dispatcher) HandleStopEvent Uses

func (ed *Dispatcher) HandleStopEvent(e Event)

HandleStopEvent stops the dispatcher and unregisters all event registration. The Dispatcher is no longer usable.

func (*Dispatcher) HandleTransferEvent Uses

func (ed *Dispatcher) HandleTransferEvent(e Event)

HandleTransferEvent transfers all event registrations into a EventSnapshot.

func (*Dispatcher) LastBlockNum Uses

func (ed *Dispatcher) LastBlockNum() uint64

LastBlockNum returns the block number of the last block for which an event was received.

func (*Dispatcher) RegisterHandler Uses

func (ed *Dispatcher) RegisterHandler(t interface{}, h Handler)

RegisterHandler registers an event handler

func (*Dispatcher) RegisterHandlers Uses

func (ed *Dispatcher) RegisterHandlers()

RegisterHandlers registers all of the handlers by event type

func (*Dispatcher) SetEventConsumerBufferSize Uses

func (p *Dispatcher) SetEventConsumerBufferSize(value uint)

func (*Dispatcher) SetEventConsumerTimeout Uses

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

func (*Dispatcher) SetSnapshot Uses

func (p *Dispatcher) SetSnapshot(value fab.EventSnapshot) error

func (*Dispatcher) Start Uses

func (ed *Dispatcher) Start() error

Start starts dispatching events as they arrive. All events are processed in a single Go routine in order to avoid any race conditions

func (*Dispatcher) UpdateLastBlockInfoOnly Uses

func (ed *Dispatcher) UpdateLastBlockInfoOnly()

UpdateLastBlockInfoOnly sets is next event should only be used for updating last block info.

type Event Uses

type Event interface{}

Event is an event that's sent to the dispatcher. This includes client registration requests or events that come from an event producer.

type FilteredBlockReg Uses

type FilteredBlockReg struct {
    Eventch chan<- *fab.FilteredBlockEvent
}

FilteredBlockReg contains the data for a filtered block registration

type Handler Uses

type Handler func(Event)

Handler is the handler for a given event type.

type HandlerRegistry Uses

type HandlerRegistry map[reflect.Type]Handler

HandlerRegistry contains the handlers for each type of event

type RegisterBlockEvent Uses

type RegisterBlockEvent struct {
    RegisterEvent
    Reg *BlockReg
}

RegisterBlockEvent registers for block events

func NewRegisterBlockEvent Uses

func NewRegisterBlockEvent(filter fab.BlockFilter, eventch chan<- *fab.BlockEvent, respch chan<- fab.Registration, errCh chan<- error) *RegisterBlockEvent

NewRegisterBlockEvent creates a new RegisterBlockEvent

type RegisterChaincodeEvent Uses

type RegisterChaincodeEvent struct {
    RegisterEvent
    Reg *ChaincodeReg
}

RegisterChaincodeEvent registers for chaincode events

func NewRegisterChaincodeEvent Uses

func NewRegisterChaincodeEvent(ccID, eventFilter string, eventch chan<- *fab.CCEvent, respch chan<- fab.Registration, errCh chan<- error) *RegisterChaincodeEvent

NewRegisterChaincodeEvent creates a new RegisterChaincodeEvent

type RegisterEvent Uses

type RegisterEvent struct {
    RegCh chan<- fab.Registration
    ErrCh chan<- error
}

RegisterEvent is the base for all registration events.

func NewRegisterEvent Uses

func NewRegisterEvent(respch chan<- fab.Registration, errCh chan<- error) RegisterEvent

NewRegisterEvent creates a new RgisterEvent

type RegisterFilteredBlockEvent Uses

type RegisterFilteredBlockEvent struct {
    RegisterEvent
    Reg *FilteredBlockReg
}

RegisterFilteredBlockEvent registers for filtered block events

func NewRegisterFilteredBlockEvent Uses

func NewRegisterFilteredBlockEvent(eventch chan<- *fab.FilteredBlockEvent, respch chan<- fab.Registration, errCh chan<- error) *RegisterFilteredBlockEvent

NewRegisterFilteredBlockEvent creates a new RegisterFilterBlockEvent

type RegisterTxStatusEvent Uses

type RegisterTxStatusEvent struct {
    RegisterEvent
    Reg *TxStatusReg
}

RegisterTxStatusEvent registers for transaction status events

func NewRegisterTxStatusEvent Uses

func NewRegisterTxStatusEvent(txID string, eventch chan<- *fab.TxStatusEvent, respch chan<- fab.Registration, errCh chan<- error) *RegisterTxStatusEvent

NewRegisterTxStatusEvent creates a new RegisterTxStatusEvent

type RegistrationInfo Uses

type RegistrationInfo struct {
    TotalRegistrations            int
    NumBlockRegistrations         int
    NumFilteredBlockRegistrations int
    NumCCRegistrations            int
    NumTxStatusRegistrations      int
}

RegistrationInfo contains counts of the current event registrations

type RegistrationInfoEvent Uses

type RegistrationInfoEvent struct {
    RegInfoCh chan<- *RegistrationInfo
}

RegistrationInfoEvent requests registration information

func NewRegistrationInfoEvent Uses

func NewRegistrationInfoEvent(regInfoCh chan<- *RegistrationInfo) *RegistrationInfoEvent

NewRegistrationInfoEvent returns a new RegistrationInfoEvent

type StopAndTransferEvent Uses

type StopAndTransferEvent struct {
    SnapshotCh chan<- fab.EventSnapshot
    ErrCh      chan<- error
}

StopAndTransferEvent tells the dispatcher to stop processing and transfer all registrations into a snapshot

func NewStopAndTransferEvent Uses

func NewStopAndTransferEvent(snapshotch chan<- fab.EventSnapshot, errch chan<- error) *StopAndTransferEvent

NewStopAndTransferEvent creates a new StopAndTransferEvent

type StopEvent Uses

type StopEvent struct {
    ErrCh chan<- error
}

StopEvent tells the dispatcher to stop processing

func NewStopEvent Uses

func NewStopEvent(errch chan<- error) *StopEvent

NewStopEvent creates a new StopEvent

type TransferEvent Uses

type TransferEvent struct {
    SnapshotCh chan<- fab.EventSnapshot
    ErrCh      chan<- error
}

TransferEvent tells the dispatcher to transfer all registrations into a snapshot

func NewTransferEvent Uses

func NewTransferEvent(snapshotch chan<- fab.EventSnapshot, errch chan<- error) *TransferEvent

NewTransferEvent creates a new TransferEvent

type TxStatusReg Uses

type TxStatusReg struct {
    TxID    string
    Eventch chan<- *fab.TxStatusEvent
}

TxStatusReg contains the data for a transaction status registration

type UnregisterEvent Uses

type UnregisterEvent struct {
    Reg fab.Registration
}

UnregisterEvent unregisters a registration

func NewUnregisterEvent Uses

func NewUnregisterEvent(reg fab.Registration) *UnregisterEvent

NewUnregisterEvent creates a new UnregisterEvent

Package dispatcher imports 15 packages (graph) and is imported by 5 packages. Updated 2019-08-30. Refresh now. Tools for package owners.