event

package
v0.0.0-...-2efaa0c Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

README

Event GoDoc

A pluggable interface for platform event publishing and subscription.

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.

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

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

func NewEvent(opts ...Option) Event {
	return newOS(opts...)
}

Supported Backends

Documentation

Overview

Package event is an interface for event sourcing.

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
	// 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_os_event is a generated protocol buffer package.
Package go_micro_os_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