events

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection added in v0.0.2

type Collection []Event

Collection of events.

func (Collection) Await added in v0.0.2

func (c Collection) Await() error

Await all events or error.

func (Collection) Complete added in v0.0.2

func (c Collection) Complete()

Complete these events.

func (Collection) Fail added in v0.0.2

func (c Collection) Fail(err error)

Fail these events.

type Distributor

type Distributor interface {
	Enqueue(Event) error // Enqueue a new event.
}

Distributor will queue an event for distribution, taking care of the messy details.

type Event

type Event interface {
	GetMessageID() string            // GetMessageID returns the message identifier.
	GetHeaders() map[string][]string // GetHeaders returns HTTP compatible headers.
	GetURI() string                  // GetURI returns a HTTP like route.
	GetContent() []byte              // GetContent returns the []byte content of the message.

	Fail(error)
	Complete()
	Await() error
}

Event is the most abstract description of the message passing.

type EventMsg

type EventMsg struct {
	ID      string              `json:"id"`
	Headers map[string][]string `json:"headers"`
	URI     string              `json:"uri"`
	Content []byte              `json:"content"`

	FailFunc     *func(error) `json:"-"`
	CompleteFunc *func()      `json:"-"`
}

EventMsg is the underlying Event.

func FromJSON

func FromJSON(payload string) (EventMsg, error)

FromJSON will load an EventMsg from JSON string.

func FromJSONb

func FromJSONb(payload []byte) (EventMsg, error)

FromJSONb will load an EventMsg from JSON []Byte.

func JunkEvent

func JunkEvent() EventMsg

JunkEvent generates a junk event.

func (EventMsg) Await

func (e EventMsg) Await() error

Await will wait

func (EventMsg) Complete

func (e EventMsg) Complete()

Complete indicates that the given event has successfully been compelted.

func (EventMsg) Fail

func (e EventMsg) Fail(err error)

Fail indicates that the given event has failed.

func (EventMsg) GetContent

func (e EventMsg) GetContent() []byte

GetContent returns the []byte content of the message.

func (EventMsg) GetHeaders

func (e EventMsg) GetHeaders() map[string][]string

GetHeaders returns HTTP compatible headers.

func (EventMsg) GetMessageID

func (e EventMsg) GetMessageID() string

GetMessageID returns the message identifier.

func (EventMsg) GetURI

func (e EventMsg) GetURI() string

GetURI returns a HTTP like route.

func (EventMsg) ToJSON

func (e EventMsg) ToJSON() (string, error)

ToJSON will convert an EventMsg to JSON.

func (EventMsg) ToJSONb

func (e EventMsg) ToJSONb() ([]byte, error)

ToJSONb will convert an EventMsg to JSON []Byte.

Jump to

Keyboard shortcuts

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