Documentation
¶
Index ¶
- type Manager
- func (m *Manager) AddServerPeer(uuid string, url string, headers map[string]string, ...) error
- func (m *Manager) AddTopic(uuid string, topic string) error
- func (m *Manager) DeletePeer(uuid string) error
- func (m *Manager) FanOut(data interface{}, attributes map[string]string) error
- func (m *Manager) FanOutSubscribers(data interface{}, attributes map[string]string, topic string) error
- func (m *Manager) Forward(peerUUID string, message Message) error
- func (m *Manager) GetPeerIP(uuid string) (string, error)
- func (m *Manager) GetTopics(uuid string) ([]string, error)
- func (m *Manager) PeerExists(uuid string) bool
- func (m *Manager) RemoveTopic(uuid string, topic string) error
- func (m *Manager) Send(peerUUID string, data interface{}, attributes map[string]string) error
- func (m *Manager) SetPeerStickyAttributes(peerUUID string, attributes map[string]string) error
- func (m *Manager) SetTopics(uuid string, topics []string) error
- func (m *Manager) Start() error
- type Message
- type Peer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct { UUID string API_Port int // Port to listen on API_Path string // Path to listen on eg: /poll API_Middleware *gin.HandlerFunc // Middleware to run before each request PollLength time.Duration // Time before a poll should be refreshed PeerExpiry time.Duration // Time before a peer is considered expired/offline Deadline time.Duration // Time before a poll times out OutboundBufferSize int // Size of outbound message buffers UpCallback *func(peerUUID string) // Function to call when a peer comes online DownCallback *func(peerUUID string) // Function to call when a peer goes offline ReceiveCallback *func(peerUUID string, msg Message) // Function to call when receiving a message // contains filtered or unexported fields }
func NewDefaultManager ¶
func NewDefaultManager() *Manager
NewDefaultManager Creates a new LongPoll Manager with default settings
func (*Manager) AddServerPeer ¶
func (m *Manager) AddServerPeer(uuid string, url string, headers map[string]string, stickyAttributes map[string]string) error
AddServerPeer Adds a server peer to the LongPoll Manager
func (*Manager) DeletePeer ¶
DeletePeer Deletes a peer from the LongPoll Manager
func (*Manager) FanOutSubscribers ¶
func (m *Manager) FanOutSubscribers(data interface{}, attributes map[string]string, topic string) error
FanOutSubscribers Sends a message to all peers subscribed to a given topic
func (*Manager) PeerExists ¶
PeerExists Checks if a peer exists. This function locks peersMU!
func (*Manager) RemoveTopic ¶
RemoveTopic Removes a topic from a peer
func (*Manager) SetPeerStickyAttributes ¶ added in v0.1.1
SetPeerStickyAttributes Sets the sticky attributes of a peer
type Peer ¶ added in v0.1.1
type Peer struct { UUID string // Unique identifier for this peer Ch chan Message // Buffered channel for outgoing messages to client peers LastConsumed time.Time // Last time this client peer consumed a message Topics []string // Topics this peer is subscribed to (see FanOutSubscribers()) StickyAttrbitues map[string]string // Attributes to be appended to every outgoing message // Specific to server peers IsServer bool ServerURL string // URL of server running longpoll API Headers map[string]string // Headers to be applied to outgoing requests Online bool // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.