event

package
v2.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2018 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 added in v1.1.0

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

Collector is the struct for posting event.

func GetCollector added in v1.1.0

func GetCollector() *Collector

GetCollector returns single-instance event collector.

func (*Collector) Post added in v1.1.0

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

Post a event.

func (*Collector) Subscribe added in v1.1.0

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

Subscribe registers a subscription in event collector.

func (*Collector) Unsubscribe added in v1.1.0

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 added in v1.1.0

type Meta struct {
	ContractID string
}

Meta is the information abount event.

func (*Meta) Match added in v1.1.0

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 added in v1.1.0

type Topic int

Topic defines different event topics.

const (
	ContractReceipt Topic = iota
	ContractEvent
)

event topics

func (Topic) String added in v1.1.0

func (t Topic) String() string

Jump to

Keyboard shortcuts

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