events

package
v1.0.0-alpha0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2017 License: Apache-2.0, CC-BY-SA-4.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventVersion = "v1"
)

Variables

View Source
var (
	G = GetPoster
)

Functions

func RegisterCompactor

func RegisterCompactor(topic string, compactor interface{})

RegisterCompactor sets the compacter for the given topic.

func WithPoster

func WithPoster(ctx context.Context, poster Poster) context.Context

func WithTopic

func WithTopic(ctx context.Context, topic string) context.Context

WithTopic returns a context with a new topic set, such that events emitted from the resulting context will be marked with the topic.

A topic groups events by the target module they operate on. This is primarily designed to support multi-module log compaction of events. In typical journaling systems, the entries operate on a single data structure. When compacting the journal, we can replace all former log entries with a summary data structure that will result in the same state.

By providing a compaction mechanism by topic, we can prune down to a data structure oriented towards a single topic, leaving unrelated messages alone.

func WithTx

func WithTx(pctx context.Context) (ctx context.Context, commit func(), rollback func(err error))

WithTx returns a new context with an event transaction, such that events posted to the underlying context will be committed to the event log as a group, organized by a transaction id, when commit is called.

Types

type Emitter

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

func NewEmitter

func NewEmitter() *Emitter

func (*Emitter) Events

func (e *Emitter) Events(ctx context.Context, clientID string) chan *events.Envelope

func (*Emitter) Post

func (e *Emitter) Post(ctx context.Context, evt Event) error

func (*Emitter) Remove

func (e *Emitter) Remove(clientID string)

type Event

type Event interface{}

type Poster

type Poster interface {
	Post(ctx context.Context, evt Event) error
}

Poster posts the event.

func GetPoster

func GetPoster(ctx context.Context) Poster

Jump to

Keyboard shortcuts

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