Documentation
¶
Overview ¶
Package pubsub is used for events publishing and subscribing for them.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event interface { // Name returns event name. Name() string // Data returns event payload. Data() []byte }
Event is something that happens (sorry for the tautology).
func NewAllRequestsDeletedEvent ¶
func NewAllRequestsDeletedEvent() Event
NewAllRequestsDeletedEvent creates an event, that means "all requests was deleted".
func NewRequestDeletedEvent ¶
NewRequestDeletedEvent creates an event, that means "request with passed ID was deleted".
func NewRequestRegisteredEvent ¶
NewRequestRegisteredEvent creates an event, that means "new request with passed ID was registered".
type InMemory ¶
type InMemory struct {
// contains filtered or unexported fields
}
InMemory publisher/subscriber uses memory for events publishing and delivering to the subscribers. Useful for application "single node" mode running or unit testing.
Publishing/subscribing events order is NOT guaranteed.
Node: Do not forget to Close it after all. Closed publisher/subscriber cannot be opened back.
func NewInMemory ¶
func NewInMemory() *InMemory
NewInMemory creates new inmemory publisher/subscriber.
func (*InMemory) Publish ¶
Publish an event into passed channel. Publishing is non-blocking operation.
type Publisher ¶
type Publisher interface { // Publish an event into passed channel. Publish(channelName string, event Event) error }
Publisher allows to publish Event*s.
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis publisher/subscriber uses redis server for events publishing and delivering to the subscribers. Useful for application "distributed" mode running.
Publishing/subscribing events order and delivering (in cases then there is no one active subscriber for the channel) is NOT guaranteed.
Node: Do not forget to Close it after all. Closed publisher/subscriber cannot be opened back.
type Subscriber ¶
type Subscriber interface { // Subscribe to the named channel and receive Event's into the passed channel. // // Keep in mind - passed channel (chan) must be created on the caller side and channels without active readers // (or closed too early) can block application working (or break it at all). // // Also do not forget to Unsubscribe from the channel. Subscribe(channelName string, channel chan<- Event) error // Unsubscribe the subscription to the named channel for the passed events channel. Unsubscribe(channelName string, channel chan Event) error }
Subscriber allows to Subscribe and Unsubscribe for Event*s.