Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultEvent ¶
func NewDefaultEvent ¶
func NewDefaultEvent(topic string, producer string) DefaultEvent
func (*DefaultEvent) GetProducer ¶
func (e *DefaultEvent) GetProducer() string
func (*DefaultEvent) GetTopic ¶
func (e *DefaultEvent) GetTopic() string
type Eventbus ¶ added in v0.0.2
type Eventbus interface { // Register registers the event to the topic Register(topic string, subscribers ...*Subscriber) error // Post posts the event to the topic Post(ctx context.Context, event Event) error // Serve starts the event bus async Serve(ctx context.Context) }
Eventbus is the interface for event bus
func NewEventbus ¶
NewEventbus creates the event bus
type Subscriber ¶
type Subscriber struct { // UID UID func() string // NewEvent is a function that creates a new event from a message. NewEvent func() Event // HandleEvent handles the event HandleEvent func(ctx context.Context, event Event) error }
Subscriber is the interface for subscriber
type Subscribers ¶ added in v0.0.2
Subscribers is the list of subscribers
func (*Subscribers) Add ¶ added in v0.0.2
func (s *Subscribers) Add(sub *Subscriber)
func (*Subscribers) Contains ¶ added in v0.0.2
func (s *Subscribers) Contains(uid string) bool
func (*Subscribers) Each ¶ added in v0.0.2
func (s *Subscribers) Each(f func(sub *Subscriber))
func (*Subscribers) Len ¶ added in v0.0.2
func (s *Subscribers) Len() int
Click to show internal directories.
Click to hide internal directories.