Documentation ¶
Index ¶
Constants ¶
const AlertTopic = "hub.subscription.messageslost"
AlertTopic is used to notify when a nonblocking subscriber loose one message You can subscribe on this topic and log or send metrics.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Fields ¶
type Fields map[string]interface{}
Fields is a [key]value storage for Messages values.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub is a component that provides publish and subscribe capabilities for messages. Every message has a Name used to route them to subscribers and this can be used like RabbitMQ topics exchanges. Where every word is separated by dots `.` and you can use `*` as a wildcard.
func (*Hub) Close ¶
func (h *Hub) Close()
Close will unsubscribe all the subscriptions and close them all.
func (*Hub) NonBlockingSubscribe ¶
func (h *Hub) NonBlockingSubscribe(cap int, topics ...string) Subscription
NonBlockingSubscribe create a nonblocking subscription to receive events for a given topic. This subscriber will loose messages if the buffer reaches the max capability.
func (*Hub) Subscribe ¶
func (h *Hub) Subscribe(cap int, topics ...string) Subscription
Subscribe create a blocking subscription to receive events for a given topic. The cap param is used inside the subscriber and in this case used to create a channel. cap(1) = unbuffered channel.
func (*Hub) Unsubscribe ¶
func (h *Hub) Unsubscribe(sub Subscription)
Unsubscribe remove and close the Subscription.
type Message ¶
Message represent some message/event passed into the hub It also contain some helper functions to convert the fields to primitive types.
type Subscription ¶
type Subscription struct { Topics []string Receiver <-chan Message // contains filtered or unexported fields }
Subscription represents a topic subscription.