event

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeKey   = "EventType"
	EventIDKey     = "EventID"
	MessageTypeKey = "MessageType"
	TxTypeKey      = "TxType"
	TxHashKey      = "TxHash"
	HeightKey      = "Height"
	IndexKey       = "Index"
	NameKey        = "Name"
	PermissionKey  = "Permission"
	StackDepthKey  = "StackDepth"
	AddressKey     = "Address"
	OriginKey      = "Origin"
	CalleeKey      = "Callee"
	CallerKey      = "Caller"
	ValueKey       = "Value"
	GasKey         = "Gas"
	ExceptionKey   = "Exception"
	LogNKeyPrefix  = "Log"
)
View Source
const DefaultEventBufferCapacity = 2 << 10
View Source
const SubscribeCallbackTimeout = 2 * time.Second

Variables

This section is empty.

Functions

func GenerateSubscriptionID added in v0.18.0

func GenerateSubscriptionID() (string, error)

func LogNKey added in v0.19.0

func LogNKey(topic int) string

func LogNTextKey added in v0.19.0

func LogNTextKey(topic int) string

func PublishAll added in v0.18.0

func PublishAll(ctx context.Context, subscribable Subscribable, subscriber string, queryable query.Queryable,
	publisher Publisher, extraTags map[string]interface{}) error

func QueryForEventID added in v0.18.0

func QueryForEventID(eventID string) *query.Builder

Get a query that matches events with a specific eventID

func SubscribeCallback added in v0.18.0

func SubscribeCallback(ctx context.Context, subscribable Subscribable, subscriber string, queryable query.Queryable,
	callback func(message interface{}) (stop bool)) error

Subscribe to messages matching query and launch a goroutine to run a callback for each one. The goroutine will exit if the callback returns true for 'stop' and clean up the subscription and channel.

Types

type Cache added in v0.18.0

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

A Cache buffers events for a Publisher.

func NewCache added in v0.19.0

func NewCache() *Cache

Create a new Cache with an EventSwitch as backend

func (*Cache) Flush added in v0.18.0

func (evc *Cache) Flush(publisher Publisher) error

func (*Cache) Publish added in v0.18.0

func (evc *Cache) Publish(ctx context.Context, message interface{}, tags Tags) error

Cache an event to be fired upon finality.

func (*Cache) Reset added in v0.19.0

func (evc *Cache) Reset()

func (*Cache) Sync added in v0.19.0

func (evc *Cache) Sync(publisher Publisher) error

Clears cached events by flushing them to Publisher

type CombinedTags added in v0.19.0

type CombinedTags []Tags

func (CombinedTags) Get added in v0.19.0

func (ct CombinedTags) Get(key string) (value string, ok bool)

func (CombinedTags) Keys added in v0.19.0

func (ct CombinedTags) Keys() []string

func (CombinedTags) Len added in v0.19.0

func (ct CombinedTags) Len() (length int)

func (CombinedTags) Map added in v0.19.0

func (ct CombinedTags) Map() map[string]interface{}

type Emitter added in v0.18.0

type Emitter interface {
	Subscribable
	Publisher
	process.Process
}

func NewEmitter added in v0.18.0

func NewEmitter(logger *logging.Logger) Emitter

type Indexable added in v0.19.0

type Indexable interface {
	ProvideIndex(index uint64)
}

If message implement this interface we will provide them with an index in the cache

type Publisher added in v0.18.0

type Publisher interface {
	Publish(ctx context.Context, message interface{}, tag Tags) error
}

func NewNoOpPublisher added in v0.18.0

func NewNoOpPublisher() Publisher

NoOpPublisher

type PublisherFunc added in v0.19.0

type PublisherFunc func(ctx context.Context, message interface{}, tags Tags) error

func (PublisherFunc) Publish added in v0.19.0

func (pf PublisherFunc) Publish(ctx context.Context, message interface{}, tags Tags) error

type Subscribable added in v0.18.0

type Subscribable interface {
	// Subscribe to all events matching query, which is a valid tmlibs Query. Blocking the out channel blocks the entire
	// pubsub.
	Subscribe(ctx context.Context, subscriber string, queryable query.Queryable, out chan<- interface{}) error
	// Unsubscribe subscriber from a specific query string. Note the subscribe channel must be drained.
	Unsubscribe(ctx context.Context, subscriber string, queryable query.Queryable) error
	UnsubscribeAll(ctx context.Context, subscriber string) error
}

TODO: manage the creation, closing, and draining of channels behind the interface rather than only closing. stop one subscriber from blocking everything!

type TagMap added in v0.19.0

type TagMap map[string]interface{}

func (TagMap) Get added in v0.19.0

func (ts TagMap) Get(key string) (value string, ok bool)

func (TagMap) Keys added in v0.19.0

func (ts TagMap) Keys() []string

func (TagMap) Len added in v0.19.0

func (ts TagMap) Len() int

func (TagMap) Map added in v0.19.0

func (ts TagMap) Map() map[string]interface{}

type Tags added in v0.19.0

type Tags interface {
	pubsub.TagMap
	Keys() []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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