Documentation
¶
Index ¶
- Constants
- Variables
- func NewExtension(opts ...ConfigOption) forge.Extension
- func NewExtensionWithConfig(config Config) forge.Extension
- func NewLocalRoom(opts RoomOptions) *local.LocalRoom
- func NewSSEConnection(stream forge.Stream, remoteAddr, localAddr string) forge.Connection
- type ActivityInfo
- type AnalyticsEvent
- type AnalyticsQuery
- type AnalyticsResult
- type Availability
- type BackendError
- type BinaryCodec
- type Channel
- type ChannelStore
- type Codec
- type CodecRegistry
- func (r *CodecRegistry) Decode(data []byte, msg *streaming.Message) error
- func (r *CodecRegistry) DecodeWithType(contentType string, data []byte, msg *streaming.Message) error
- func (r *CodecRegistry) Default() Codec
- func (r *CodecRegistry) Encode(msg *streaming.Message) ([]byte, error)
- func (r *CodecRegistry) Get(contentType string) (Codec, bool)
- func (r *CodecRegistry) Register(codec Codec)
- func (r *CodecRegistry) SetDefault(contentType string) error
- type Config
- type ConfigOption
- func WithAuthentication(username, password string) ConfigOption
- func WithBackend(backend string) ConfigOption
- func WithBackendURLs(urls ...string) ConfigOption
- func WithBufferSizes(read, write int) ConfigOption
- func WithConfig(config Config) ConfigOption
- func WithConnectionLimits(perUser, roomsPerUser, channelsPerUser int) ConfigOption
- func WithFeatures(rooms, channels, presence, typing, history bool) ConfigOption
- func WithLocalBackend() ConfigOption
- func WithMessageLimits(maxSize, maxPerSecond int) ConfigOption
- func WithMessageRetention(retention time.Duration) ConfigOption
- func WithNATSBackend(urls ...string) ConfigOption
- func WithNodeID(nodeID string) ConfigOption
- func WithPresenceTimeout(timeout time.Duration) ConfigOption
- func WithRedisBackend(url string) ConfigOption
- func WithRequireConfig(require bool) ConfigOption
- func WithTLS(certFile, keyFile, caFile string) ConfigOption
- func WithTimeouts(ping, pong, write time.Duration) ConfigOption
- func WithTypingTimeout(timeout time.Duration) ConfigOption
- type Connection
- type ConnectionHook
- type ConnectionInfo
- type DeviceInfo
- type DistributedBackend
- type DistributedBackendOptions
- type ErrorHook
- type Extension
- func (e *Extension) AsyncAPISpec() *forge.AsyncAPISpec
- func (e *Extension) Codecs() *CodecRegistry
- func (e *Extension) DashboardContributor() contributor.LocalContributor
- func (e *Extension) Health(ctx context.Context) error
- func (e *Extension) Hooks() *HookRegistry
- func (e *Extension) Manager() Manager
- func (e *Extension) Register(app forge.App) error
- func (e *Extension) RegisterCodec(codec Codec)
- func (e *Extension) RegisterDashboardBridge(b *bridge.Bridge) error
- func (e *Extension) RegisterHook(hook StreamingHook)
- func (e *Extension) RegisterRoutes(router forge.Router, wsPath, ssePath string) error
- func (e *Extension) Start(ctx context.Context) error
- func (e *Extension) Stop(ctx context.Context) error
- func (e *Extension) UnregisterHook(name string)
- type FileInfo
- type FileQuery
- type FileUpload
- type HistoryQuery
- type HookRegistry
- func (r *HookRegistry) Add(hook StreamingHook)
- func (r *HookRegistry) FireOnConnect(ctx context.Context, conn streaming.EnhancedConnection) error
- func (r *HookRegistry) FireOnDisconnect(ctx context.Context, conn streaming.EnhancedConnection)
- func (r *HookRegistry) FireOnError(ctx context.Context, conn streaming.EnhancedConnection, err error)
- func (r *HookRegistry) FireOnMessageDelivered(ctx context.Context, conn streaming.EnhancedConnection, msg *streaming.Message)
- func (r *HookRegistry) FireOnMessageReceived(ctx context.Context, conn streaming.EnhancedConnection, msg *streaming.Message) (*streaming.Message, error)
- func (r *HookRegistry) FireOnPresenceChange(ctx context.Context, userID, oldStatus, newStatus string)
- func (r *HookRegistry) FireOnRawMessage(ctx context.Context, conn streaming.EnhancedConnection, data []byte) ([]byte, error)
- func (r *HookRegistry) FireOnRoomCreate(ctx context.Context, room streaming.Room) error
- func (r *HookRegistry) FireOnRoomDelete(ctx context.Context, roomID string)
- func (r *HookRegistry) FireOnRoomJoin(ctx context.Context, conn streaming.EnhancedConnection, roomID string) error
- func (r *HookRegistry) FireOnRoomLeave(ctx context.Context, conn streaming.EnhancedConnection, roomID string)
- func (r *HookRegistry) List() []StreamingHook
- func (r *HookRegistry) Remove(name string)
- type Invite
- type InviteOptions
- type JSONCodec
- type LocalRoom
- type Lock
- type Manager
- type ManagerOption
- func WithCodecRegistry(cr *CodecRegistry) ManagerOption
- func WithCoordinator(c coordinator.StreamCoordinator) ManagerOption
- func WithFilterChain(fc filters.FilterChain) ManagerOption
- func WithHookRegistry(hr *HookRegistry) ManagerOption
- func WithManagerHealthChecker(hc lb.HealthChecker) ManagerOption
- func WithManagerLoadBalancer(l lb.LoadBalancer) ManagerOption
- func WithManagerNodeID(id string) ManagerOption
- func WithRateLimiter(rl ratelimit.RateLimiter) ManagerOption
- func WithSessionStore(ss SessionStore) ManagerOption
- func WithValidator(v validation.MessageValidator) ManagerOption
- type ManagerStats
- type Member
- type MemberOptions
- type Message
- type MessageEdit
- type MessageHandler
- type MessageHook
- type MessageReaction
- type MessageSearchQuery
- type MessageStore
- type ModerationEvent
- type ModerationStatus
- type NodeChangeEvent
- type NodeChangeHandler
- type NodeInfo
- type OnlineStats
- type PresenceEvent
- type PresenceFilters
- type PresenceHook
- type PresenceOptions
- type PresenceStore
- type PresenceTracker
- type RateLimitStatus
- type RawMessageHook
- type Room
- type RoomBan
- type RoomEvent
- type RoomHook
- type RoomOptions
- type RoomStats
- type RoomStore
- type SessionSnapshot
- type SessionStore
- type StreamingHook
- type TextCodec
- type TypingOptions
- type TypingStore
- type TypingTracker
- type UserPresence
- type UserPresenceStats
- type UserStats
- type WebhookConfig
Constants ¶
const ( TransportWebSocket = "websocket" TransportSSE = "sse" )
Transport type constants.
const ContentTypeBinary = internal.ContentTypeBinary
const ContentTypeJSON = internal.ContentTypeJSON
Content type constants.
const ContentTypeMsgPack = internal.ContentTypeMsgPack
const ContentTypeProtobuf = internal.ContentTypeProtobuf
const ContentTypeText = internal.ContentTypeText
const (
// ManagerKey is the DI key for the streaming manager.
ManagerKey = "streaming"
)
DI container keys for streaming extension services.
const MessageTypeJoin = internal.MessageTypeJoin
const MessageTypeLeave = internal.MessageTypeLeave
const MessageTypeMessage = internal.MessageTypeMessage
Message type constants.
const MessageTypePresence = internal.MessageTypePresence
const MessageTypeTyping = internal.MessageTypeTyping
const StatusAway = internal.StatusAway
const StatusBusy = internal.StatusBusy
const StatusOffline = internal.StatusOffline
const StatusOnline = internal.StatusOnline
Status constants.
Variables ¶
var DefaultPresenceOptions = internal.DefaultPresenceOptions
Default option functions.
var DefaultTypingOptions = internal.DefaultTypingOptions
var ErrAlreadyRoomMember = internal.ErrAlreadyRoomMember
var ErrAlreadySubscribed = internal.ErrAlreadySubscribed
var ErrBackendNotFound = internal.ErrBackendNotConnected
var ErrBackendTimeout = internal.ErrBackendTimeout
var ErrChannelAlreadyExists = internal.ErrChannelAlreadyExists
var ErrChannelNotFound = internal.ErrChannelNotFound
Channel errors.
var ErrConnectionClosed = internal.ErrConnectionClosed
var ErrConnectionLimitReached = internal.ErrConnectionLimitReached
var ErrConnectionNotFound = internal.ErrConnectionNotFound
Connection errors.
var ErrInsufficientRole = internal.ErrInsufficientRole
var ErrInvalidChannel = internal.ErrInvalidChannel
var ErrInvalidConfig = internal.ErrInvalidConfig
var ErrInvalidConnection = internal.ErrInvalidConnection
var ErrInvalidMessage = internal.ErrInvalidMessage
var ErrInvalidPermission = internal.ErrInvalidPermission
var ErrInvalidRoom = internal.ErrInvalidRoom
var ErrInvalidStatus = internal.ErrInvalidStatus
var ErrInviteExpired = internal.ErrInviteExpired
var ErrInviteNotFound = internal.ErrInviteNotFound
Invite errors.
var ErrLockAcquisitionFailed = internal.ErrLockAcquisitionFailed
var ErrLockNotHeld = internal.ErrLockNotHeld
var ErrMessageNotFound = internal.ErrMessageNotFound
var ErrMessageTooLarge = internal.ErrMessageTooLarge
var ErrNodeNotFound = internal.ErrNodeNotFound
var ErrNotRoomMember = internal.ErrNotRoomMember
var ErrNotSubscribed = internal.ErrNotSubscribed
var ErrPermissionDenied = internal.ErrPermissionDenied
Permission errors.
var ErrPresenceNotFound = internal.ErrPresenceNotFound
var ErrRoomAlreadyExists = internal.ErrRoomAlreadyExists
var ErrRoomFull = internal.ErrRoomFull
var ErrRoomLimitReached = internal.ErrRoomLimitReached
var ErrRoomNotFound = internal.ErrRoomNotFound
Room errors.
var NewBackendError = internal.NewBackendError
var NewChannelError = internal.NewChannelError
var NewConnectionError = internal.NewConnectionError
Error constructors.
var NewMessageError = internal.NewMessageError
var NewRoomError = internal.NewRoomError
Functions ¶
func NewExtension ¶
func NewExtension(opts ...ConfigOption) forge.Extension
NewExtension creates a new streaming extension with functional options.
func NewExtensionWithConfig ¶
NewExtensionWithConfig creates a new streaming extension with a complete config.
func NewSSEConnection ¶ added in v0.10.0
func NewSSEConnection(stream forge.Stream, remoteAddr, localAddr string) forge.Connection
NewSSEConnection creates a new SSE connection adapter.
Types ¶
type ActivityInfo ¶
type ActivityInfo = internal.ActivityInfo
type AnalyticsEvent ¶
type AnalyticsEvent = internal.AnalyticsEvent
type AnalyticsQuery ¶
type AnalyticsQuery = internal.AnalyticsQuery
type Availability ¶
type Availability = internal.Availability
type BinaryCodec ¶ added in v1.3.0
type BinaryCodec struct{}
BinaryCodec handles raw binary data. On decode, it stores the raw bytes in msg.RawData and sets the content type. On encode, it returns msg.RawData directly.
func (*BinaryCodec) ContentType ¶ added in v1.3.0
func (c *BinaryCodec) ContentType() string
type ChannelStore ¶
type ChannelStore = internal.ChannelStore
type Codec ¶ added in v1.3.0
type Codec interface {
// ContentType returns the MIME type this codec handles (e.g. "application/json").
ContentType() string
// Encode serializes a message to bytes.
Encode(msg *streaming.Message) ([]byte, error)
// Decode deserializes bytes into a message.
Decode(data []byte, msg *streaming.Message) error
}
Codec handles encoding and decoding messages for a specific content type.
type CodecRegistry ¶ added in v1.3.0
type CodecRegistry struct {
// contains filtered or unexported fields
}
CodecRegistry manages codecs by content type and provides encode/decode dispatch based on message content type.
func NewCodecRegistry ¶ added in v1.3.0
func NewCodecRegistry() *CodecRegistry
NewCodecRegistry creates a new codec registry pre-loaded with a JSON codec as default.
func (*CodecRegistry) Decode ¶ added in v1.3.0
func (r *CodecRegistry) Decode(data []byte, msg *streaming.Message) error
Decode deserializes bytes into a message using the default codec. If decoding fails with the default codec, it returns the error.
func (*CodecRegistry) DecodeWithType ¶ added in v1.3.0
func (r *CodecRegistry) DecodeWithType(contentType string, data []byte, msg *streaming.Message) error
DecodeWithType deserializes bytes into a message using the codec for the given content type.
func (*CodecRegistry) Default ¶ added in v1.3.0
func (r *CodecRegistry) Default() Codec
Default returns the default codec (JSON).
func (*CodecRegistry) Encode ¶ added in v1.3.0
func (r *CodecRegistry) Encode(msg *streaming.Message) ([]byte, error)
Encode serializes a message using the codec matching msg.ContentType, or the default codec if ContentType is empty.
func (*CodecRegistry) Get ¶ added in v1.3.0
func (r *CodecRegistry) Get(contentType string) (Codec, bool)
Get returns the codec for the given content type.
func (*CodecRegistry) Register ¶ added in v1.3.0
func (r *CodecRegistry) Register(codec Codec)
Register adds a codec. If a codec for the same content type already exists, it is replaced.
func (*CodecRegistry) SetDefault ¶ added in v1.3.0
func (r *CodecRegistry) SetDefault(contentType string) error
SetDefault changes the default codec to the one registered for the given content type.
type ConfigOption ¶
type ConfigOption = internal.ConfigOption
func WithAuthentication ¶
func WithAuthentication(username, password string) ConfigOption
func WithBackend ¶
func WithBackend(backend string) ConfigOption
func WithBackendURLs ¶
func WithBackendURLs(urls ...string) ConfigOption
func WithBufferSizes ¶
func WithBufferSizes(read, write int) ConfigOption
func WithConfig ¶
func WithConfig(config Config) ConfigOption
func WithConnectionLimits ¶
func WithConnectionLimits(perUser, roomsPerUser, channelsPerUser int) ConfigOption
func WithFeatures ¶
func WithFeatures(rooms, channels, presence, typing, history bool) ConfigOption
func WithLocalBackend ¶
func WithLocalBackend() ConfigOption
func WithMessageLimits ¶
func WithMessageLimits(maxSize, maxPerSecond int) ConfigOption
func WithMessageRetention ¶
func WithMessageRetention(retention time.Duration) ConfigOption
func WithNATSBackend ¶
func WithNATSBackend(urls ...string) ConfigOption
func WithNodeID ¶
func WithNodeID(nodeID string) ConfigOption
func WithPresenceTimeout ¶
func WithPresenceTimeout(timeout time.Duration) ConfigOption
func WithRedisBackend ¶
func WithRedisBackend(url string) ConfigOption
func WithRequireConfig ¶
func WithRequireConfig(require bool) ConfigOption
func WithTLS ¶
func WithTLS(certFile, keyFile, caFile string) ConfigOption
func WithTimeouts ¶
func WithTimeouts(ping, pong, write time.Duration) ConfigOption
func WithTypingTimeout ¶
func WithTypingTimeout(timeout time.Duration) ConfigOption
type Connection ¶
type Connection = internal.EnhancedConnection
func NewConnection ¶
func NewConnection(conn forge.Connection) Connection
NewConnection creates a new enhanced connection with default transport "websocket".
func NewConnectionWithTransport ¶ added in v1.3.0
func NewConnectionWithTransport(conn forge.Connection, transport string) Connection
NewConnectionWithTransport creates a new enhanced connection with a specified transport type.
type ConnectionHook ¶ added in v1.3.0
type ConnectionHook interface {
StreamingHook
// OnConnect is called before registration. Return error to reject connection.
OnConnect(ctx context.Context, conn Connection) error
// OnDisconnect is called after unregistration.
OnDisconnect(ctx context.Context, conn Connection)
}
ConnectionHook fires on connection lifecycle events.
type DeviceInfo ¶
type DeviceInfo = internal.DeviceInfo
type DistributedBackend ¶
type DistributedBackend = internal.DistributedBackend
Distributed backend.
type DistributedBackendOptions ¶
type DistributedBackendOptions = internal.DistributedBackendOptions
type ErrorHook ¶ added in v1.3.0
type ErrorHook interface {
StreamingHook
// OnError is called when a message handling error occurs.
OnError(ctx context.Context, conn Connection, err error)
}
ErrorHook fires on message handling errors.
type Extension ¶
type Extension struct {
*forge.BaseExtension
// contains filtered or unexported fields
}
Extension implements forge.Extension for streaming functionality.
func (*Extension) AsyncAPISpec ¶
func (e *Extension) AsyncAPISpec() *forge.AsyncAPISpec
AsyncAPISpec generates AsyncAPI 3.0.0 specification for the streaming extension This documents all streaming channels, operations, and message types.
func (*Extension) Codecs ¶ added in v1.3.0
func (e *Extension) Codecs() *CodecRegistry
Codecs returns the codec registry for direct access.
func (*Extension) DashboardContributor ¶ added in v1.3.0
func (e *Extension) DashboardContributor() contributor.LocalContributor
DashboardContributor implements dashboard.DashboardAware. Returns a streaming dashboard contributor for auto-registration. Uses resolver closures so the manager/config are resolved at render time, not at discovery time (when they may not yet be initialized).
func (*Extension) Hooks ¶ added in v1.3.0
func (e *Extension) Hooks() *HookRegistry
Hooks returns the hook registry for direct access.
func (*Extension) RegisterCodec ¶ added in v1.3.0
RegisterCodec adds a message codec for a specific content type.
func (*Extension) RegisterDashboardBridge ¶ added in v1.3.0
RegisterDashboardBridge implements dashboard.BridgeAware. Registers streaming bridge functions for Go↔JS communication. Uses resolver closures so the manager/config are resolved at request time.
func (*Extension) RegisterHook ¶ added in v1.3.0
func (e *Extension) RegisterHook(hook StreamingHook)
RegisterHook adds a streaming hook for lifecycle events. Hooks can implement one or more hook interfaces (ConnectionHook, MessageHook, RawMessageHook, RoomHook, PresenceHook, ErrorHook).
func (*Extension) RegisterRoutes ¶
RegisterRoutes is a helper to register WebSocket and SSE routes with the router.
func (*Extension) UnregisterHook ¶ added in v1.3.0
UnregisterHook removes a streaming hook by name.
type HookRegistry ¶ added in v1.3.0
type HookRegistry struct {
// contains filtered or unexported fields
}
HookRegistry manages streaming hooks and dispatches events.
func NewHookRegistry ¶ added in v1.3.0
func NewHookRegistry() *HookRegistry
NewHookRegistry creates a new hook registry.
func (*HookRegistry) Add ¶ added in v1.3.0
func (r *HookRegistry) Add(hook StreamingHook)
Add registers a hook. The hook is type-asserted to categorize it into the appropriate dispatch lists.
func (*HookRegistry) FireOnConnect ¶ added in v1.3.0
func (r *HookRegistry) FireOnConnect(ctx context.Context, conn streaming.EnhancedConnection) error
FireOnConnect fires ConnectionHook.OnConnect for all registered hooks. Returns the first error encountered, which should be used to reject the connection.
func (*HookRegistry) FireOnDisconnect ¶ added in v1.3.0
func (r *HookRegistry) FireOnDisconnect(ctx context.Context, conn streaming.EnhancedConnection)
FireOnDisconnect fires ConnectionHook.OnDisconnect for all registered hooks. Errors are ignored (post-hook).
func (*HookRegistry) FireOnError ¶ added in v1.3.0
func (r *HookRegistry) FireOnError(ctx context.Context, conn streaming.EnhancedConnection, err error)
FireOnError fires ErrorHook.OnError for all hooks (post-hook).
func (*HookRegistry) FireOnMessageDelivered ¶ added in v1.3.0
func (r *HookRegistry) FireOnMessageDelivered(ctx context.Context, conn streaming.EnhancedConnection, msg *streaming.Message)
FireOnMessageDelivered fires MessageHook.OnMessageDelivered asynchronously. This is non-blocking to avoid slowing down message delivery.
func (*HookRegistry) FireOnMessageReceived ¶ added in v1.3.0
func (r *HookRegistry) FireOnMessageReceived(ctx context.Context, conn streaming.EnhancedConnection, msg *streaming.Message) (*streaming.Message, error)
FireOnMessageReceived fires MessageHook.OnMessageReceived for all hooks in sequence. Each hook can transform or block (return nil) the message.
func (*HookRegistry) FireOnPresenceChange ¶ added in v1.3.0
func (r *HookRegistry) FireOnPresenceChange(ctx context.Context, userID, oldStatus, newStatus string)
FireOnPresenceChange fires PresenceHook.OnPresenceChange for all hooks (post-hook).
func (*HookRegistry) FireOnRawMessage ¶ added in v1.3.0
func (r *HookRegistry) FireOnRawMessage(ctx context.Context, conn streaming.EnhancedConnection, data []byte) ([]byte, error)
FireOnRawMessage fires RawMessageHook.OnRawMessage for all hooks in sequence. Each hook can transform the bytes or block (return error) the message.
func (*HookRegistry) FireOnRoomCreate ¶ added in v1.3.0
FireOnRoomCreate fires RoomHook.OnRoomCreate for all hooks. Returns the first error encountered, which should be used to reject creation.
func (*HookRegistry) FireOnRoomDelete ¶ added in v1.3.0
func (r *HookRegistry) FireOnRoomDelete(ctx context.Context, roomID string)
FireOnRoomDelete fires RoomHook.OnRoomDelete for all hooks (post-hook).
func (*HookRegistry) FireOnRoomJoin ¶ added in v1.3.0
func (r *HookRegistry) FireOnRoomJoin(ctx context.Context, conn streaming.EnhancedConnection, roomID string) error
FireOnRoomJoin fires RoomHook.OnRoomJoin for all hooks. Returns the first error encountered, which should be used to reject the join.
func (*HookRegistry) FireOnRoomLeave ¶ added in v1.3.0
func (r *HookRegistry) FireOnRoomLeave(ctx context.Context, conn streaming.EnhancedConnection, roomID string)
FireOnRoomLeave fires RoomHook.OnRoomLeave for all hooks (post-hook).
func (*HookRegistry) List ¶ added in v1.3.0
func (r *HookRegistry) List() []StreamingHook
List returns all registered hooks.
func (*HookRegistry) Remove ¶ added in v1.3.0
func (r *HookRegistry) Remove(name string)
Remove unregisters a hook by name.
type InviteOptions ¶
type InviteOptions = internal.InviteOptions
type JSONCodec ¶ added in v1.3.0
type JSONCodec struct{}
JSONCodec encodes/decodes messages as JSON. This is the default codec.
func (*JSONCodec) ContentType ¶ added in v1.3.0
type Manager ¶
Core interfaces.
func GetManager ¶
GetManager retrieves the streaming Manager from the container. Returns error if not found or type assertion fails.
func GetManagerFromApp ¶
GetManagerFromApp retrieves the streaming Manager from the app. Returns error if not found or type assertion fails.
func MustGetManager ¶
MustGetManager retrieves the streaming Manager from the container. Panics if not found or type assertion fails.
func MustGetManagerFromApp ¶
MustGetManagerFromApp retrieves the streaming Manager from the app. Panics if not found or type assertion fails.
func NewManager ¶
func NewManager( config Config, roomStore RoomStore, channelStore ChannelStore, messageStore MessageStore, presenceTracker PresenceTracker, typingTracker TypingTracker, distributed DistributedBackend, logger forge.Logger, metrics forge.Metrics, opts ...ManagerOption, ) Manager
NewManager creates a new streaming manager.
type ManagerOption ¶ added in v0.10.0
type ManagerOption func(*manager)
ManagerOption configures the manager.
func WithCodecRegistry ¶ added in v1.3.0
func WithCodecRegistry(cr *CodecRegistry) ManagerOption
WithCodecRegistry sets the codec registry for message encoding/decoding.
func WithCoordinator ¶ added in v0.10.0
func WithCoordinator(c coordinator.StreamCoordinator) ManagerOption
WithCoordinator sets the distributed coordinator.
func WithFilterChain ¶ added in v0.10.0
func WithFilterChain(fc filters.FilterChain) ManagerOption
WithFilterChain sets the message filter chain.
func WithHookRegistry ¶ added in v1.3.0
func WithHookRegistry(hr *HookRegistry) ManagerOption
WithHookRegistry sets the hook registry for lifecycle hooks.
func WithManagerHealthChecker ¶ added in v0.10.0
func WithManagerHealthChecker(hc lb.HealthChecker) ManagerOption
WithManagerHealthChecker sets the health checker.
func WithManagerLoadBalancer ¶ added in v0.10.0
func WithManagerLoadBalancer(l lb.LoadBalancer) ManagerOption
WithManagerLoadBalancer sets the load balancer.
func WithManagerNodeID ¶ added in v0.10.0
func WithManagerNodeID(id string) ManagerOption
WithNodeID sets the node ID for distributed mode.
func WithRateLimiter ¶ added in v0.10.0
func WithRateLimiter(rl ratelimit.RateLimiter) ManagerOption
WithRateLimiter sets the rate limiter.
func WithSessionStore ¶ added in v0.10.0
func WithSessionStore(ss SessionStore) ManagerOption
WithSessionStore sets the session store for session resumption.
func WithValidator ¶ added in v0.10.0
func WithValidator(v validation.MessageValidator) ManagerOption
WithValidator sets the message validator.
type ManagerStats ¶
type ManagerStats = internal.ManagerStats
type MemberOptions ¶
type MemberOptions = internal.MemberOptions
type MessageEdit ¶
type MessageEdit = internal.MessageEdit
type MessageHandler ¶
type MessageHandler = internal.MessageHandler
type MessageHook ¶ added in v1.3.0
type MessageHook interface {
StreamingHook
// OnMessageReceived is called before message processing. Can transform or block (return nil).
OnMessageReceived(ctx context.Context, conn Connection, msg *Message) (*Message, error)
// OnMessageDelivered is called after delivery (non-blocking, runs async).
OnMessageDelivered(ctx context.Context, conn Connection, msg *Message)
}
MessageHook fires on message events.
type MessageReaction ¶
type MessageReaction = internal.MessageReaction
type MessageSearchQuery ¶
type MessageSearchQuery = internal.MessageSearchQuery
type MessageStore ¶
type MessageStore = internal.MessageStore
type ModerationEvent ¶
type ModerationEvent = internal.ModerationEvent
type NodeChangeEvent ¶
type NodeChangeEvent = internal.NodeChangeEvent
type NodeChangeHandler ¶
type NodeChangeHandler = internal.NodeChangeHandler
type OnlineStats ¶
type OnlineStats = internal.OnlineStats
type PresenceFilters ¶
type PresenceFilters = internal.PresenceFilters
type PresenceHook ¶ added in v1.3.0
type PresenceHook interface {
StreamingHook
// OnPresenceChange is called after a user's presence status changes.
OnPresenceChange(ctx context.Context, userID, oldStatus, newStatus string)
}
PresenceHook fires on presence changes.
type PresenceOptions ¶
type PresenceOptions = internal.PresenceOptions
type PresenceStore ¶
type PresenceStore = internal.PresenceStore
type RawMessageHook ¶ added in v1.3.0
type RawMessageHook interface {
StreamingHook
// OnRawMessage processes raw bytes before decoding. Return error to drop the message.
OnRawMessage(ctx context.Context, conn Connection, data []byte) ([]byte, error)
}
RawMessageHook fires before deserialization on raw bytes from the connection.
type RoomHook ¶ added in v1.3.0
type RoomHook interface {
StreamingHook
// OnRoomJoin is called before join. Return error to reject.
OnRoomJoin(ctx context.Context, conn Connection, roomID string) error
// OnRoomLeave is called after leave.
OnRoomLeave(ctx context.Context, conn Connection, roomID string)
// OnRoomCreate is called before room creation. Return error to reject.
OnRoomCreate(ctx context.Context, room Room) error
// OnRoomDelete is called after room deletion.
OnRoomDelete(ctx context.Context, roomID string)
}
RoomHook fires on room lifecycle events.
type RoomOptions ¶
type RoomOptions = internal.RoomOptions
type SessionSnapshot ¶ added in v0.10.0
type SessionSnapshot struct {
SessionID string `json:"session_id"`
UserID string `json:"user_id"`
Rooms []string `json:"rooms"`
Channels []string `json:"channels"`
Metadata map[string]string `json:"metadata,omitempty"`
DisconnectedAt time.Time `json:"disconnected_at"`
}
SessionSnapshot captures the state of a connection for resumption.
type SessionStore ¶ added in v0.10.0
type SessionStore interface {
// Save stores a session snapshot with a TTL.
Save(ctx context.Context, snapshot *SessionSnapshot, ttl time.Duration) error
// Get retrieves a session snapshot by session ID.
Get(ctx context.Context, sessionID string) (*SessionSnapshot, error)
// Delete removes a session snapshot.
Delete(ctx context.Context, sessionID string) error
}
SessionStore stores session snapshots for resumption.
func NewInMemorySessionStore ¶ added in v0.10.0
func NewInMemorySessionStore() SessionStore
NewInMemorySessionStore creates an in-memory session store.
type StreamingHook ¶ added in v1.3.0
type StreamingHook interface {
Name() string
}
StreamingHook is the base interface for all streaming hooks. Hooks implement one or more of the optional hook interfaces below.
type TextCodec ¶ added in v1.3.0
type TextCodec struct{}
TextCodec handles plain text data. On decode, it stores the text in msg.Data as a string. On encode, it converts msg.Data to a string and returns bytes.
func (*TextCodec) ContentType ¶ added in v1.3.0
type TypingStore ¶
type TypingStore = internal.TypingStore
type TypingTracker ¶
type TypingTracker = internal.TypingTracker
type UserPresence ¶
type UserPresence = internal.UserPresence
type UserPresenceStats ¶
type UserPresenceStats = internal.UserPresenceStats