Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithBufferSize ¶
func WithBufferSize(s int) option
WithBufferSize is used to set the buffer size of each queue each subscriber gets a channel that its listening on without a high enough buffer size the channel will stall
func WithWorkers ¶
func WithWorkers(w int) option
WithWorkers sets the amount of workers that will be used
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus is the main structure used to keep track of all subscribers
func (*Bus) Subscribe ¶
func (b *Bus) Subscribe(e EventType, h EventHandler)
Subscribe adds a handler to listen for a specific event type
type Event ¶
type Event struct { Type EventType Data interface{} }
Event is the main type that gets sent thr9ough the bus it is up to the callers to validate the data when received
type EventHandler ¶
type EventHandler interface { // This function will be called when an event is received // that the handler is subscribed to Handle(ctx context.Context, e *Event) // On Shutfown of the bus all Stop functyions will be called // NOTE: Stop should be idempotent as it will be called once per // subscribed event. so if a handler is subscribed to more than one event it // will be called multiple times Stop(ctx context.Context) }
EventHandler is an interface that callers can use to make use of the bus
Click to show internal directories.
Click to hide internal directories.