eventbus

package
v0.0.0-...-cbdeaad Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventCoinsPricesFetched    = "coins_prices_fetched"
	EventFoundUnexistingSymbol = "found_unexisting_symbol"
	SendNotification           = "send_notification"
	SaveBalance                = "save_balance"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bus

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

func NewEventBus

func NewEventBus() *Bus

func (*Bus) Notify

func (b *Bus) Notify(event Event)

func (*Bus) Subscribe

func (b *Bus) Subscribe(events ...string) *Subscription

type Event

type Event struct {
	Name    string
	Payload interface{}
}

func FoundUnexistingSymbol

func FoundUnexistingSymbol(symbol string) Event

func GenerateEvent

func GenerateEvent(eventName string, payload interface{}) Event

type EventHandler

type EventHandler func(context.Context, Event)

type Subscription

type Subscription struct {
	EventsCh         chan Event
	EventsSubscribed map[string]bool
	// contains filtered or unexported fields
}

func (*Subscription) Close

func (s *Subscription) Close()

func (*Subscription) Handler

func (s *Subscription) Handler(ctx context.Context, handler EventHandler)

If events is not provided, will be all events for this subscription

Jump to

Keyboard shortcuts

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