event

package
v0.0.0-...-284234c Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

README

Event interface

It's important to be able to track events at the platform level to know what's changing where. With hundreds of services it can be difficult to track or find a way to enforce this across services. By tracking platform events we can essentially build a platform event correlation system.

Interface

type Event interface {
	// publish an event record
	Publish(*Record) error
	// subscribe to an event types
	Subscribe(Handler, ...string) error
	// used for internal purposes
	Start() error
	Stop() error
}

type Record struct {
	Id        string
	Type      string
	Origin    string
	Timestamp int64
	RootId    string
	Metadata  map[string]string
	Data      string
}

type Handler func(*Record)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RecordTopic      = "micro.event.record"
	DefaultEventType = "event"
)

Functions

func NewContext

func NewContext(ctx context.Context, c Event) context.Context

Types

type Event

type Event interface {
	// publish an event record
	Publish(context.Context, *Record) error
	// subscribe to an event types
	Subscribe(context.Context, Handler, ...string) error
	// used for internal purposes
	Start() error
	Stop() error
	// Name
	String() string
}

func FromContext

func FromContext(ctx context.Context) (Event, bool)

func NewEvent

func NewEvent(opts ...Option) Event

type Handler

type Handler func(*Record)

type Option

type Option func(o *Options)

type Options

type Options struct {
	Client client.Client

	// Alternate options
	Context context.Context
}

type Record

type Record struct {
	Id        string
	Type      string
	Origin    string
	Timestamp int64
	RootId    string
	Metadata  map[string]string
	Data      string
}

Directories

Path Synopsis
Package go_micro_platform_event is a generated protocol buffer package.
Package go_micro_platform_event is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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