cluster

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventDirect = "direct_signal"
	EventRoom   = "room_signal"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Kind() string
	Publish(context.Context, Event) error
	Subscribe(func(Event)) (io.Closer, error)
	Close() error
}

Backend publishes and subscribes to cluster events.

func NewBackendFromConfig

func NewBackendFromConfig(cfg core.Config) (Backend, error)

NewBackendFromConfig creates the configured cluster transport.

type Event

type Event struct {
	Type     string      `json:"type"`
	NodeID   string      `json:"node_id"`
	RoomID   string      `json:"room_id,omitempty"`
	SenderID string      `json:"sender_id,omitempty"`
	Signal   core.Signal `json:"signal"`
}

Event represents a cluster fanout unit replicated across nodes.

type MemoryBackend

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

MemoryBackend provides in-process fanout for tests and local development.

func NewMemoryBackend

func NewMemoryBackend() *MemoryBackend

func (*MemoryBackend) Close

func (b *MemoryBackend) Close() error

func (*MemoryBackend) Kind

func (b *MemoryBackend) Kind() string

func (*MemoryBackend) Publish

func (b *MemoryBackend) Publish(_ context.Context, event Event) error

func (*MemoryBackend) Subscribe

func (b *MemoryBackend) Subscribe(handler func(Event)) (io.Closer, error)

type NATSBackend

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

func NewNATSBackend

func NewNATSBackend(url, subject string) (*NATSBackend, error)

func (*NATSBackend) Close

func (b *NATSBackend) Close() error

func (*NATSBackend) Kind

func (b *NATSBackend) Kind() string

func (*NATSBackend) Publish

func (b *NATSBackend) Publish(_ context.Context, event Event) error

func (*NATSBackend) Subscribe

func (b *NATSBackend) Subscribe(handler func(Event)) (io.Closer, error)

type RedisBackend

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

func NewRedisBackend

func NewRedisBackend(addr, password string, db int, channel string) (*RedisBackend, error)

func (*RedisBackend) Close

func (b *RedisBackend) Close() error

func (*RedisBackend) Kind

func (b *RedisBackend) Kind() string

func (*RedisBackend) Publish

func (b *RedisBackend) Publish(ctx context.Context, event Event) error

func (*RedisBackend) Subscribe

func (b *RedisBackend) Subscribe(handler func(Event)) (io.Closer, error)

Jump to

Keyboard shortcuts

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