mediator

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatch

func Dispatch(ev Event)

func SetDefault

func SetDefault(m Mediator)

func Subscribe

func Subscribe(hdl EventHandler)

Types

type Event

type Event interface {
	Kind() EventKind
}

Event 事件接口.

type EventCollection

type EventCollection interface {
	Add(Event)
	Raise(Mediator)
}

func NewEventCollection

func NewEventCollection() EventCollection

type EventHandler

type EventHandler interface {
	Listening() []EventKind
	Handle(context.Context, Event)
}

type EventKind

type EventKind string

EventKind 事件类型描述.

type InMemMediator

type InMemMediator struct {
	// contains filtered or unexported fields
}

func (*InMemMediator) Dispatch

func (m *InMemMediator) Dispatch(ev Event)

func (*InMemMediator) Subscribe

func (m *InMemMediator) Subscribe(hdl EventHandler)

func (*InMemMediator) WithOrphanEventHandler

func (m *InMemMediator) WithOrphanEventHandler(fn func(Event))

type Mediator

type Mediator interface {
	Dispatch(Event)
	Subscribe(EventHandler)
}

func Default

func Default() Mediator

func NewInMemMediator

func NewInMemMediator(opt Options) (Mediator, error)

type Options

type Options struct {
	Timeout    string `json:"timeout" yaml:"timeout" toml:"timeout"`
	Concurrent int    `json:"concurrent" yaml:"concurrent" toml:"concurrent"`
}

Jump to

Keyboard shortcuts

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