Documentation
¶
Index ¶
- Constants
- func ChannelName(roomID string) string
- func ResultChannel(requestID string) string
- func StreamName(roomID string) string
- type Bus
- type Event
- type Op
- type RoomBus
- func (rb *RoomBus) Publish(roomID string, msg map[string]interface{})
- func (rb *RoomBus) RoomCount() int
- func (rb *RoomBus) StartRedisSubscriber(ctx context.Context)
- func (rb *RoomBus) Subscribe(roomID string) (ch chan interface{}, cancel func())
- func (rb *RoomBus) SubscriberCount(roomID string) int
Constants ¶
View Source
const ( // PubSub: Room events — all subscribers in room get published events. // Format: room:{roomId}:events RoomEventPattern = "room:%s:events" // PubSub: Entity updates — broadcast to all subscribers. // Format: entity:updates EntityUpdateChannel = "entity:updates" // Stream: Room movement sync — stateful (replay last N messages). // Format: room:{roomId}:movements // Each message: {"player_id":"p1","x":100,"y":200,"ts":1234567890} RoomMovementPattern = "room:%s:movements" // List (queue): Mutations from WS server → fookie-server processes. // Format: mutations:queue // Each item: JSON-encoded GraphQL mutation request MutationsQueue = "mutations:queue" // PubSub: Mutation results — WS server listens for responses. // Format: mutation:result:{requestId} MutationResultPattern = "mutation:result:%s" )
Variables ¶
This section is empty.
Functions ¶
func ChannelName ¶
ChannelName builds a room event channel name.
func ResultChannel ¶
ResultChannel builds a mutation result channel name.
func StreamName ¶
StreamName builds a room movement stream name.
Types ¶
type RoomBus ¶
type RoomBus struct {
// contains filtered or unexported fields
}
func NewRoomBus ¶
func NewRoomBus() *RoomBus
func NewRoomBusWithRedis ¶
func (*RoomBus) Publish ¶
Publish sends to local subscribers and (if Redis configured) to all other server instances.
func (*RoomBus) RoomCount ¶
RoomCount returns the number of active rooms with subscribers (for metrics).
func (*RoomBus) StartRedisSubscriber ¶
StartRedisSubscriber subscribes to all room channels on Redis and forwards incoming messages to local subscribers. Call in a goroutine.
func (*RoomBus) SubscriberCount ¶
SubscriberCount returns the number of active subscribers for a room (for metrics).
Click to show internal directories.
Click to hide internal directories.