Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bus ¶
type Bus interface { // Topics returns the current registered topicsMap. Topics() []Descriptor // Length returns the number of subscribed topicsMap. Length() int // Subscribe a certain consumer to a single or a group of topicsMap. Subscribe(Consumer, ...Descriptor) error // SubscribeToAll topicsMap. SubscribeToAll(Consumer) error // Unsubscribe removes a consumer for a group of topicsMap. Unsubscribe(Consumer, ...Descriptor) error // Unregister removes all consumers for the specified topicsMap. Unregister(...Descriptor) error // contains filtered or unexported methods }
Bus implements publish/subscribe pattern: https://en.wikipedia.org/wiki/Publish%E2%80%93subscribe_pattern
func NewBus ¶
func NewBus(eventStore EventStore, logger Logger, errorQueue ErrorQueue, bufferSize int) Bus
NewBus creates new Bus
type Consumer ¶
type Consumer interface { fmt.GoStringer fmt.Stringer // MatchCriteria returns a match criteria callback. MatchCriteria() Match // Drop puts the message in the receiver mail box. Drop(Descriptor) // ReadMessage reads a message from the receiver mail box. ReadMessage() Descriptor // OnSubscribe called on new subscription. OnSubscribe(Descriptor, Notification) // OnUnsubscribe called on subscription cancellation. OnUnsubscribe(Descriptor, Notification) // Signout closes the mailbox. Signout() // contains filtered or unexported methods }
Consumer interface defines consumers operations.
type ConsumerCollection ¶
type ConsumerCollection interface { // Append a consumer to the ConsumerCollection. Append(...Consumer) // Delete a consumer from the ConsumerCollection. Delete(...Consumer) // Length returns the length of the ConsumerCollection. Length() int // Exists check if consumers do exist in the ConsumerCollection. Exists(Consumer) bool // Iterator iterates over the consumers in a ConsumerCollection. Iterator() <-chan Consumer }
ConsumerCollection defines consumers collection operations.
type Descriptor ¶
type Descriptor interface { fmt.GoStringer fmt.Stringer // Name returns the topic category. Name() Category // contains filtered or unexported methods }
Descriptor is the interface that a topic must implement.
func NewDescriptor ¶
func NewDescriptor(category Category, payload Payload, version Version) Descriptor
NewDescriptor returns a new topic descriptor.
type Dispatcher ¶
type Dispatcher interface {
// contains filtered or unexported methods
}
Dispatcher is responsible for dispatching topics.
func NewDispatcher ¶
func NewDispatcher(eventStore EventStore, logger Logger, errorQueue ErrorQueue, bufferSize int) Dispatcher
NewDispatcher creates a new Dispatcher.
type ErrorQueue ¶
type ErrorQueue interface {
Report(error)
}
ErrorQueue interface for error reporting.
type EventStore ¶
type EventStore interface { Load(UUID) (ConsumerCollection, bool) Store(Descriptor, ...Consumer) bool DeleteTopic(...Descriptor) Length() int Remove(Descriptor, ...Consumer) bool IsSubscribed(Descriptor, Consumer) bool Topics() []Descriptor }
EventStore for the topicsMap.
type Inbox ¶
type Inbox interface { Receive(Descriptor) Read() Descriptor Signout() }
Inbox interface for consumers to receive messages on.
type Notification ¶
type Notification func(Descriptor, Consumer)
Notification callback when a subscription on topic happens (e.g. OnSubscribe, On.Unsubscribe).
type Serializer ¶
type Serializer interface {
// contains filtered or unexported methods
}
Serializer interface