actor

package
v0.0.0-...-a907a0b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AckTopic

func AckTopic(messageID string) string

AckTopic returns the pubsub topic name for acknowledgements of a given message.

func RoomFactory

func RoomFactory(_ context.Context) (actors.Grain, error)

RoomFactory creates Room grains for the cluster grain registry.

func RoomTopic

func RoomTopic(roomID string) string

RoomTopic returns the pubsub topic name for a room.

Types

type Member

type Member struct {
	// contains filtered or unexported fields
}

Member owns a single websocket connection and bridges it to cluster messaging.

func NewMember

func NewMember(conn net.Conn, opts MemberOptions) *Member

NewMember creates a Member actor bound to a websocket connection. The given conn is wrapped so concurrent writes (from readPump's control-frame handling and writePump) are serialized and safe.

func (*Member) PostStop

func (m *Member) PostStop(ctx *goakt.Context) error

PostStop cleans up subscriptions and closes the websocket connection.

func (*Member) PreStart

func (m *Member) PreStart(ctx *goakt.Context) error

PreStart initializes the actor before it starts receiving messages.

func (*Member) Receive

func (m *Member) Receive(ctx *goakt.ReceiveContext)

Receive handles actor messages, including room membership and pubsub fan-in.

type MemberOptions

type MemberOptions struct {
	SendQueueSize       int
	MaxMessageSize      int // max inbound message size in bytes; 0 = legacy 1 GiB
	RoomDeactivateAfter time.Duration
	ResumeSession       *store.Session
	ReplayLimit         int
	OnStop              func()
	NamespacePolicy     namespace.Policy // optional namespace access control
}

MemberOptions configures buffer sizes and room lifecycle behavior.

type Room

type Room struct {
	// contains filtered or unexported fields
}

Room is a grain that tracks membership and publishes room messages via pubsub.

func NewRoom

func NewRoom() *Room

NewRoom constructs a Room grain with empty membership.

func (*Room) OnActivate

func (r *Room) OnActivate(_ context.Context, props *actors.GrainProps) error

OnActivate initializes the grain state and caches dependencies.

func (*Room) OnDeactivate

func (*Room) OnDeactivate(_ context.Context, _ *actors.GrainProps) error

OnDeactivate runs when the grain is passivated.

func (*Room) OnReceive

func (r *Room) OnReceive(ctx *actors.GrainContext)

OnReceive handles membership changes and publishes room messages.

type Router

type Router struct {
	// contains filtered or unexported fields
}

Router is a singleton actor that routes room messages to the correct grain.

func NewRouter

func NewRouter() *Router

NewRouter creates a router that forwards messages to room grains.

func NewRouterWithOptions

func NewRouterWithOptions(opts RouterOptions) *Router

NewRouterWithOptions creates a router with custom options.

func (*Router) PostStop

func (r *Router) PostStop(_ *actors.Context) error

PostStop runs when the router is shutting down.

func (*Router) PreStart

func (r *Router) PreStart(_ *actors.Context) error

PreStart runs before the router begins processing messages.

func (*Router) Receive

func (r *Router) Receive(ctx *actors.ReceiveContext)

Receive routes incoming messages to the appropriate room grain.

type RouterOptions

type RouterOptions struct {
	NamespacePolicy namespace.Policy
}

RouterOptions configures the router behavior.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址