event

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2018 License: Apache-2.0 Imports: 16 Imported by: 46

Documentation

Index

Constants

View Source
const (
	EventIDKey     = "EventID"
	MessageTypeKey = "MessageType"
	TxTypeKey      = "TxType"
	TxHashKey      = "TxHash"
	StackDepthKey  = "StackDepth"
)
View Source
const DefaultEventBufferCapacity = 2 << 10

Variables

This section is empty.

Functions

func GenerateSubscriptionID added in v0.18.0

func GenerateSubscriptionID() (string, error)

func PublishAll added in v0.18.0

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

func PublishWithEventID added in v0.18.0

func PublishWithEventID(publisher Publisher, eventID string, eventData interface{},
	extraTags map[string]interface{}) error

func SubscribeCallback added in v0.18.0

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

Subscribe to messages matching query and launch a goroutine to run a callback for each one. The goroutine will exit when the context is done or the subscription is removed.

Types

type Cache added in v0.18.0

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

A Cache buffers events for a Publisher.

func NewEventCache added in v0.18.0

func NewEventCache(publisher Publisher) *Cache

Create a new Cache with an EventSwitch as backend

func (*Cache) Flush added in v0.18.0

func (evc *Cache) Flush() error

Clears cached events by flushing them to Publisher

func (*Cache) Publish added in v0.18.0

func (evc *Cache) Publish(ctx context.Context, message interface{}, tags map[string]interface{}) error

Cache an event to be fired upon finality.

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 Publisher added in v0.18.0

type Publisher interface {
	Publish(ctx context.Context, message interface{}, tags map[string]interface{}) error
}

func NewNoOpPublisher added in v0.18.0

func NewNoOpPublisher() Publisher

NoOpPublisher

type Query added in v0.18.0

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

A pre-parsed query

func WrapQuery added in v0.18.0

func WrapQuery(qry pubsub.Query) Query

func (Query) Query added in v0.18.0

func (q Query) Query() (pubsub.Query, error)

type QueryBuilder added in v0.18.0

type QueryBuilder struct {

	// reusable buffer for building queryString
	bytes.Buffer
	// contains filtered or unexported fields
}

A fluent query builder

func NewQueryBuilder added in v0.18.0

func NewQueryBuilder(queries ...string) *QueryBuilder

Creates a new query builder with a base query that is the conjunction of all queries passed

func QueryForEventID added in v0.18.0

func QueryForEventID(eventID string) *QueryBuilder

Get a query that matches events with a specific eventID

func (*QueryBuilder) And added in v0.18.0

func (qb *QueryBuilder) And(queryBuilders ...*QueryBuilder) *QueryBuilder

Creates the conjunction of QueryBuilder and rightQuery

func (*QueryBuilder) AndContains added in v0.18.0

func (qb *QueryBuilder) AndContains(tag string, operand interface{}) *QueryBuilder

func (*QueryBuilder) AndEquals added in v0.18.0

func (qb *QueryBuilder) AndEquals(tag string, operand interface{}) *QueryBuilder

Creates the conjunction of QueryBuilder and tag = operand

func (*QueryBuilder) AndGreaterThanOrEqual added in v0.18.0

func (qb *QueryBuilder) AndGreaterThanOrEqual(tag string, operand interface{}) *QueryBuilder

func (*QueryBuilder) AndLessThanOrEqual added in v0.18.0

func (qb *QueryBuilder) AndLessThanOrEqual(tag string, operand interface{}) *QueryBuilder

func (*QueryBuilder) AndStrictlyGreaterThan added in v0.18.0

func (qb *QueryBuilder) AndStrictlyGreaterThan(tag string, operand interface{}) *QueryBuilder

func (*QueryBuilder) AndStrictlyLessThan added in v0.18.0

func (qb *QueryBuilder) AndStrictlyLessThan(tag string, operand interface{}) *QueryBuilder

func (*QueryBuilder) Query added in v0.18.0

func (qb *QueryBuilder) Query() (pubsub.Query, error)

func (*QueryBuilder) String added in v0.18.0

func (qb *QueryBuilder) String() string

type QueryString added in v0.18.0

type QueryString string

A yet-to-parsed query

func (QueryString) Query added in v0.18.0

func (qs QueryString) Query() (pubsub.Query, error)

type Queryable added in v0.18.0

type Queryable interface {
	Query() (pubsub.Query, error)
}

func MatchAllQueryable added in v0.18.0

func MatchAllQueryable() Queryable

type Subscribable added in v0.18.0

type Subscribable interface {
	// Subscribe to all events matching query, which is a valid tmlibs Query
	Subscribe(ctx context.Context, subscriber string, query Queryable, out chan<- interface{}) error
	// Unsubscribe subscriber from a specific query string
	Unsubscribe(ctx context.Context, subscriber string, query Queryable) error
	UnsubscribeAll(ctx context.Context, subscriber string) error
}

Jump to

Keyboard shortcuts

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