event

package
v0.4.2-0...-ae8ecb7 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypeError is the type to use for sending errors in the transport of the events.
	TypeError = Type("error")
)

Variables

View Source
var InterfaceSpec = spi.InterfaceSpec{
	Name:    "Event",
	Version: "0.1.1",
}

InterfaceSpec is the current name and version of the Flavor API.

Functions

This section is empty.

Types

type Event

type Event struct {

	// Topic is the topic to which this event is published
	Topic types.Path

	// Type of the event. This is usually used as a hint to what struct types to use to unmarshal data
	Type Type `json:",omitempty"`

	// ID is unique id for the event.
	ID string

	// Timestamp is the time.UnixNano() value -- this is the timestamp when event occurred
	Timestamp time.Time

	// Received is the timestamp when the message is received.
	Received time.Time `json:",omitempty"`

	// Data contains some application specific payload
	Data *types.Any `json:",omitempty"`

	// Error contains any errors that occurred during delivery of the mesasge
	Error error `json:",omitempty"`
}

Event holds information about when, what, etc.

func (*Event) Bytes

func (event *Event) Bytes() ([]byte, error)

Bytes returns the bytes representation

func (*Event) FromAny

func (event *Event) FromAny(any *types.Any) *Event

FromAny sets the fields of this Event from the contents of Any

func (Event) Init

func (event Event) Init() *Event

Init creates an instance with the value initialized to the state of receiver.

func (*Event) Now

func (event *Event) Now() *Event

Now sets the timestamp of this event to now.

func (*Event) ReceivedNow

func (event *Event) ReceivedNow() *Event

ReceivedNow marks the receipt timestamp with now

func (*Event) WithData

func (event *Event) WithData(data interface{}) (*Event, error)

WithData converts the data into an any and sets this event's data to it.

func (*Event) WithDataMust

func (event *Event) WithDataMust(data interface{}) *Event

WithDataMust does what WithData does but will panic on error

func (*Event) WithError

func (event *Event) WithError(err error) *Event

WithError sets the error

func (*Event) WithTopic

func (event *Event) WithTopic(s string) *Event

WithTopic sets the topic from input string

func (*Event) WithType

func (event *Event) WithType(s string) *Event

WithType sets the type from a string

type Plugin

type Plugin interface {

	// List returns a list of *child nodes* given a path for a topic.
	// A topic of "." is the top level
	List(topic types.Path) (child []string, err error)
}

Plugin must be implemented for the object to be able to publish events.

type Publisher

type Publisher interface {

	// PublishOn sets the channel to publish.  Note that the implementation is given a channel
	// to publish on.  This is so that the server can optionally add buffering without the
	// implementations having any knowledge.
	PublishOn(chan<- *Event)
}

Publisher is the interface that event sources also implement to be assigned a publish function.

type Subscriber

type Subscriber interface {

	// SubscribeOn returns the channel for the topic
	SubscribeOn(topic types.Path) (<-chan *Event, chan<- struct{}, error)
}

Subscriber is the interface given to clients interested in events

type Type

type Type string

Type is the type of an event. This gives hint about what struct types to map to, etc. It also marks one instance of an event as of different nature from another.

type Validator

type Validator interface {

	// Validate validates the topic
	Validate(topic types.Path) error
}

Validator is the interface for validating the topic

Jump to

Keyboard shortcuts

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