Documentation ¶
Overview ¶
Package event deals with subscriptions to real-time events.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMuxClosed is returned when Posting on a closed TypeMux. ErrMuxClosed = errors.New("event: mux closed") //ErrDuplicateSubscribe is returned when subscribe duplicate type ErrDuplicateSubscribe = errors.New("event: subscribe duplicate type") )
Functions ¶
This section is empty.
Types ¶
type BlockSignatureEvent ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
A Dispatcher dispatches events to registered receivers. Receivers can be registered to handle events of certain type. Any operation called after mux is stopped will return ErrMuxClosed.
The zero value is ready to use.
func NewDispatcher ¶
func NewDispatcher() *Dispatcher
func (*Dispatcher) Post ¶
func (d *Dispatcher) Post(ev interface{}) error
Post sends an event to all receivers registered for the given type. It returns ErrMuxClosed if the mux has been stopped.
func (*Dispatcher) Stop ¶
func (d *Dispatcher) Stop()
Stop closes a mux. The mux can no longer be used. Future Post calls will fail with ErrMuxClosed. Stop blocks until all current deliveries have finished.
func (*Dispatcher) Subscribe ¶
func (d *Dispatcher) Subscribe(types ...interface{}) (*Subscription, error)
Subscribe creates a subscription for events of the given types. The subscription's channel is closed when it is unsubscribed or the mux is closed.
type NewProposedBlockEvent ¶
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription is a subscription established through TypeMux.
func (*Subscription) Chan ¶
func (s *Subscription) Chan() <-chan *TypeMuxEvent
func (*Subscription) Closed ¶
func (s *Subscription) Closed() bool
func (*Subscription) Unsubscribe ¶
func (s *Subscription) Unsubscribe()
type TypeMuxEvent ¶
TypeMuxEvent is a time-tagged notification pushed to subscribers.