events

package
v0.0.0-...-fe81f67 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bucket

type Bucket struct {
	Rule      rules.Rule `json:"rule"`
	Events    []*Event   `json:"events"`
	FlushLock bool       `json:"flush_lock"`
	UpdatedAt time.Time  `json:"updated_at"`
	CreatedAt time.Time  `json:"created_at"`
	// contains filtered or unexported fields
}

Bucket contains the rule for a collection of events and the events

func NewBucket

func NewBucket(rule rules.Rule) *Bucket

NewBucket creates a new Bucket

func (*Bucket) AddEvent

func (rb *Bucket) AddEvent(event *Event)

AddEvent to the bucket

func (*Bucket) CanFlush

func (rb *Bucket) CanFlush() bool

CanFlush returns if the bucket can be evicted from the db

func (*Bucket) CanFlushIn

func (rb *Bucket) CanFlushIn() time.Duration

CanFlushIn returns time left for flush

func (*Bucket) DecodeMsg

func (z *Bucket) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Bucket) EncodeMsg

func (z *Bucket) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Bucket) MarshalMsg

func (z *Bucket) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Bucket) Msgsize

func (z *Bucket) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Bucket) Post

func (rb *Bucket) Post() error

Post posts rulebucket to the configured hook endpoint

func (*Bucket) UnmarshalMsg

func (z *Bucket) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

type Event

type Event struct {
	// Type of occurrence which has happened. Often this property is
	// used for routing, observability, policy enforcement, etc.
	// REQUIRED.
	EventType string `json:"eventType"`

	// The version of the eventType. This enables the interpretation of
	// data by eventual consumers, requires the consumer to be knowledgeable
	// about the producer.
	// OPTIONAL.
	EventTypeVersion string `json:"eventTypeVersion,omitempty"`

	// The version of the CloudEvents specification which the event
	// uses. This enables the interpretation of the context.
	// REQUIRED.
	CloudEventsVersion string `json:"cloudEventsVersion"`

	// This describes the event producer. Often this will include information
	// such as the type of the event source, the organization publishing the
	// event, and some unique idenfitiers. The exact syntax and semantics behind
	// the data encoded in the URI is event producer defined.
	// REQUIRED.
	Source string `json:"source"`

	// ID of the event. The semantics of this string are explicitly undefined to
	// ease the implementation of producers. Enables deduplication.
	// REQUIRED.
	EventID string `json:"eventID"`

	// Timestamp of when the event happened. RFC3339.
	// OPTIONAL.
	EventTime time.Time `json:"eventTime,omitempty"`

	// A link to the schema that the data attribute adheres to. RFC3986.
	// OPTIONAL.
	SchemaURL string `json:"schemaURL,omitempty"`

	// Describe the data encoding format. RFC2046.
	// OPTIONAL.
	ContentType string `json:"contentType,omitempty"`

	// This is for additional metadata and this does not have a mandated
	// structure. This enables a place for custom fields a producer or middleware
	// might want to include and provides a place to test metadata before adding
	// them to the CloudEvents specification. See the Extensions document for a
	// list of possible properties.
	// OPTIONAL. This is a map, but an 'interface{}' for flexibility.
	Extensions interface{} `json:"extensions,omitempty"`

	// The event payload. The payload depends on the eventType, schemaURL and
	// eventTypeVersion, the payload is encoded into a media format which is
	// specified by the contentType attribute (e.g. application/json).
	//
	// If the contentType value is "application/json", or any media type with a
	// structured +json suffix, the implementation MUST translate the data attribute
	// value into a JSON value, and set the data member of the envelope JSON object
	// to this JSON value.
	// OPTIONAL.
	Data interface{} `json:"data,omitempty"`
	// contains filtered or unexported fields
}

Event wraps cloudevent.CloudEvent

func (*Event) DecodeMsg

func (z *Event) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (*Event) EncodeMsg

func (z *Event) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (*Event) Hash

func (e *Event) Hash() []byte

Hash returns md5 hash string of the type

func (*Event) MarshalMsg

func (z *Event) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (*Event) Msgsize

func (z *Event) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Event) UnmarshalMsg

func (z *Event) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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