bus

package
v1.22.20 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Zlib Imports: 3 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 struct {
	// contains filtered or unexported fields
}

func New

func New() *Bus

func (*Bus) Publish

func (bus *Bus) Publish(topic string, ev Event)

func (*Bus) PublishArgs added in v1.5.8

func (bus *Bus) PublishArgs(topic string, args ...interface{})

func (*Bus) Start added in v0.7.5

func (bus *Bus) Start() error

func (*Bus) Stop added in v0.7.5

func (bus *Bus) Stop()

func (*Bus) Subscribe

func (bus *Bus) Subscribe(topic string, ch interface{}) error

func (*Bus) SubscribeAsync added in v1.5.8

func (bus *Bus) SubscribeAsync(topic string, fn interface{}, transactional bool) error

func (*Bus) SubscribeEventChan added in v1.5.8

func (bus *Bus) SubscribeEventChan(topic string, ch EventChan) error

func (*Bus) SubscribeOnce added in v1.5.8

func (bus *Bus) SubscribeOnce(topic string, fn interface{}) error

SubscribeOnce subscribes to a topic once. Handler will be removed after executing. Returns error if `fn` is not a function.

func (*Bus) SubscribeOnceAsync added in v1.5.8

func (bus *Bus) SubscribeOnceAsync(topic string, fn interface{}) error

SubscribeOnceAsync subscribes to a topic once with an asynchronous callback Async determines whether subsequent Publish should wait for callback return Handler will be removed after executing. Returns error if `fn` is not a function.

func (*Bus) UnSubscribe

func (bus *Bus) UnSubscribe(topic string, ch interface{})

func (*Bus) Wait added in v1.9.2

func (bus *Bus) Wait()

type Event

type Event struct {
	Cmd  string
	Data interface{}
}

type EventChan

type EventChan chan Event

type Publisher

type Publisher interface {
	Publish(topic string, ev Event)
	PublishArgs(topic string, args ...interface{})
}

type Subscriber

type Subscriber interface {
	SubscribeEventChan(topic string, ch EventChan) error
	Subscribe(topic string, ch interface{}) error
	SubscribeAsync(topic string, ch interface{}, transactional bool) error
	SubscribeOnce(topic string, ch interface{}) error
	SubscribeOnceAsync(topic string, ch interface{}) error
	UnSubscribe(topic string, ch interface{})
}

Subscriber ch is func or chan.(EventChan)

Jump to

Keyboard shortcuts

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