Documentation
¶
Overview ¶
Package adapter provides configuration options for the Valkey sharded Pub/Sub adapter for Socket.IO.
Package adapter defines the interface for the Valkey sharded Pub/Sub adapter for Socket.IO.
Package adapter implements a Valkey sharded Pub/Sub adapter for Socket.IO clustering.
This adapter uses Valkey's sharded Pub/Sub for improved horizontal scalability. Unlike the Redis sharded adapter, no manual cluster-slot pooling is required because the valkey-go client handles cluster routing internally.
Package adapter provides configuration options for the Valkey Streams-based Socket.IO adapter.
Package adapter defines types and interfaces for the Valkey Streams-based Socket.IO adapter.
Package adapter implements a Valkey Streams-based adapter for Socket.IO clustering. Valkey Streams provide message persistence and enable session recovery across server restarts.
Package adapter provides configuration options for the Valkey-based Socket.IO adapter.
Package adapter defines types and interfaces for the Valkey-based Socket.IO adapter implementation.
Package adapter provides a Valkey-based adapter implementation for Socket.IO clustering.
Index ¶
- Constants
- Variables
- type AckRequest
- type Packet
- type RawClusterMessage
- type Request
- type Response
- type ShardedValkeyAdapter
- type ShardedValkeyAdapterBuilder
- type ShardedValkeyAdapterOptions
- func (s *ShardedValkeyAdapterOptions) Assign(data ShardedValkeyAdapterOptionsInterface) ShardedValkeyAdapterOptionsInterface
- func (s *ShardedValkeyAdapterOptions) ChannelPrefix() string
- func (s *ShardedValkeyAdapterOptions) GetRawChannelPrefix() types.Optional[string]
- func (s *ShardedValkeyAdapterOptions) GetRawSubscriptionMode() types.Optional[valkey.SubscriptionMode]
- func (s *ShardedValkeyAdapterOptions) SetChannelPrefix(v string)
- func (s *ShardedValkeyAdapterOptions) SetSubscriptionMode(v valkey.SubscriptionMode)
- func (s *ShardedValkeyAdapterOptions) SubscriptionMode() valkey.SubscriptionMode
- type ShardedValkeyAdapterOptionsInterface
- type ValkeyAdapter
- type ValkeyAdapterBuilder
- type ValkeyAdapterOptions
- func (s *ValkeyAdapterOptions) Assign(data ValkeyAdapterOptionsInterface) ValkeyAdapterOptionsInterface
- func (s *ValkeyAdapterOptions) GetRawPublishOnSpecificResponseChannel() types.Optional[bool]
- func (s *ValkeyAdapterOptions) GetRawRequestsTimeout() types.Optional[time.Duration]
- func (s *ValkeyAdapterOptions) PublishOnSpecificResponseChannel() bool
- func (s *ValkeyAdapterOptions) RequestsTimeout() time.Duration
- func (s *ValkeyAdapterOptions) SetPublishOnSpecificResponseChannel(v bool)
- func (s *ValkeyAdapterOptions) SetRequestsTimeout(requestsTimeout time.Duration)
- type ValkeyAdapterOptionsInterface
- type ValkeyRequest
- type ValkeyStreamsAdapter
- type ValkeyStreamsAdapterBuilder
- type ValkeyStreamsAdapterOptions
- func (s *ValkeyStreamsAdapterOptions) Assign(data ValkeyStreamsAdapterOptionsInterface) ValkeyStreamsAdapterOptionsInterface
- func (s *ValkeyStreamsAdapterOptions) BlockTimeInMs() int64
- func (s *ValkeyStreamsAdapterOptions) ChannelPrefix() string
- func (s *ValkeyStreamsAdapterOptions) GetRawBlockTimeInMs() types.Optional[int64]
- func (s *ValkeyStreamsAdapterOptions) GetRawChannelPrefix() types.Optional[string]
- func (s *ValkeyStreamsAdapterOptions) GetRawMaxLen() types.Optional[int64]
- func (s *ValkeyStreamsAdapterOptions) GetRawOnlyPlaintext() types.Optional[bool]
- func (s *ValkeyStreamsAdapterOptions) GetRawReadCount() types.Optional[int64]
- func (s *ValkeyStreamsAdapterOptions) GetRawSessionKeyPrefix() types.Optional[string]
- func (s *ValkeyStreamsAdapterOptions) GetRawStreamCount() types.Optional[int]
- func (s *ValkeyStreamsAdapterOptions) GetRawStreamName() types.Optional[string]
- func (s *ValkeyStreamsAdapterOptions) GetRawUseShardedPubSub() types.Optional[bool]
- func (s *ValkeyStreamsAdapterOptions) MaxLen() int64
- func (s *ValkeyStreamsAdapterOptions) OnlyPlaintext() bool
- func (s *ValkeyStreamsAdapterOptions) ReadCount() int64
- func (s *ValkeyStreamsAdapterOptions) SessionKeyPrefix() string
- func (s *ValkeyStreamsAdapterOptions) SetBlockTimeInMs(v int64)
- func (s *ValkeyStreamsAdapterOptions) SetChannelPrefix(v string)
- func (s *ValkeyStreamsAdapterOptions) SetMaxLen(v int64)
- func (s *ValkeyStreamsAdapterOptions) SetOnlyPlaintext(v bool)
- func (s *ValkeyStreamsAdapterOptions) SetReadCount(v int64)
- func (s *ValkeyStreamsAdapterOptions) SetSessionKeyPrefix(v string)
- func (s *ValkeyStreamsAdapterOptions) SetStreamCount(v int)
- func (s *ValkeyStreamsAdapterOptions) SetStreamName(v string)
- func (s *ValkeyStreamsAdapterOptions) SetUseShardedPubSub(v bool)
- func (s *ValkeyStreamsAdapterOptions) StreamCount() int
- func (s *ValkeyStreamsAdapterOptions) StreamName() string
- func (s *ValkeyStreamsAdapterOptions) UseShardedPubSub() bool
- type ValkeyStreamsAdapterOptionsInterface
Constants ¶
const ( DefaultStreamName = "socket.io" DefaultStreamMaxLen = 10_000 DefaultStreamReadCount = 100 DefaultStreamCount = 1 DefaultStreamChannelPrefix = "socket.io" DefaultBlockTimeInMs = 5_000 DefaultSessionKeyPrefix = "sio:session:" )
const DefaultRequestsTimeout = 5000 * time.Millisecond
DefaultRequestsTimeout is the default timeout for inter-node requests.
const (
// DefaultShardedChannelPrefix is the default channel prefix for sharded Valkey adapter.
DefaultShardedChannelPrefix = "socket.io"
)
Variables ¶
var DefaultShardedSubscriptionMode = valkey.DynamicSubscriptionMode
DefaultShardedSubscriptionMode is the default subscription mode for the sharded adapter.
Functions ¶
This section is empty.
Types ¶
type AckRequest ¶
type AckRequest = adapter.ClusterAckRequest
AckRequest is an alias for adapter.ClusterAckRequest, used for acknowledgement tracking.
type Packet ¶
type Packet = valkey.ValkeyPacket
Packet is an alias for valkey.ValkeyPacket, representing a broadcast packet sent via Valkey.
type RawClusterMessage ¶
RawClusterMessage represents a raw message from the Valkey stream.
func (RawClusterMessage) Data ¶
func (r RawClusterMessage) Data() string
Data returns the data field from the raw cluster message.
func (RawClusterMessage) Nsp ¶
func (r RawClusterMessage) Nsp() string
Nsp returns the namespace from the raw cluster message.
func (RawClusterMessage) Type ¶
func (r RawClusterMessage) Type() string
Type returns the message type from the raw cluster message.
func (RawClusterMessage) Uid ¶
func (r RawClusterMessage) Uid() string
Uid returns the UID from the raw cluster message.
type Request ¶
type Request = valkey.ValkeyRequest
Request is an alias for valkey.ValkeyRequest, representing an inter-node request.
type Response ¶
type Response = valkey.ValkeyResponse
Response is an alias for valkey.ValkeyResponse, representing an inter-node response.
type ShardedValkeyAdapter ¶
type ShardedValkeyAdapter interface {
adapter.ClusterAdapter
SetValkey(*valkey.ValkeyClient)
SetOpts(any)
}
ShardedValkeyAdapter defines the interface for a sharded Valkey-based Socket.IO adapter.
func MakeShardedValkeyAdapter ¶
func MakeShardedValkeyAdapter() ShardedValkeyAdapter
MakeShardedValkeyAdapter creates a new uninitialized shardedValkeyAdapter.
func NewShardedValkeyAdapter ¶
func NewShardedValkeyAdapter(nsp socket.Namespace, valkeyClient *valkey.ValkeyClient, opts any) ShardedValkeyAdapter
NewShardedValkeyAdapter creates and fully initializes a sharded Valkey adapter.
type ShardedValkeyAdapterBuilder ¶
type ShardedValkeyAdapterBuilder struct {
// Valkey is the Valkey client used for sharded Pub/Sub communication.
Valkey *valkey.ValkeyClient
// Opts contains configuration options for the adapter.
Opts ShardedValkeyAdapterOptionsInterface
}
ShardedValkeyAdapterBuilder creates sharded Valkey adapters for Socket.IO namespaces.
type ShardedValkeyAdapterOptions ¶
type ShardedValkeyAdapterOptions struct {
// contains filtered or unexported fields
}
ShardedValkeyAdapterOptions holds configuration for the sharded Valkey adapter.
func DefaultShardedValkeyAdapterOptions ¶
func DefaultShardedValkeyAdapterOptions() *ShardedValkeyAdapterOptions
DefaultShardedValkeyAdapterOptions returns a new ShardedValkeyAdapterOptions with default values.
func (*ShardedValkeyAdapterOptions) Assign ¶
func (s *ShardedValkeyAdapterOptions) Assign(data ShardedValkeyAdapterOptionsInterface) ShardedValkeyAdapterOptionsInterface
Assign copies non-nil fields from another ShardedValkeyAdapterOptionsInterface.
func (*ShardedValkeyAdapterOptions) ChannelPrefix ¶
func (s *ShardedValkeyAdapterOptions) ChannelPrefix() string
func (*ShardedValkeyAdapterOptions) GetRawChannelPrefix ¶
func (s *ShardedValkeyAdapterOptions) GetRawChannelPrefix() types.Optional[string]
func (*ShardedValkeyAdapterOptions) GetRawSubscriptionMode ¶
func (s *ShardedValkeyAdapterOptions) GetRawSubscriptionMode() types.Optional[valkey.SubscriptionMode]
func (*ShardedValkeyAdapterOptions) SetChannelPrefix ¶
func (s *ShardedValkeyAdapterOptions) SetChannelPrefix(v string)
func (*ShardedValkeyAdapterOptions) SetSubscriptionMode ¶
func (s *ShardedValkeyAdapterOptions) SetSubscriptionMode(v valkey.SubscriptionMode)
func (*ShardedValkeyAdapterOptions) SubscriptionMode ¶
func (s *ShardedValkeyAdapterOptions) SubscriptionMode() valkey.SubscriptionMode
type ShardedValkeyAdapterOptionsInterface ¶
type ShardedValkeyAdapterOptionsInterface interface {
SetChannelPrefix(string)
GetRawChannelPrefix() types.Optional[string]
ChannelPrefix() string
SetSubscriptionMode(valkey.SubscriptionMode)
GetRawSubscriptionMode() types.Optional[valkey.SubscriptionMode]
SubscriptionMode() valkey.SubscriptionMode
}
ShardedValkeyAdapterOptionsInterface defines the interface for configuring ShardedValkeyAdapterOptions.
type ValkeyAdapter ¶
type ValkeyAdapter interface {
socket.Adapter
SetValkey(*valkey.ValkeyClient)
SetOpts(any)
Uid() adapter.ServerId
RequestsTimeout() time.Duration
PublishOnSpecificResponseChannel() bool
Parser() valkey.Parser
AllRooms() func(func(*types.Set[socket.Room], error))
}
ValkeyAdapter defines the interface for a Valkey-based Socket.IO adapter.
func MakeValkeyAdapter ¶
func MakeValkeyAdapter() ValkeyAdapter
MakeValkeyAdapter creates a new uninitialized valkeyAdapter with default options.
func NewValkeyAdapter ¶
func NewValkeyAdapter(nsp socket.Namespace, valkeyClient *valkey.ValkeyClient, opts any) ValkeyAdapter
NewValkeyAdapter creates and initializes a new ValkeyAdapter for the given namespace.
type ValkeyAdapterBuilder ¶
type ValkeyAdapterBuilder struct {
// Valkey is the Valkey client used by the adapter for Pub/Sub communication.
Valkey *valkey.ValkeyClient
// Opts contains configuration options for the adapter.
Opts ValkeyAdapterOptionsInterface
}
ValkeyAdapterBuilder builds a ValkeyAdapter with the given Valkey client and options.
type ValkeyAdapterOptions ¶
type ValkeyAdapterOptions struct {
emitter.EmitterOptions
// contains filtered or unexported fields
}
ValkeyAdapterOptions holds configuration for the Valkey adapter.
Fields:
- requestsTimeout: Maximum time to wait for responses to inter-node requests. Default: 5000ms.
- publishOnSpecificResponseChannel: When true, responses are published to a channel specific to the requesting node.
func DefaultValkeyAdapterOptions ¶
func DefaultValkeyAdapterOptions() *ValkeyAdapterOptions
DefaultValkeyAdapterOptions returns a new ValkeyAdapterOptions with default values.
func (*ValkeyAdapterOptions) Assign ¶
func (s *ValkeyAdapterOptions) Assign(data ValkeyAdapterOptionsInterface) ValkeyAdapterOptionsInterface
Assign copies non-nil fields from another ValkeyAdapterOptionsInterface.
func (*ValkeyAdapterOptions) GetRawPublishOnSpecificResponseChannel ¶
func (s *ValkeyAdapterOptions) GetRawPublishOnSpecificResponseChannel() types.Optional[bool]
GetRawPublishOnSpecificResponseChannel returns the raw Optional value.
func (*ValkeyAdapterOptions) GetRawRequestsTimeout ¶
func (s *ValkeyAdapterOptions) GetRawRequestsTimeout() types.Optional[time.Duration]
GetRawRequestsTimeout returns the raw Optional value for requestsTimeout.
func (*ValkeyAdapterOptions) PublishOnSpecificResponseChannel ¶
func (s *ValkeyAdapterOptions) PublishOnSpecificResponseChannel() bool
PublishOnSpecificResponseChannel returns whether responses are published to node-specific channels.
func (*ValkeyAdapterOptions) RequestsTimeout ¶
func (s *ValkeyAdapterOptions) RequestsTimeout() time.Duration
RequestsTimeout returns the configured requests timeout.
func (*ValkeyAdapterOptions) SetPublishOnSpecificResponseChannel ¶
func (s *ValkeyAdapterOptions) SetPublishOnSpecificResponseChannel(v bool)
SetPublishOnSpecificResponseChannel sets whether responses are published to node-specific channels.
func (*ValkeyAdapterOptions) SetRequestsTimeout ¶
func (s *ValkeyAdapterOptions) SetRequestsTimeout(requestsTimeout time.Duration)
SetRequestsTimeout sets the timeout duration for inter-node requests.
type ValkeyAdapterOptionsInterface ¶
type ValkeyAdapterOptionsInterface interface {
emitter.EmitterOptionsInterface
SetRequestsTimeout(time.Duration)
GetRawRequestsTimeout() types.Optional[time.Duration]
RequestsTimeout() time.Duration
SetPublishOnSpecificResponseChannel(bool)
GetRawPublishOnSpecificResponseChannel() types.Optional[bool]
PublishOnSpecificResponseChannel() bool
}
ValkeyAdapterOptionsInterface defines the interface for configuring ValkeyAdapterOptions.
type ValkeyRequest ¶
type ValkeyRequest struct {
Type adapter.MessageType
Resolve func(*types.Slice[any])
Timeout *atomic.Pointer[utils.Timer]
NumSub int64
MsgCount *atomic.Int64
Rooms *types.Set[socket.Room]
Sockets *types.Slice[*adapter.SocketResponse]
Responses *types.Slice[any]
// Once ensures that the Resolve callback and cleanup are executed exactly once,
// preventing double invocations from both normal completion and timeout paths.
Once sync.Once
}
ValkeyRequest represents an internal request tracker with state management.
type ValkeyStreamsAdapter ¶
type ValkeyStreamsAdapter interface {
adapter.ClusterAdapter
SetValkey(*valkey.ValkeyClient)
SetOpts(any)
Cleanup(func())
OnRawMessage(RawClusterMessage, string) error
}
ValkeyStreamsAdapter defines the interface for a Valkey Streams-based Socket.IO adapter.
func MakeValkeyStreamsAdapter ¶
func MakeValkeyStreamsAdapter() ValkeyStreamsAdapter
MakeValkeyStreamsAdapter creates a new uninitialized valkeyStreamsAdapter.
func NewValkeyStreamsAdapter ¶
func NewValkeyStreamsAdapter(nsp socket.Namespace, client *valkey.ValkeyClient, opts any) ValkeyStreamsAdapter
NewValkeyStreamsAdapter creates and initializes a new Valkey Streams adapter.
type ValkeyStreamsAdapterBuilder ¶
type ValkeyStreamsAdapterBuilder struct {
// Valkey is the Valkey client used for stream operations.
Valkey *valkey.ValkeyClient
// Opts contains configuration options for the streams adapter.
Opts ValkeyStreamsAdapterOptionsInterface
// contains filtered or unexported fields
}
ValkeyStreamsAdapterBuilder creates Valkey Streams adapters for Socket.IO namespaces.
type ValkeyStreamsAdapterOptions ¶
type ValkeyStreamsAdapterOptions struct {
adapter.ClusterAdapterOptions
// contains filtered or unexported fields
}
ValkeyStreamsAdapterOptions holds configuration for the Valkey Streams adapter.
func DefaultValkeyStreamsAdapterOptions ¶
func DefaultValkeyStreamsAdapterOptions() *ValkeyStreamsAdapterOptions
DefaultValkeyStreamsAdapterOptions returns a new ValkeyStreamsAdapterOptions with default values.
func (*ValkeyStreamsAdapterOptions) Assign ¶
func (s *ValkeyStreamsAdapterOptions) Assign(data ValkeyStreamsAdapterOptionsInterface) ValkeyStreamsAdapterOptionsInterface
Assign copies non-nil fields from another ValkeyStreamsAdapterOptionsInterface.
func (*ValkeyStreamsAdapterOptions) BlockTimeInMs ¶
func (s *ValkeyStreamsAdapterOptions) BlockTimeInMs() int64
func (*ValkeyStreamsAdapterOptions) ChannelPrefix ¶
func (s *ValkeyStreamsAdapterOptions) ChannelPrefix() string
func (*ValkeyStreamsAdapterOptions) GetRawBlockTimeInMs ¶
func (s *ValkeyStreamsAdapterOptions) GetRawBlockTimeInMs() types.Optional[int64]
func (*ValkeyStreamsAdapterOptions) GetRawChannelPrefix ¶
func (s *ValkeyStreamsAdapterOptions) GetRawChannelPrefix() types.Optional[string]
func (*ValkeyStreamsAdapterOptions) GetRawMaxLen ¶
func (s *ValkeyStreamsAdapterOptions) GetRawMaxLen() types.Optional[int64]
func (*ValkeyStreamsAdapterOptions) GetRawOnlyPlaintext ¶
func (s *ValkeyStreamsAdapterOptions) GetRawOnlyPlaintext() types.Optional[bool]
func (*ValkeyStreamsAdapterOptions) GetRawReadCount ¶
func (s *ValkeyStreamsAdapterOptions) GetRawReadCount() types.Optional[int64]
func (*ValkeyStreamsAdapterOptions) GetRawSessionKeyPrefix ¶
func (s *ValkeyStreamsAdapterOptions) GetRawSessionKeyPrefix() types.Optional[string]
func (*ValkeyStreamsAdapterOptions) GetRawStreamCount ¶
func (s *ValkeyStreamsAdapterOptions) GetRawStreamCount() types.Optional[int]
func (*ValkeyStreamsAdapterOptions) GetRawStreamName ¶
func (s *ValkeyStreamsAdapterOptions) GetRawStreamName() types.Optional[string]
func (*ValkeyStreamsAdapterOptions) GetRawUseShardedPubSub ¶
func (s *ValkeyStreamsAdapterOptions) GetRawUseShardedPubSub() types.Optional[bool]
func (*ValkeyStreamsAdapterOptions) MaxLen ¶
func (s *ValkeyStreamsAdapterOptions) MaxLen() int64
func (*ValkeyStreamsAdapterOptions) OnlyPlaintext ¶
func (s *ValkeyStreamsAdapterOptions) OnlyPlaintext() bool
func (*ValkeyStreamsAdapterOptions) ReadCount ¶
func (s *ValkeyStreamsAdapterOptions) ReadCount() int64
func (*ValkeyStreamsAdapterOptions) SessionKeyPrefix ¶
func (s *ValkeyStreamsAdapterOptions) SessionKeyPrefix() string
func (*ValkeyStreamsAdapterOptions) SetBlockTimeInMs ¶
func (s *ValkeyStreamsAdapterOptions) SetBlockTimeInMs(v int64)
func (*ValkeyStreamsAdapterOptions) SetChannelPrefix ¶
func (s *ValkeyStreamsAdapterOptions) SetChannelPrefix(v string)
func (*ValkeyStreamsAdapterOptions) SetMaxLen ¶
func (s *ValkeyStreamsAdapterOptions) SetMaxLen(v int64)
func (*ValkeyStreamsAdapterOptions) SetOnlyPlaintext ¶
func (s *ValkeyStreamsAdapterOptions) SetOnlyPlaintext(v bool)
func (*ValkeyStreamsAdapterOptions) SetReadCount ¶
func (s *ValkeyStreamsAdapterOptions) SetReadCount(v int64)
func (*ValkeyStreamsAdapterOptions) SetSessionKeyPrefix ¶
func (s *ValkeyStreamsAdapterOptions) SetSessionKeyPrefix(v string)
func (*ValkeyStreamsAdapterOptions) SetStreamCount ¶
func (s *ValkeyStreamsAdapterOptions) SetStreamCount(v int)
func (*ValkeyStreamsAdapterOptions) SetStreamName ¶
func (s *ValkeyStreamsAdapterOptions) SetStreamName(v string)
func (*ValkeyStreamsAdapterOptions) SetUseShardedPubSub ¶
func (s *ValkeyStreamsAdapterOptions) SetUseShardedPubSub(v bool)
func (*ValkeyStreamsAdapterOptions) StreamCount ¶
func (s *ValkeyStreamsAdapterOptions) StreamCount() int
func (*ValkeyStreamsAdapterOptions) StreamName ¶
func (s *ValkeyStreamsAdapterOptions) StreamName() string
func (*ValkeyStreamsAdapterOptions) UseShardedPubSub ¶
func (s *ValkeyStreamsAdapterOptions) UseShardedPubSub() bool
type ValkeyStreamsAdapterOptionsInterface ¶
type ValkeyStreamsAdapterOptionsInterface interface {
adapter.ClusterAdapterOptionsInterface
SetStreamName(string)
GetRawStreamName() types.Optional[string]
StreamName() string
SetStreamCount(int)
GetRawStreamCount() types.Optional[int]
StreamCount() int
SetChannelPrefix(string)
GetRawChannelPrefix() types.Optional[string]
ChannelPrefix() string
SetUseShardedPubSub(bool)
GetRawUseShardedPubSub() types.Optional[bool]
UseShardedPubSub() bool
SetMaxLen(int64)
GetRawMaxLen() types.Optional[int64]
MaxLen() int64
SetReadCount(int64)
GetRawReadCount() types.Optional[int64]
ReadCount() int64
SetBlockTimeInMs(int64)
GetRawBlockTimeInMs() types.Optional[int64]
BlockTimeInMs() int64
SetSessionKeyPrefix(string)
GetRawSessionKeyPrefix() types.Optional[string]
SessionKeyPrefix() string
SetOnlyPlaintext(bool)
GetRawOnlyPlaintext() types.Optional[bool]
OnlyPlaintext() bool
}
ValkeyStreamsAdapterOptionsInterface defines the interface for configuring ValkeyStreamsAdapterOptions.