event

package
v1.3.17 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 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 Event

type Event interface {
	ID() string
	Source() string
	Destination() string
	Header() Values
	Data() interface{}
	Match(pattern string) bool
}

func NewEvent

func NewEvent(id, source, destination string, header Values, data interface{}) Event

type Hub

type Hub interface {
	Subscribe(eventID string, observer Observer)
	Unsubscribe(eventID string, observer Observer)
	Post(event Event)
	Send(event Event) Result
	Call(event Event) Result
	Terminate()
}

func NewHub

func NewHub() Hub

type ID2ObserverFuncMap

type ID2ObserverFuncMap map[string]ObserverFunc

type ID2ObserverMap

type ID2ObserverMap map[string]ObserverList

type Observer

type Observer interface {
	ID() string
	Notify(event Event, result Result) bool
}

type ObserverFunc

type ObserverFunc func(Event, Result) bool

type ObserverList

type ObserverList []Observer

type Result

type Result interface {
	Error() error
	Set(data interface{}, err error)
	Get() (interface{}, error)
}

func NewResult

func NewResult(id, source, destination string) Result

type SimpleObserver

type SimpleObserver interface {
	Observer
	Subscribe(eventID string, observerFunc ObserverFunc)
	Unsubscribe(eventID string)
}

func NewSimpleObserver

func NewSimpleObserver(id string, hub Hub) SimpleObserver

type Values

type Values map[string]interface{}

func NewValues

func NewValues() Values

func (Values) Get

func (s Values) Get(key string) interface{}

func (Values) GetBool

func (s Values) GetBool(key string) bool

func (Values) GetInt

func (s Values) GetInt(key string) int

func (Values) GetString

func (s Values) GetString(key string) string

func (Values) Set

func (s Values) Set(key string, value interface{})

Jump to

Keyboard shortcuts

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