eventbus

package
v0.0.1-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEventBusClosed = errors.New("event bus closed")
	ErrTopicNotFound  = errors.New("topic not found")
)

Functions

func Merge

func Merge(cs ...<-chan Topic) <-chan Topic

Types

type DataChannel

type DataChannel chan DataEvent

type DataChannelSlice

type DataChannelSlice []DataChannel

type DataEvent

type DataEvent struct {
	Data  interface{}
	Topic string
}

type EventBus

type EventBus struct {
	Topics []string
	// contains filtered or unexported fields
}

func NewEventBus

func NewEventBus(topics []string) *EventBus

func (*EventBus) Close

func (eb *EventBus) Close()

func (*EventBus) Publish

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

func (*EventBus) Subscribe

func (eb *EventBus) Subscribe(topic string) DataChannel

Subscribe registra o eventbus em um tópico e retorna o canal onde as informações serão enviadas

func (*EventBus) Unsubscribe

func (eb *EventBus) Unsubscribe(topic string) error

Unsubscribe remove o tópico da lista de registrados, fecha todos os canais relacionados a esse tópico

type Topic

type Topic struct {
	Type    string      `json:"type,omitempty"`
	Payload interface{} `json:"payload,omitempty"`
}

Jump to

Keyboard shortcuts

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