Documentation ¶
Index ¶
- Constants
- Variables
- type Awaiter
- type Counter
- type Counters
- type Frame
- type ID
- type Message
- type Ssid
- type Subscriber
- type SubscriberType
- type Subscribers
- func (s *Subscribers) AddRange(from Subscribers, filter func(s Subscriber) bool)
- func (s *Subscribers) AddUnique(value Subscriber) bool
- func (s *Subscribers) Contains(value Subscriber) (ok bool)
- func (s *Subscribers) Random(rnd uint32) (v Subscriber)
- func (s *Subscribers) Remove(value Subscriber) bool
- func (s *Subscribers) Reset()
- func (s *Subscribers) Size() int
- type Subscription
- type Trie
Constants ¶
const ( SubscriberDirect = SubscriberType(iota) SubscriberRemote SubscriberOffline )
Subscriber types
const RetainedTTL = math.MaxUint32
RetainedTTL represents a TTL value to use for retained messages (max TTL).
Variables ¶
var Query = Ssid{system, query}
Query represents a constant SSID for a query.
Functions ¶
This section is empty.
Types ¶
type Counters ¶
Counters represents a subscription counting map.
type Frame ¶
type Frame []Message
Frame represents a message frame which is sent through the wire to the remote server and contains a set of messages.
func DecodeFrame ¶
DecodeFrame decodes the message frame from the decoder.
type ID ¶
type ID []byte
ID represents a message ID encoded at 128bit and lexigraphically sortable
type Message ¶
type Message struct { ID ID `json:"id,omitempty"` // The ID of the message Channel []byte `json:"chan,omitempty"` // The channel of the message Payload []byte `json:"data,omitempty"` // The payload of the message TTL uint32 `json:"ttl,omitempty"` // The time-to-live of the message }
Message represents a message which has to be forwarded or stored.
func DecodeMessage ¶
DecodeMessage decodes the message from the decoder.
func (*Message) GetBinaryCodec ¶
GetBinaryCodec retrieves a custom binary codec.
type Ssid ¶
type Ssid []uint32
Ssid represents a subscription ID which contains a contract and a list of hashes for various parts of the channel.
func NewSsidForPresence ¶
NewSsidForPresence creates a new SSID for presence.
func NewSsidForShare ¶
NewSsidForShare creates a new SSID for shared subscriptions.
func (Ssid) GetHashCode ¶
GetHashCode combines the SSID into a single hash.
type Subscriber ¶
type Subscriber interface { ID() string Type() SubscriberType Send(*Message) error }
Subscriber is a value associated with a subscription.
type Subscribers ¶
type Subscribers map[uint32]Subscriber
Subscribers represents a subscriber set which can contain only unique values.
func (*Subscribers) AddRange ¶
func (s *Subscribers) AddRange(from Subscribers, filter func(s Subscriber) bool)
AddRange adds multiple subscribers from an existing list of subscribers, with filter applied.
func (*Subscribers) AddUnique ¶
func (s *Subscribers) AddUnique(value Subscriber) bool
AddUnique adds a subscriber to the set.
func (*Subscribers) Contains ¶
func (s *Subscribers) Contains(value Subscriber) (ok bool)
Contains checks whether a subscriber is in the set.
func (*Subscribers) Random ¶
func (s *Subscribers) Random(rnd uint32) (v Subscriber)
Random picks a random subscriber from the map. The 'rnd' argument must be a 32-bit randomly generated unsigned integer in range of [0, math.MaxUint32).
func (*Subscribers) Remove ¶
func (s *Subscribers) Remove(value Subscriber) bool
Remove removes a subscriber from the set.
func (*Subscribers) Size ¶
func (s *Subscribers) Size() int
Size returns the size of the subscriber list.
type Subscription ¶
type Subscription struct { Ssid Ssid // Gets or sets the SSID (parsed channel) for this subscription. Subscriber Subscriber // Gets or sets the subscriber for this subscription. }
Subscription represents a topic subscription.
type Trie ¶
Trie represents an efficient collection of subscriptions with lookup capability.
func NewTrie ¶
func NewTrie() *Trie
NewTrie creates a new subscriptions matcher using standard emitter strategy.
func NewTrieMQTT ¶
func NewTrieMQTT() *Trie
NewTrieMQTT creates a new subscriptions matcher using standard MQTT strategy.
func (*Trie) Lookup ¶
func (t *Trie) Lookup(ssid Ssid, filter func(s Subscriber) bool) (subs Subscribers)
Lookup returns the Subscribers for the given topic.
func (*Trie) Subscribe ¶
func (t *Trie) Subscribe(ssid Ssid, sub Subscriber) *Subscription
Subscribe adds the Subscriber to the topic and returns a Subscription.
func (*Trie) Unsubscribe ¶
func (t *Trie) Unsubscribe(ssid Ssid, subscriber Subscriber)
Unsubscribe removes the Subscription.