Documentation
¶
Overview ¶
Package bus implements a message bus which is a common data model and a messaging infrastructure to allow different modules to communicate locally or remotely.
Index ¶
- Variables
- type Broadcaster
- type Bus
- type Future
- type Message
- func NewBatchMessageWithNode(id MessageID, node string, data interface{}) Message
- func NewMessage(id MessageID, data interface{}) Message
- func NewMessageWithNode(id MessageID, node string, data interface{}) Message
- func NewMessageWithNodeSelectors(id MessageID, nodeSelectors map[string][]string, timeRange *modelv1.TimeRange, ...) Message
- type MessageID
- type MessageListener
- type Publisher
- type Subscriber
- type Topic
- type UnImplementedHealthyListener
Constants ¶
This section is empty.
Variables ¶
var ( // ErrTopicNotExist hints the topic published doesn't exist. ErrTopicNotExist = errors.New("the topic does not exist") )
Functions ¶
This section is empty.
Types ¶
type Broadcaster ¶ added in v0.5.0
type Broadcaster interface {
Broadcast(timeout time.Duration, topic Topic, message Message) ([]Future, error)
}
Broadcaster allow sending Messages to a Topic and receiving the responses.
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
The Bus allows publish-subscribe-style communication between components.
func (*Bus) Close ¶ added in v0.3.0
func (b *Bus) Close()
Close a Bus until all Messages are sent to Subscribers.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message is send on the bus to all subscribed listeners.
func NewBatchMessageWithNode ¶ added in v0.6.0
NewBatchMessageWithNode returns a new Message with a MessageID and NodeID and embed data.
func NewMessage ¶
NewMessage returns a new Message with a MessageID and embed data.
func NewMessageWithNode ¶ added in v0.5.0
NewMessageWithNode returns a new Message with a MessageID and NodeID and embed data.
func NewMessageWithNodeSelectors ¶ added in v0.8.0
func NewMessageWithNodeSelectors(id MessageID, nodeSelectors map[string][]string, timeRange *modelv1.TimeRange, data interface{}) Message
NewMessageWithNodeSelectors returns a new Message with a MessageID and NodeSelectors and embed data. Nodes matching any of the selectors will receive the message.
func (Message) BatchModeEnabled ¶ added in v0.6.0
BatchModeEnabled returns whether the Message is sent in batch mode.
func (Message) Data ¶
func (m Message) Data() interface{}
Data returns the data wrapped in the Message.
func (Message) NodeSelectors ¶ added in v0.8.0
NodeSelectors returns the node selectors of the Message.
type MessageListener ¶
type MessageListener interface {
Rev(ctx context.Context, message Message) Message
CheckHealth() *common.Error
}
MessageListener is the signature of functions that can handle an EventMessage.
type Publisher ¶
type Publisher interface {
Publish(ctx context.Context, topic Topic, message ...Message) (Future, error)
}
Publisher allow sending Messages to a Topic.
type Subscriber ¶
type Subscriber interface {
Subscribe(topic Topic, listener MessageListener) error
}
Subscriber allow subscribing a Topic's messages.
type Topic ¶
type Topic struct {
// contains filtered or unexported fields
}
Topic is the object which messages are sent to or received from.
type UnImplementedHealthyListener ¶ added in v0.8.0
type UnImplementedHealthyListener struct{}
UnImplementedHealthyListener is a listener that is not implemented. But it is healthy.
func (*UnImplementedHealthyListener) CheckHealth ¶ added in v0.8.0
func (h *UnImplementedHealthyListener) CheckHealth() *common.Error
CheckHealth always returns nil.