eventbus

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyLocked = errors.New("already locked")
)

Functions

This section is empty.

Types

type EventBus

type EventBus interface {
	// Subscribe subscribe event
	Subscribe(topic string, handler interface{}) error

	// UnSubscribe unsubscribe event
	UnSubscribe(topic string, handler interface{}) error

	// Publish publish event
	Publish(topic string, data interface{}) error

	// TryLock try lock, if lock success return nil
	TryLock(key string) error

	// UnLock unLock
	UnLock(key string) error
}

func GetEventBus

func GetEventBus() EventBus

func NewEventBus

func NewEventBus(cfg *config.Config) EventBus

type MemoryEventBus

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

func NewMemoryEventBus

func NewMemoryEventBus() *MemoryEventBus

func (*MemoryEventBus) Publish

func (eb *MemoryEventBus) Publish(topic string, data interface{}) error

func (*MemoryEventBus) Subscribe

func (eb *MemoryEventBus) Subscribe(topic string, handler interface{}) error

func (*MemoryEventBus) TryLock

func (eb *MemoryEventBus) TryLock(key string) error

func (*MemoryEventBus) UnLock

func (eb *MemoryEventBus) UnLock(key string) error

func (*MemoryEventBus) UnSubscribe

func (eb *MemoryEventBus) UnSubscribe(topic string, handler interface{}) error

Jump to

Keyboard shortcuts

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