subscriber

package
v0.0.0-...-bda353b Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventSubscriber

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

EventSubscriber - new EventSubscriber struct

func NewSubscriber

func NewSubscriber(msgBus msgbus.MessageBus) *EventSubscriber

NewSubscriber - new and register msgbus.BlockInfo object

func (*EventSubscriber) OnMessage

func (s *EventSubscriber) OnMessage(msg *msgbus.Message)

OnMessage - deal msgbus.BlockInfo message

func (*EventSubscriber) OnQuit

func (s *EventSubscriber) OnQuit()

OnQuit - deal msgbus OnQuit message

func (*EventSubscriber) SubscribeBlockEvent

func (s *EventSubscriber) SubscribeBlockEvent(ch chan<- model.NewBlockEvent) Subscription

SubscribeBlockEvent - subscribe block event

func (*EventSubscriber) SubscribeContractEvent

func (s *EventSubscriber) SubscribeContractEvent(ch chan<- model.NewContractEvent) Subscription

SubscribeContractEvent - subscribe contract event

type Feed

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

Feed implements one-to-many subscriptions where the carrier of events is a channel. Values sent to a Feed are delivered to all subscribed channels simultaneously.

Feeds can only be used with a single type. The type is determined by the first Send or Subscribe operation. Subsequent calls to these methods panic if the type does not match.

The zero value is ready to use.

func (*Feed) Send

func (f *Feed) Send(value interface{}) (nsent int)

Send delivers to all subscribed channels simultaneously. It returns the number of subscribers that the value was sent to.

func (*Feed) Subscribe

func (f *Feed) Subscribe(channel interface{}) Subscription

Subscribe adds a channel to the feed. Future sends will be delivered on the channel until the subscription is canceled. All channels added must have the same element type.

The channel should have ample buffer space to avoid blocking other subscribers. Slow subscribers are not dropped.

type Subscription

type Subscription interface {
	Err() <-chan error // returns the error channel
	Unsubscribe()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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