event

package
v0.0.0-...-376a440 Latest Latest
Warning

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

Go to latest
Published: May 10, 2020 License: LGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const EventChSize = 100

EventChSize is the size of subscriber's read channel.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collector

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

Collector is the struct for posting event.

func GetCollector

func GetCollector() *Collector

GetCollector returns single-instance event collector.

func (*Collector) Post

func (ec *Collector) Post(e *Event, meta *Meta)

Post a event.

func (*Collector) Subscribe

func (ec *Collector) Subscribe(id int64, topics []Topic, filter *Meta) <-chan *Event

Subscribe registers a subscription in event collector.

func (*Collector) Unsubscribe

func (ec *Collector) Unsubscribe(id int64, topics []Topic)

Unsubscribe deregisters a subscription from event collector.

type Event

type Event struct {
	Topic Topic
	Data  string
	Time  int64
}

Event is the struct sent to subscriber.

func NewEvent

func NewEvent(topic Topic, data string) *Event

NewEvent generate new event with topic and data

type Meta

type Meta struct {
	ContractID string
}

Meta is the information abount event.

func (*Meta) Match

func (m *Meta) Match(meta *Meta) bool

Match checks whether the given meta argument is matched to self.

type Subscription

type Subscription struct {
	C chan<- *Event
	// contains filtered or unexported fields
}

Subscription is a struct used for listening specific topics

type Topic

type Topic int

Topic defines different event topics.

const (
	ContractReceipt Topic = iota
	ContractEvent
)

event topics

func (Topic) String

func (t Topic) String() string

Jump to

Keyboard shortcuts

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