Documentation
¶
Index ¶
- Constants
- Variables
- type Event
- func (event *Event) Bytes() ([]byte, error)
- func (event *Event) FromAny(any *types.Any) *Event
- func (event Event) Init() *Event
- func (event *Event) Now() *Event
- func (event *Event) ReceivedNow() *Event
- func (event *Event) WithData(data interface{}) (*Event, error)
- func (event *Event) WithDataMust(data interface{}) *Event
- func (event *Event) WithError(err error) *Event
- func (event *Event) WithTopic(s string) *Event
- func (event *Event) WithType(s string) *Event
- type Plugin
- type Publisher
- type Subscriber
- type Type
- type Validator
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) ReceivedNow ¶
ReceivedNow marks the receipt timestamp with now
func (*Event) WithDataMust ¶
WithDataMust does what WithData does but will panic on error
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
Click to show internal directories.
Click to hide internal directories.