Documentation ¶
Index ¶
Constants ¶
const ( SubscriberDirect = SubscriberType(iota) SubscriberRemote )
Subscriber types
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 Message ¶
type Message struct { Time int64 `json:"ts,omitempty"` // The timestamp of the message Ssid Ssid `json:"ssid,omitempty"` // The Ssid 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.
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 (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 []Subscriber
Subscribers represents a subscriber set which can contain only unique values.
func (*Subscribers) AddUnique ¶
func (s *Subscribers) AddUnique(value Subscriber)
AddUnique adds a subscriber to the set.
func (*Subscribers) Contains ¶
func (s *Subscribers) Contains(value Subscriber) bool
Contains checks whether a subscriber is in the set.
func (*Subscribers) Remove ¶
func (s *Subscribers) Remove(value Subscriber)
Remove removes a subscriber from the set.
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 (*Trie) Lookup ¶
func (t *Trie) Lookup(query Ssid) (subs Subscribers)
Lookup returns the Subscribers for the given topic.
func (*Trie) Subscribe ¶
func (t *Trie) Subscribe(ssid Ssid, sub Subscriber) (*Subscription, error)
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.