Documentation
¶
Overview ¶
Package pubsub provides the needed primitives for a Publish-Subscribe system
Package pubsub provides the needed primitives for a Publish-Subscribe system
Index ¶
- func IsNoSuchTopicError(e error) bool
- func IsNotImplementedError(e error) bool
- type ErrType
- type Event
- type EventType
- type InMemory
- func (im *InMemory) CreateTopic(topic string) error
- func (im *InMemory) DeleteTopic(topic string) error
- func (im *InMemory) Publish(topic string, ev *Event) error
- func (im *InMemory) Subscribe(topic string) (*Subscription, error)
- func (im *InMemory) TopicExists(topic string) bool
- func (im *InMemory) UnSubscribe(topic string, sID string) error
- type Kind
- type NoSuchTopicError
- type NotImplementedError
- type PubSub
- type Subscription
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNoSuchTopicError ¶
func IsNotImplementedError ¶
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event data structure
func NewEvent ¶
NewEvent returns a pointer to Event type kind EventType, the kind of Event configPath string, the config path
type InMemory ¶
InMemory is the data structure implementing the PubSub interface
func (*InMemory) CreateTopic ¶
CreateTopic creates a new topic from string
func (*InMemory) DeleteTopic ¶
DeleteTopic deletes a given topic
func (*InMemory) Subscribe ¶
func (im *InMemory) Subscribe(topic string) (*Subscription, error)
Subscribe adds a new subscription to a topic, returns the newly created Subscription object, or NoSuchTopicError if the topic is not created yet
func (*InMemory) TopicExists ¶
TopicExists checks whether or not a topic exists
type Kind ¶
type Kind string
Kind is the KV kind
const INMEMORY Kind = "in-memory"
INMEMORY is an in-memory PubSub implementation
func PubSubFromName ¶
PubSubFromName returns the PubSub Kind from the provided name It will return a NotImplementedError otherwise
type NoSuchTopicError ¶
type NoSuchTopicError struct {
// contains filtered or unexported fields
}
func NewNoSuchTopicError ¶
func NewNoSuchTopicError(topic string) NoSuchTopicError
func (NoSuchTopicError) Error ¶
func (e NoSuchTopicError) Error() string
type NotImplementedError ¶
type NotImplementedError struct {
// contains filtered or unexported fields
}
func NewNotImplementedError ¶
func NewNotImplementedError(impl string) NotImplementedError
func (NotImplementedError) Error ¶
func (e NotImplementedError) Error() string
type PubSub ¶
type PubSub interface {
CreateTopic(topic string) error
DeleteTopic(topic string) error
TopicExists(topic string) bool
Publish(topic string, ev *Event) error
Subscribe(topic string) (*Subscription, error)
UnSubscribe(topic string, sID string) error
}
PubSub provides an API for a Publish-Subscribe system
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
Subscription type
func NewSubscription ¶
func NewSubscription() *Subscription
NewSubscription creates a new Subscription
func (*Subscription) Channel ¶
func (s *Subscription) Channel() chan *Event
Channel returns the subscription channel