Documentation ¶
Index ¶
- Constants
- Variables
- func RandomId() (string, error)
- func Uid2(length int) (string, error)
- type AckRequest
- type ClusterAckRequest
- type ClusterAdapter
- type ClusterAdapterBuilder
- type ClusterAdapterOptions
- func (s *ClusterAdapterOptions) Assign(data ClusterAdapterOptionsInterface) (ClusterAdapterOptionsInterface, error)
- func (s *ClusterAdapterOptions) GetRawHeartbeatInterval() *time.Duration
- func (s *ClusterAdapterOptions) GetRawHeartbeatTimeout() *int64
- func (s *ClusterAdapterOptions) HeartbeatInterval() time.Duration
- func (s *ClusterAdapterOptions) HeartbeatTimeout() int64
- func (s *ClusterAdapterOptions) SetHeartbeatInterval(heartbeatInterval time.Duration)
- func (s *ClusterAdapterOptions) SetHeartbeatTimeout(heartbeatTimeout int64)
- type ClusterAdapterOptionsInterface
- type ClusterAdapterWithHeartbeat
- type ClusterAdapterWithHeartbeatBuilder
- type ClusterMessage
- type ClusterMessageRecord
- type ClusterRequest
- type MessageType
- type RedisAdapter
- type RedisAdapterBuilder
- type RedisAdapterOptions
- func (s *RedisAdapterOptions) Assign(data RedisAdapterOptionsInterface) (RedisAdapterOptionsInterface, error)
- func (s *RedisAdapterOptions) GetRawKey() *string
- func (s *RedisAdapterOptions) GetRawParser() types.Parser
- func (s *RedisAdapterOptions) GetRawPublishOnSpecificResponseChannel() *bool
- func (s *RedisAdapterOptions) GetRawRequestsTimeout() *time.Duration
- func (s *RedisAdapterOptions) Key() string
- func (s *RedisAdapterOptions) Parser() types.Parser
- func (s *RedisAdapterOptions) PublishOnSpecificResponseChannel() bool
- func (s *RedisAdapterOptions) RequestsTimeout() time.Duration
- func (s *RedisAdapterOptions) SetKey(key string)
- func (s *RedisAdapterOptions) SetParser(parser types.Parser)
- func (s *RedisAdapterOptions) SetPublishOnSpecificResponseChannel(publishOnSpecificResponseChannel bool)
- func (s *RedisAdapterOptions) SetRequestsTimeout(requestsTimeout time.Duration)
- type RedisAdapterOptionsInterface
- type Request
- type Response
- type ResponseSockets
- type SentRequest
- type ServerRequest
- type ShardedRedisAdapter
- type ShardedRedisAdapterBuilder
- type ShardedRedisAdapterOptions
- func (s *ShardedRedisAdapterOptions) Assign(data ShardedRedisAdapterOptionsInterface) (ShardedRedisAdapterOptionsInterface, error)
- func (s *ShardedRedisAdapterOptions) ChannelPrefix() string
- func (s *ShardedRedisAdapterOptions) GetRawChannelPrefix() *string
- func (s *ShardedRedisAdapterOptions) GetRawSubscriptionMode() *subMode
- func (s *ShardedRedisAdapterOptions) SetChannelPrefix(channelPrefix string)
- func (s *ShardedRedisAdapterOptions) SetSubscriptionMode(subMode subMode)
- func (s *ShardedRedisAdapterOptions) SubscriptionMode() subMode
- type ShardedRedisAdapterOptionsInterface
Constants ¶
View Source
const ( EMITTER_UID string = "emitter" DEFAULT_TIMEOUT time.Duration = 5000 * time.Millisecond )
Variables ¶
View Source
var ( StaticSubscriptionMode subMode = subMode{"static"} DynamicSubscriptionMode subMode = subMode{"dynamic"} )
Functions ¶
Types ¶
type AckRequest ¶
func NewAckRequest ¶
func NewAckRequest(clientCountCallback func(uint64), ack func([]any, error)) AckRequest
type ClusterAckRequest ¶
func NewClusterAckRequest ¶
func NewClusterAckRequest(clientCountCallback func(uint64), ack func([]any, error)) ClusterAckRequest
type ClusterAdapter ¶
type ClusterAdapter interface { socket.Adapter Uid() string OnMessage(*ClusterMessage, int64) OnResponse(*ClusterMessage) Publish(*ClusterMessage) (int64, error) PublishMessage(*ClusterMessage) (int64, error) PublishResponse(string, *ClusterMessage) (int64, error) }
func MakeClusterAdapter ¶
func MakeClusterAdapter() ClusterAdapter
func NewClusterAdapter ¶
func NewClusterAdapter(nsp socket.NamespaceInterface) ClusterAdapter
type ClusterAdapterBuilder ¶
type ClusterAdapterBuilder struct {
socket.AdapterConstructor
}
A cluster-ready adapter. Any extending class must:
- implement [ClusterAdapter#PublishMessage] and [ClusterAdapter#PublishResponse] - call [ClusterAdapter#OnMessage] and [ClusterAdapter#OnResponse]
func (*ClusterAdapterBuilder) New ¶
func (cb *ClusterAdapterBuilder) New(nsp socket.NamespaceInterface) socket.Adapter
type ClusterAdapterOptions ¶
type ClusterAdapterOptions struct {
// contains filtered or unexported fields
}
func DefaultClusterAdapterOptions ¶
func DefaultClusterAdapterOptions() *ClusterAdapterOptions
func (*ClusterAdapterOptions) Assign ¶
func (s *ClusterAdapterOptions) Assign(data ClusterAdapterOptionsInterface) (ClusterAdapterOptionsInterface, error)
func (*ClusterAdapterOptions) GetRawHeartbeatInterval ¶
func (s *ClusterAdapterOptions) GetRawHeartbeatInterval() *time.Duration
func (*ClusterAdapterOptions) GetRawHeartbeatTimeout ¶
func (s *ClusterAdapterOptions) GetRawHeartbeatTimeout() *int64
func (*ClusterAdapterOptions) HeartbeatInterval ¶
func (s *ClusterAdapterOptions) HeartbeatInterval() time.Duration
func (*ClusterAdapterOptions) HeartbeatTimeout ¶
func (s *ClusterAdapterOptions) HeartbeatTimeout() int64
func (*ClusterAdapterOptions) SetHeartbeatInterval ¶
func (s *ClusterAdapterOptions) SetHeartbeatInterval(heartbeatInterval time.Duration)
func (*ClusterAdapterOptions) SetHeartbeatTimeout ¶
func (s *ClusterAdapterOptions) SetHeartbeatTimeout(heartbeatTimeout int64)
type ClusterAdapterWithHeartbeat ¶
type ClusterAdapterWithHeartbeat interface { ClusterAdapter SetOpts(*ClusterAdapterOptions) }
func MakeClusterAdapterWithHeartbeat ¶
func MakeClusterAdapterWithHeartbeat() ClusterAdapterWithHeartbeat
func NewClusterAdapterWithHeartbeat ¶
func NewClusterAdapterWithHeartbeat(nsp socket.NamespaceInterface, opts *ClusterAdapterOptions) ClusterAdapterWithHeartbeat
type ClusterAdapterWithHeartbeatBuilder ¶
type ClusterAdapterWithHeartbeatBuilder struct { socket.AdapterConstructor Opts *ClusterAdapterOptions }
func (*ClusterAdapterWithHeartbeatBuilder) New ¶
func (c *ClusterAdapterWithHeartbeatBuilder) New(nsp socket.NamespaceInterface) socket.Adapter
type ClusterMessage ¶
type ClusterMessage struct { Uid string Type MessageType Data *ClusterMessageRecord }
type ClusterMessageRecord ¶
type ClusterMessageRecord struct { RequestId string Packet any ClientCount uint64 Sockets any Opts *types.PacketOptions Rooms []socket.Room Close bool }
ClusterMessage
type ClusterRequest ¶
type MessageType ¶
type MessageType int
const ( MESSAGE_INITIAL_HEARTBEAT MessageType = 1 MESSAGE_HEARTBEAT MessageType = 2 MESSAGE_BROADCAST MessageType = 3 MESSAGE_SOCKETS_JOIN MessageType = 4 MESSAGE_SOCKETS_LEAVE MessageType = 5 MESSAGE_DISCONNECT_SOCKETS MessageType = 6 MESSAGE_FETCH_SOCKETS MessageType = 7 MESSAGE_FETCH_SOCKETS_RESPONSE MessageType = 8 MESSAGE_SERVER_SIDE_EMIT MessageType = 9 MESSAGE_SERVER_SIDE_EMIT_RESPONSE MessageType = 10 MESSAGE_BROADCAST_CLIENT_COUNT MessageType = 11 MESSAGE_BROADCAST_ACK MessageType = 12 )
type RedisAdapter ¶
type RedisAdapter interface { socket.Adapter SetRedis(*_types.RedisClient) SetOpts(*RedisAdapterOptions) Uid() string RequestsTimeout() time.Duration PublishOnSpecificResponseChannel() bool Parser() _types.Parser AllRooms() func(func(*types.Set[socket.Room], error)) }
func MakeRedisAdapter ¶
func MakeRedisAdapter() RedisAdapter
func NewRedisAdapter ¶
func NewRedisAdapter(nsp socket.NamespaceInterface, redis *_types.RedisClient, opts *RedisAdapterOptions) RedisAdapter
type RedisAdapterBuilder ¶
type RedisAdapterBuilder struct { socket.AdapterConstructor // a Redis client Redis *_types.RedisClient // additional options Opts *RedisAdapterOptions }
func (*RedisAdapterBuilder) New ¶
func (rb *RedisAdapterBuilder) New(nsp socket.NamespaceInterface) socket.Adapter
Adapter constructor.
type RedisAdapterOptions ¶
type RedisAdapterOptions struct {
// contains filtered or unexported fields
}
func DefaultRedisAdapterOptions ¶
func DefaultRedisAdapterOptions() *RedisAdapterOptions
func (*RedisAdapterOptions) Assign ¶
func (s *RedisAdapterOptions) Assign(data RedisAdapterOptionsInterface) (RedisAdapterOptionsInterface, error)
func (*RedisAdapterOptions) GetRawKey ¶
func (s *RedisAdapterOptions) GetRawKey() *string
func (*RedisAdapterOptions) GetRawParser ¶
func (s *RedisAdapterOptions) GetRawParser() types.Parser
func (*RedisAdapterOptions) GetRawPublishOnSpecificResponseChannel ¶
func (s *RedisAdapterOptions) GetRawPublishOnSpecificResponseChannel() *bool
func (*RedisAdapterOptions) GetRawRequestsTimeout ¶
func (s *RedisAdapterOptions) GetRawRequestsTimeout() *time.Duration
func (*RedisAdapterOptions) Key ¶
func (s *RedisAdapterOptions) Key() string
func (*RedisAdapterOptions) Parser ¶
func (s *RedisAdapterOptions) Parser() types.Parser
func (*RedisAdapterOptions) PublishOnSpecificResponseChannel ¶
func (s *RedisAdapterOptions) PublishOnSpecificResponseChannel() bool
func (*RedisAdapterOptions) RequestsTimeout ¶
func (s *RedisAdapterOptions) RequestsTimeout() time.Duration
func (*RedisAdapterOptions) SetKey ¶
func (s *RedisAdapterOptions) SetKey(key string)
func (*RedisAdapterOptions) SetParser ¶
func (s *RedisAdapterOptions) SetParser(parser types.Parser)
func (*RedisAdapterOptions) SetPublishOnSpecificResponseChannel ¶
func (s *RedisAdapterOptions) SetPublishOnSpecificResponseChannel(publishOnSpecificResponseChannel bool)
func (*RedisAdapterOptions) SetRequestsTimeout ¶
func (s *RedisAdapterOptions) SetRequestsTimeout(requestsTimeout time.Duration)
type RedisAdapterOptionsInterface ¶
type RedisAdapterOptionsInterface interface { SetKey(string) GetRawKey() *string Key() string SetRequestsTimeout(time.Duration) GetRawRequestsTimeout() *time.Duration RequestsTimeout() time.Duration SetPublishOnSpecificResponseChannel(bool) GetRawPublishOnSpecificResponseChannel() *bool PublishOnSpecificResponseChannel() bool SetParser(types.Parser) GetRawParser() types.Parser Parser() types.Parser }
type Request ¶
type Request struct { Type _types.RequestType `json:"type,omitempty" mapstructure:"type,omitempty" msgpack:"type,omitempty"` RequestId string `json:"requestId,omitempty" mapstructure:"requestId,omitempty" msgpack:"requestId,omitempty"` Rooms []socket.Room `json:"rooms,omitempty" mapstructure:"rooms,omitempty" msgpack:"rooms,omitempty"` Opts *_types.PacketOptions `json:"opts,omitempty" mapstructure:"opts,omitempty" msgpack:"opts,omitempty"` Sid socket.SocketId `json:"sid,omitempty" mapstructure:"sid,omitempty" msgpack:"sid,omitempty"` Room socket.Room `json:"room,omitempty" mapstructure:"room,omitempty" msgpack:"room,omitempty"` Close bool `json:"close,omitempty" mapstructure:"close,omitempty" msgpack:"close,omitempty"` Uid string `json:"uid,omitempty" mapstructure:"uid,omitempty" msgpack:"uid,omitempty"` Data []any `json:"data,omitempty" mapstructure:"data,omitempty" msgpack:"data,omitempty"` Packet *parser.Packet `json:"packet,omitempty" mapstructure:"packet,omitempty" msgpack:"packet,omitempty"` }
type Response ¶
type Response struct { Type _types.RequestType `json:"type,omitempty" mapstructure:"type,omitempty" msgpack:"type,omitempty"` RequestId string `json:"requestId,omitempty" mapstructure:"requestId,omitempty" msgpack:"requestId,omitempty"` Rooms []socket.Room `json:"rooms,omitempty" mapstructure:"rooms,omitempty" msgpack:"rooms,omitempty"` Sockets []*ResponseSockets `json:"sockets,omitempty" mapstructure:"sockets,omitempty" msgpack:"sockets,omitempty"` Data []any `json:"data,omitempty" mapstructure:"data,omitempty" msgpack:"data,omitempty"` ClientCount uint64 `json:"clientcount,omitempty" mapstructure:"clientcount,omitempty" msgpack:"clientcount,omitempty"` Packet []any `json:"packet,omitempty" mapstructure:"packet,omitempty" msgpack:"packet,omitempty"` }
type ResponseSockets ¶
type ResponseSockets struct { SocketId socket.SocketId `json:"id,omitempty" mapstructure:"id,omitempty" msgpack:"id,omitempty"` SocketHandshake *socket.Handshake `json:"handshake,omitempty" mapstructure:"handshake,omitempty" msgpack:"handshake,omitempty"` SocketRooms []socket.Room `json:"rooms,omitempty" mapstructure:"rooms,omitempty" msgpack:"rooms,omitempty"` SocketData any `json:"data,omitempty" mapstructure:"data,omitempty" msgpack:"data,omitempty"` // contains filtered or unexported fields }
func (*ResponseSockets) Data ¶
func (r *ResponseSockets) Data() any
func (*ResponseSockets) Handshake ¶
func (r *ResponseSockets) Handshake() *socket.Handshake
func (*ResponseSockets) Id ¶
func (r *ResponseSockets) Id() socket.SocketId
type SentRequest ¶
type ServerRequest ¶
type ServerRequest struct { RequestId string `json:"requestId,omitempty" mapstructure:"requestId,omitempty" msgpack:"requestId,omitempty"` Uid string `json:"uid,omitempty" mapstructure:"uid,omitempty" msgpack:"uid,omitempty"` Type _types.RequestType `json:"type,omitempty" mapstructure:"type,omitempty" msgpack:"type,omitempty"` Data []any `json:"data,omitempty" mapstructure:"data,omitempty" msgpack:"data,omitempty"` }
type ShardedRedisAdapter ¶
type ShardedRedisAdapter interface { ClusterAdapter SetRedis(*types.RedisClient) SetOpts(*ShardedRedisAdapterOptions) }
func MakeShardedRedisAdapter ¶
func MakeShardedRedisAdapter() ShardedRedisAdapter
func NewShardedRedisAdapter ¶
func NewShardedRedisAdapter(nsp socket.NamespaceInterface, redis *_types.RedisClient, opts *ShardedRedisAdapterOptions) ShardedRedisAdapter
type ShardedRedisAdapterBuilder ¶
type ShardedRedisAdapterBuilder struct { socket.AdapterConstructor // a Redis client Redis *_types.RedisClient // additional options Opts *ShardedRedisAdapterOptions }
Create a new Adapter based on Redis sharded Pub/Sub introduced in Redis 7.0.
See: https://redis.io/docs/manual/pubsub/#sharded-pubsub
func (*ShardedRedisAdapterBuilder) New ¶
func (sb *ShardedRedisAdapterBuilder) New(nsp socket.NamespaceInterface) socket.Adapter
type ShardedRedisAdapterOptions ¶
type ShardedRedisAdapterOptions struct {
// contains filtered or unexported fields
}
func DefaultShardedRedisAdapterOptions ¶
func DefaultShardedRedisAdapterOptions() *ShardedRedisAdapterOptions
func (*ShardedRedisAdapterOptions) Assign ¶
func (s *ShardedRedisAdapterOptions) Assign(data ShardedRedisAdapterOptionsInterface) (ShardedRedisAdapterOptionsInterface, error)
func (*ShardedRedisAdapterOptions) ChannelPrefix ¶
func (s *ShardedRedisAdapterOptions) ChannelPrefix() string
func (*ShardedRedisAdapterOptions) GetRawChannelPrefix ¶
func (s *ShardedRedisAdapterOptions) GetRawChannelPrefix() *string
func (*ShardedRedisAdapterOptions) GetRawSubscriptionMode ¶
func (s *ShardedRedisAdapterOptions) GetRawSubscriptionMode() *subMode
func (*ShardedRedisAdapterOptions) SetChannelPrefix ¶
func (s *ShardedRedisAdapterOptions) SetChannelPrefix(channelPrefix string)
func (*ShardedRedisAdapterOptions) SetSubscriptionMode ¶
func (s *ShardedRedisAdapterOptions) SetSubscriptionMode(subMode subMode)
func (*ShardedRedisAdapterOptions) SubscriptionMode ¶
func (s *ShardedRedisAdapterOptions) SubscriptionMode() subMode
Click to show internal directories.
Click to hide internal directories.