event

package
v1.0.0-...-3fe6b38 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

type Bus interface {
	Consumer
	Producer
}

Bus connects event Consumer and Producer.

type Consumer

type Consumer interface {
	Consume(buf []Event, ctx context.Context) error
}

type ErrConsumeFailed

type ErrConsumeFailed struct {
	Reason error
}

Bus connected consumer failed to consume events

func (ErrConsumeFailed) Error

func (e ErrConsumeFailed) Error() string

type ErrProduceFailed

type ErrProduceFailed struct {
	Reason error
}

Bus connected provider failed to provide events

func (ErrProduceFailed) Error

func (e ErrProduceFailed) Error() string

type Event

type Event struct {
	Target   string        `json:"target"`
	Category EventCategory `json:"category"`
	Name     string        `json:"name"`
	Time     time.Time     `json:"time"`
	Data     interface{}   `json:"data,omitempty"`
}

func (*Event) Conforms

func (e *Event) Conforms(target, name string) bool

type EventCategory

type EventCategory string
const (
	CategorySystem EventCategory = "system"
	CategoryModel  EventCategory = "model"
	CategoryEvent  EventCategory = "event"
)

Event categories

func (EventCategory) IsCustom

func (ec EventCategory) IsCustom() bool

Test if the event category is custom

func (EventCategory) IsEvent

func (ec EventCategory) IsEvent() bool

Test if the event category is event

func (EventCategory) IsModel

func (ec EventCategory) IsModel() bool

Test if the event category is model

func (EventCategory) IsSystem

func (ec EventCategory) IsSystem() bool

Test if the event category is system

type Listener

type Listener interface {
	Listen(buf []Event)
}

type Producer

type Producer interface {
	Produce(buf []Event, ctx context.Context) (n int, err error)
}

Jump to

Keyboard shortcuts

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