events

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	fab.ProviderContext
	fab.IdentityContext
}

Context holds the providers and services needed to create an EventHub.

type EventHub

type EventHub struct {
	// contains filtered or unexported fields
}

EventHub allows a client to listen to event at a peer.

func FromConfig

func FromConfig(ctx Context, peerCfg *apiconfig.PeerConfig) (*EventHub, error)

FromConfig creates new event hub from context and peer config.

func New

func New(ctx Context) (*EventHub, error)

New creates an EventHub from context.

func (*EventHub) Connect

func (eventHub *EventHub) Connect() error

Connect establishes connection with peer event source

func (*EventHub) Disconnect

func (eventHub *EventHub) Disconnect() error

Disconnect disconnects from peer event source

func (*EventHub) Disconnected

func (eventHub *EventHub) Disconnected(err error)

Disconnected implements consumer.EventAdapter interface for receiving events

func (*EventHub) GetInterestedEvents

func (eventHub *EventHub) GetInterestedEvents() ([]*pb.Interest, error)

GetInterestedEvents implements consumer.EventAdapter interface for registering interested events

func (*EventHub) IsConnected

func (eventHub *EventHub) IsConnected() bool

IsConnected gets connected state of eventhub Returns true if connected to event source, false otherwise

func (*EventHub) Recv

func (eventHub *EventHub) Recv(msg *pb.Event) (bool, error)

Recv implements consumer.EventAdapter interface for receiving events

func (*EventHub) RegisterBlockEvent

func (eventHub *EventHub) RegisterBlockEvent(callback func(*common.Block))

RegisterBlockEvent - register callback function for block events

func (*EventHub) RegisterChaincodeEvent

func (eventHub *EventHub) RegisterChaincodeEvent(ccid string, eventname string, callback func(*fab.ChaincodeEvent)) *fab.ChainCodeCBE

RegisterChaincodeEvent registers a callback function to receive chaincode events. ccid: chaincode id eventname: The regex string used to filter events callback: Callback function for filter matches that takes a single parameter which is a json object representation

of type "message ChaincodeEvent"

Returns ChainCodeCBE object that should be treated as an opaque handle used to unregister (see unregisterChaincodeEvent)

func (*EventHub) RegisterTxEvent

func (eventHub *EventHub) RegisterTxEvent(txnID fab.TransactionID, callback func(string, pb.TxValidationCode, error))

RegisterTxEvent registers a callback function to receive transactional events. txid: transaction id callback: Function that takes a single parameter which is a json object representation of type "message Transaction"

func (*EventHub) SetInterests

func (eventHub *EventHub) SetInterests(block bool)

SetInterests clears all interests and sets the interests for BLOCK type of events.

func (*EventHub) SetPeerAddr

func (eventHub *EventHub) SetPeerAddr(peerURL string, peerTLSCertificate *sm2.Certificate, peerTLSServerHostOverride string)

SetPeerAddr set peer url for event source peeraddr peer url peerTLSCertificate peer tls certificate peerTLSServerHostOverride tls serverhostoverride

func (*EventHub) UnregisterBlockEvent

func (eventHub *EventHub) UnregisterBlockEvent(callback func(*common.Block))

UnregisterBlockEvent unregister callback for block event

func (*EventHub) UnregisterChaincodeEvent

func (eventHub *EventHub) UnregisterChaincodeEvent(cbe *fab.ChainCodeCBE)

UnregisterChaincodeEvent unregisters chaincode event registration ChainCodeCBE: handle returned from call to registerChaincodeEvent.

func (*EventHub) UnregisterTxEvent

func (eventHub *EventHub) UnregisterTxEvent(txnID fab.TransactionID)

UnregisterTxEvent unregister transactional event registration. txid: transaction id

type MockCCBlockEventBuilder

type MockCCBlockEventBuilder struct {
	CCID      string
	EventName string
	ChannelID string
	TxID      string
	Payload   []byte
}

MockCCBlockEventBuilder builds a mock CC event block

func (*MockCCBlockEventBuilder) Build

Build builds a mock chaincode event block

func (*MockCCBlockEventBuilder) BuildWithTxValidationFlag

func (b *MockCCBlockEventBuilder) BuildWithTxValidationFlag(isValid bool) *pb.Event_Block

BuildWithTxValidationFlag builds a mock chaincode event block with valid/invalid TxValidation Flag (set in the argument)

type MockCCEventBuilder

type MockCCEventBuilder struct {
	CCID      string
	EventName string
	Payload   []byte
}

MockCCEventBuilder builds a mock chaincode event

func (*MockCCEventBuilder) Build

Build builds a mock chaincode event

type MockTxEventBuilder

type MockTxEventBuilder struct {
	ChannelID string
	TxID      string
}

MockTxEventBuilder builds a mock TX event block

func (*MockTxEventBuilder) Build

func (b *MockTxEventBuilder) Build() *pb.Event_Block

Build builds a mock TX event block

func (*MockTxEventBuilder) BuildWithTxValidationCode

func (b *MockTxEventBuilder) BuildWithTxValidationCode(c pb.TxValidationCode) *pb.Event_Block

BuildWithTxValidationCode Build builds a mock TX event block

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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