event

package
v1.3.122 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Action = "_action_"
	Add    = "add"
	Del    = "del"
	Mod    = "mod"
	Notify = "notify"
)

Variables

This section is empty.

Functions

func MatchValue added in v1.3.39

func MatchValue(pattern, val string) bool

Types

type Event

type Event interface {
	ID() string
	Source() string
	Destination() string
	Header() Values
	Context() context.Context
	BindContext(ctx context.Context)
	Data() interface{}
	SetData(key string, val interface{})
	GetData(key string) interface{}
	Match(pattern string) bool
}

func NewEvent

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

func NewEventWitchContext added in v1.3.58

func NewEventWitchContext(id, source, destination string, header Values, context context.Context, 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(capacitySize int) Hub

type ID2ActionChanelMap added in v1.3.40

type ID2ActionChanelMap map[string]actionChannel

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)
}

type ObserverFunc

type ObserverFunc func(Event, Result)

type ObserverList

type ObserverList []Observer

type Result

type Result interface {
	Error() *cd.Result
	Set(data interface{}, err *cd.Result)
	Get() (interface{}, *cd.Result)
	SetVal(key string, val interface{})
	GetVal(key string) interface{}
}

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