Versions in this module Expand all Collapse all v2 v2.0.4 Nov 13, 2020 Changes in this version + type PublishGeoAPICommand struct + Bearing float64 + DriverId int + Latitude float64 + Longitude float64 v2.0.3 Nov 13, 2020 v2.0.2 Nov 13, 2020 v2.0.1 Nov 13, 2020 v2.0.0 Nov 12, 2020 Changes in this version + const DefaultWebsocketMessageSizeLimit + const DefaultWebsocketPingInterval + const DefaultWebsocketWriteTimeout + const NoLimit + const UseSeqGen + var CompatibilityFlags uint64 + var DefaultConfig = Config + var DisconnectBadRequest = &Disconnect + var DisconnectConnectionLimit = &Disconnect + var DisconnectExpired = &Disconnect + var DisconnectForceNoReconnect = &Disconnect + var DisconnectForceReconnect = &Disconnect + var DisconnectInsufficientState = &Disconnect + var DisconnectInvalidToken = &Disconnect + var DisconnectNormal = &Disconnect + var DisconnectServerError = &Disconnect + var DisconnectShutdown = &Disconnect + var DisconnectSlow = &Disconnect + var DisconnectStale = &Disconnect + var DisconnectSubExpired = &Disconnect + var DisconnectWriteError = &Disconnect + var ErrorAlreadySubscribed = &Error + var ErrorBadRequest = &Error + var ErrorExpired = &Error + var ErrorInternal = &Error + var ErrorLimitExceeded = &Error + var ErrorMethodNotFound = &Error + var ErrorNotAvailable = &Error + var ErrorPermissionDenied = &Error + var ErrorTokenExpired = &Error + var ErrorTooManyRequests = &Error + var ErrorUnauthorized = &Error + var ErrorUnknownChannel = &Error + func LogLevelToString(l LogLevel) string + func NewClient(ctx context.Context, n *Node, t Transport) (*Client, ClientCloseFunc, error) + func SetCredentials(ctx context.Context, cred *Credentials) context.Context + type AliveHandler func() + type Broker interface + Channels func() ([]string, error) + History func(ch string, filter HistoryFilter) ([]*Publication, StreamPosition, error) + Publish func(ch string, data []byte, opts PublishOptions) (StreamPosition, error) + PublishControl func(data []byte) error + PublishJoin func(ch string, info *ClientInfo) error + PublishLeave func(ch string, info *ClientInfo) error + RemoveHistory func(ch string) error + Run func(BrokerEventHandler) error + Subscribe func(ch string) error + Unsubscribe func(ch string) error + type BrokerEventHandler interface + HandleControl func(data []byte) error + HandleJoin func(ch string, info *ClientInfo) error + HandleLeave func(ch string, info *ClientInfo) error + HandlePublication func(ch string, pub *Publication) error + type Client struct + func (c *Client) Channels() []string + func (c *Client) Context() context.Context + func (c *Client) Disconnect(disconnect *Disconnect) + func (c *Client) Handle(data []byte) bool + func (c *Client) ID() string + func (c *Client) IsSubscribed(ch string) bool + func (c *Client) OnAlive(h AliveHandler) + func (c *Client) OnDisconnect(h DisconnectHandler) + func (c *Client) OnHistory(h HistoryHandler) + func (c *Client) OnMessage(h MessageHandler) + func (c *Client) OnPresence(h PresenceHandler) + func (c *Client) OnPresenceStats(h PresenceStatsHandler) + func (c *Client) OnPublish(h PublishHandler) + func (c *Client) OnRPC(h RPCHandler) + func (c *Client) OnRefresh(h RefreshHandler) + func (c *Client) OnSubRefresh(h SubRefreshHandler) + func (c *Client) OnSubscribe(h SubscribeHandler) + func (c *Client) OnUnsubscribe(h UnsubscribeHandler) + func (c *Client) Send(data []byte) error + func (c *Client) Subscribe(channel string) error + func (c *Client) Transport() TransportInfo + func (c *Client) Unsubscribe(ch string, opts ...UnsubscribeOption) error + func (c *Client) UserID() string + type ClientCloseFunc func() error + type ClientInfo struct + ChanInfo []byte + ClientID string + ConnInfo []byte + UserID string + type Closer interface + Close func(ctx context.Context) error + type Config struct + ChannelMaxLength int + ClientChannelLimit int + ClientChannelPositionCheckDelay time.Duration + ClientExpiredCloseDelay time.Duration + ClientExpiredSubCloseDelay time.Duration + ClientPresenceExpireInterval time.Duration + ClientPresenceUpdateInterval time.Duration + ClientQueueMaxSize int + ClientStaleCloseDelay time.Duration + LogHandler LogHandler + LogLevel LogLevel + MetricsNamespace string + Name string + NodeInfoMetricsAggregateInterval time.Duration + UserConnectionLimit int + Version string + type ConnectEvent struct + ClientID string + Data []byte + Name string + Token string + Transport TransportInfo + Version string + type ConnectHandler func(*Client) + type ConnectReply struct + ClientSideRefresh bool + Context context.Context + Credentials *Credentials + Data []byte + Subscriptions map[string]SubscribeOptions + type ConnectingHandler func(context.Context, ConnectEvent) (ConnectReply, error) + type Credentials struct + ExpireAt int64 + Info []byte + UserID string + func GetCredentials(ctx context.Context) (*Credentials, bool) + type Disconnect struct + Code uint32 + Reason string + Reconnect bool + func (d *Disconnect) CloseText() string + func (d *Disconnect) Error() string + func (d *Disconnect) String() string + type DisconnectEvent struct + Disconnect *Disconnect + type DisconnectHandler func(DisconnectEvent) + type DisconnectOption func(options *DisconnectOptions) + func WithClientWhitelist(whitelist []string) DisconnectOption + func WithDisconnect(disconnect *Disconnect) DisconnectOption + type DisconnectOptions struct + ClientWhitelist []string + Disconnect *Disconnect + type EncodingType string + const EncodingTypeBinary + const EncodingTypeJSON + type Engine interface + type Error struct + Code uint32 + Message string + func (e Error) Error() string + type HistoryCallback func(HistoryReply, error) + type HistoryEvent struct + Channel string + type HistoryFilter struct + Limit int + Since *StreamPosition + type HistoryHandler func(HistoryEvent, HistoryCallback) + type HistoryOption func(options *HistoryOptions) + func Since(sp StreamPosition) HistoryOption + func WithLimit(limit int) HistoryOption + type HistoryOptions struct + Limit int + Since *StreamPosition + type HistoryReply struct + Result *HistoryResult + type HistoryResult struct + Publications []*Publication + type Hub struct + func (h *Hub) Channels() []string + func (h *Hub) NumChannels() int + func (h *Hub) NumClients() int + func (h *Hub) NumSubscribers(ch string) int + func (h *Hub) NumUsers() int + type Info struct + Nodes []NodeInfo + type LogEntry struct + Fields map[string]interface{} + Level LogLevel + Message string + func NewLogEntry(level LogLevel, message string, fields ...map[string]interface{}) LogEntry + type LogHandler func(LogEntry) + type LogLevel int + const LogLevelDebug + const LogLevelError + const LogLevelInfo + const LogLevelNone + type MemoryEngine struct + func NewMemoryEngine(n *Node, c MemoryEngineConfig) (*MemoryEngine, error) + func (e *MemoryEngine) AddPresence(ch string, uid string, info *ClientInfo, _ time.Duration) error + func (e *MemoryEngine) Channels() ([]string, error) + func (e *MemoryEngine) History(ch string, filter HistoryFilter) ([]*Publication, StreamPosition, error) + func (e *MemoryEngine) Presence(ch string) (map[string]*ClientInfo, error) + func (e *MemoryEngine) PresenceStats(ch string) (PresenceStats, error) + func (e *MemoryEngine) Publish(ch string, data []byte, opts PublishOptions) (StreamPosition, error) + func (e *MemoryEngine) PublishControl(data []byte) error + func (e *MemoryEngine) PublishJoin(ch string, info *ClientInfo) error + func (e *MemoryEngine) PublishLeave(ch string, info *ClientInfo) error + func (e *MemoryEngine) RemoveHistory(ch string) error + func (e *MemoryEngine) RemovePresence(ch string, uid string) error + func (e *MemoryEngine) Run(h BrokerEventHandler) error + func (e *MemoryEngine) Subscribe(_ string) error + func (e *MemoryEngine) Unsubscribe(_ string) error + type MemoryEngineConfig struct + HistoryMetaTTL time.Duration + type MessageEvent struct + Data []byte + type MessageHandler func(MessageEvent) + type Metrics struct + Interval float64 + Items map[string]float64 + type Node struct + func New(c Config) (*Node, error) + func (n *Node) Channels() ([]string, error) + func (n *Node) Disconnect(user string, opts ...DisconnectOption) error + func (n *Node) History(ch string, opts ...HistoryOption) (HistoryResult, error) + func (n *Node) Hub() *Hub + func (n *Node) Info() (Info, error) + func (n *Node) Log(entry LogEntry) + func (n *Node) LogEnabled(level LogLevel) bool + func (n *Node) NotifyShutdown() chan struct{} + func (n *Node) OnConnect(handler ConnectHandler) + func (n *Node) OnConnecting(handler ConnectingHandler) + func (n *Node) Presence(ch string) (PresenceResult, error) + func (n *Node) PresenceStats(ch string) (PresenceStatsResult, error) + func (n *Node) Publish(channel string, data []byte, opts ...PublishOption) (PublishResult, error) + func (n *Node) RemoveHistory(ch string) error + func (n *Node) Run() error + func (n *Node) SetBroker(b Broker) + func (n *Node) SetEngine(e Engine) + func (n *Node) SetPresenceManager(m PresenceManager) + func (n *Node) Shutdown(ctx context.Context) error + func (n *Node) Unsubscribe(user string, ch string, opts ...UnsubscribeOption) error + type NodeInfo struct + Metrics *Metrics + Name string + NumChannels uint32 + NumClients uint32 + NumUsers uint32 + UID string + Uptime uint32 + Version string + type PresenceCallback func(PresenceReply, error) + type PresenceEvent struct + Channel string + type PresenceHandler func(PresenceEvent, PresenceCallback) + type PresenceManager interface + AddPresence func(ch string, clientID string, info *ClientInfo, expire time.Duration) error + Presence func(ch string) (map[string]*ClientInfo, error) + PresenceStats func(ch string) (PresenceStats, error) + RemovePresence func(ch string, clientID string) error + type PresenceReply struct + Result *PresenceResult + type PresenceResult struct + Presence map[string]*ClientInfo + type PresenceStats struct + NumClients int + NumUsers int + type PresenceStatsCallback func(PresenceStatsReply, error) + type PresenceStatsEvent struct + Channel string + type PresenceStatsHandler func(PresenceStatsEvent, PresenceStatsCallback) + type PresenceStatsReply struct + Result *PresenceStatsResult + type PresenceStatsResult struct + type ProtocolType string + const ProtocolTypeJSON + const ProtocolTypeProtobuf + type Publication struct + Data []byte + Info *ClientInfo + Offset uint64 + type PublishCallback func(PublishReply, error) + type PublishEvent struct + Channel string + ClientInfo *ClientInfo + Data []byte + type PublishHandler func(PublishEvent, PublishCallback) + type PublishOption func(*PublishOptions) + func WithClientInfo(info *ClientInfo) PublishOption + func WithHistory(size int, ttl time.Duration) PublishOption + type PublishOptions struct + ClientInfo *ClientInfo + HistorySize int + HistoryTTL time.Duration + type PublishReply struct + Options PublishOptions + Result *PublishResult + type PublishResult struct + type RPCCallback func(RPCReply, error) + type RPCEvent struct + Data []byte + Method string + type RPCHandler func(RPCEvent, RPCCallback) + type RPCReply struct + Data []byte + type RedisEngine struct + func NewRedisEngine(n *Node, config RedisEngineConfig) (*RedisEngine, error) + func (e *RedisEngine) AddPresence(ch string, uid string, info *ClientInfo, exp time.Duration) error + func (e *RedisEngine) Channels() ([]string, error) + func (e *RedisEngine) History(ch string, filter HistoryFilter) ([]*Publication, StreamPosition, error) + func (e *RedisEngine) Presence(ch string) (map[string]*ClientInfo, error) + func (e *RedisEngine) PresenceStats(ch string) (PresenceStats, error) + func (e *RedisEngine) Publish(ch string, data []byte, opts PublishOptions) (StreamPosition, error) + func (e *RedisEngine) PublishControl(data []byte) error + func (e *RedisEngine) PublishJoin(ch string, info *ClientInfo) error + func (e *RedisEngine) PublishLeave(ch string, info *ClientInfo) error + func (e *RedisEngine) RemoveHistory(ch string) error + func (e *RedisEngine) RemovePresence(ch string, uid string) error + func (e *RedisEngine) Run(h BrokerEventHandler) error + func (e *RedisEngine) Subscribe(ch string) error + func (e *RedisEngine) Unsubscribe(ch string) error + type RedisEngineConfig struct + HistoryMetaTTL time.Duration + Shards []RedisShardConfig + UseStreams bool + type RedisShardConfig struct + ClusterAddrs []string + ConnectTimeout time.Duration + DB int + Host string + IdleTimeout time.Duration + Password string + Port int + Prefix string + PubSubNumWorkers int + ReadTimeout time.Duration + SentinelAddrs []string + SentinelMasterName string + SentinelPassword string + TLSConfig *tls.Config + TLSSkipVerify bool + UseTLS bool + WriteTimeout time.Duration + type RefreshCallback func(RefreshReply, error) + type RefreshEvent struct + ClientSideRefresh bool + Token string + type RefreshHandler func(RefreshEvent, RefreshCallback) + type RefreshReply struct + ExpireAt int64 + Expired bool + Info []byte + type SockjsConfig struct + CheckOrigin func(*http.Request) bool + HandlerPrefix string + HeartbeatDelay time.Duration + URL string + WebsocketCheckOrigin func(*http.Request) bool + WebsocketReadBufferSize int + WebsocketUseWriteBufferPool bool + WebsocketWriteBufferSize int + WebsocketWriteTimeout time.Duration + type SockjsHandler struct + func NewSockjsHandler(n *Node, c SockjsConfig) *SockjsHandler + func (s *SockjsHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request) + type StreamPosition struct + Epoch string + Offset uint64 + type SubRefreshCallback func(SubRefreshReply, error) + type SubRefreshEvent struct + Channel string + ClientSideRefresh bool + Token string + type SubRefreshHandler func(SubRefreshEvent, SubRefreshCallback) + type SubRefreshReply struct + ExpireAt int64 + Expired bool + Info []byte + type SubscribeCallback func(SubscribeReply, error) + type SubscribeEvent struct + Channel string + Token string + type SubscribeHandler func(SubscribeEvent, SubscribeCallback) + type SubscribeOptions struct + ChannelInfo []byte + ExpireAt int64 + JoinLeave bool + Presence bool + Recover bool + type SubscribeReply struct + ClientSideRefresh bool + Options SubscribeOptions + type Transport interface + Close func(*Disconnect) error + Write func([]byte) error + type TransportInfo interface + Encoding func() EncodingType + Name func() string + Protocol func() ProtocolType + type UnsubscribeEvent struct + Channel string + type UnsubscribeHandler func(UnsubscribeEvent) + type UnsubscribeOption func(*UnsubscribeOptions) + func WithResubscribe(resubscribe bool) UnsubscribeOption + type UnsubscribeOptions struct + Resubscribe bool + type WebsocketConfig struct + CheckOrigin func(r *http.Request) bool + Compression bool + CompressionLevel int + CompressionMinSize int + MessageSizeLimit int + PingInterval time.Duration + ReadBufferSize int + UseWriteBufferPool bool + WriteBufferSize int + WriteTimeout time.Duration + type WebsocketHandler struct + func NewWebsocketHandler(n *Node, c WebsocketConfig) *WebsocketHandler + func (s *WebsocketHandler) ServeHTTP(rw http.ResponseWriter, r *http.Request)