streams

package
v1.5.6 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 9 Imported by: 2

Documentation

Overview

This package provides functionality to directly subscribe to streams without using channels (a simplified pub/sub mode)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CableReadyMesssage

type CableReadyMesssage struct {
	Identifier string `json:"identifier"`
}

type Config

type Config struct {
	// Secret is a key used to sign and verify streams
	Secret string `toml:"secret"`

	// Public determines if public (unsigned) streams are allowed
	Public bool `toml:"public"`

	// Whisper determines if whispering is enabled for pub/sub streams
	Whisper bool `toml:"whisper"`

	// PubSubChannel is the channel name used for direct pub/sub
	PubSubChannel string `toml:"pubsub_channel"`

	// Turbo is a flag to enable Turbo Streams support
	Turbo bool `toml:"turbo"`

	// TurboSecret is a custom secret key used to verify Turbo Streams
	TurboSecret string `toml:"turbo_secret"`

	// CableReady is a flag to enable CableReady support
	CableReady bool `toml:"cable_ready"`

	// CableReadySecret is a custom secret key used to verify CableReady streams
	CableReadySecret string `toml:"cable_ready_secret"`
}

func NewConfig

func NewConfig() Config

NewConfig returns a new Config with the given key

func (Config) GetCableReadySecret

func (c Config) GetCableReadySecret() string

func (Config) GetTurboSecret

func (c Config) GetTurboSecret() string

func (Config) ToToml added in v1.5.4

func (c Config) ToToml() string

type Controller

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

func NewCableReadyController

func NewCableReadyController(key string, l *slog.Logger) *Controller

func NewController

func NewController(key string, resolver StreamResolver, l *slog.Logger) *Controller

func NewStreamsController

func NewStreamsController(conf *Config, l *slog.Logger) *Controller

func NewTurboController

func NewTurboController(key string, l *slog.Logger) *Controller

func (*Controller) Authenticate

func (c *Controller) Authenticate(sid string, env *common.SessionEnv) (*common.ConnectResult, error)

func (*Controller) Disconnect

func (c *Controller) Disconnect(sid string, env *common.SessionEnv, ids string, subscriptions []string) error

func (*Controller) Perform

func (c *Controller) Perform(sid string, env *common.SessionEnv, ids string, identifier string, data string) (*common.CommandResult, error)

func (*Controller) Shutdown

func (c *Controller) Shutdown() error

func (*Controller) Start

func (c *Controller) Start() error

func (*Controller) Subscribe

func (c *Controller) Subscribe(sid string, env *common.SessionEnv, ids string, identifier string) (*common.CommandResult, error)

func (*Controller) Unsubscribe

func (c *Controller) Unsubscribe(sid string, env *common.SessionEnv, ids string, identifier string) (*common.CommandResult, error)

type StreamResolver

type StreamResolver = func(string) (*SubscribeRequest, error)

type SubscribeRequest

type SubscribeRequest struct {
	StreamName       string `json:"stream_name"`
	SignedStreamName string `json:"signed_stream_name"`
	// contains filtered or unexported fields
}

func (*SubscribeRequest) IsPresent

func (r *SubscribeRequest) IsPresent() bool

type TurboMessage

type TurboMessage struct {
	SignedStreamName string `json:"signed_stream_name"`
}

Jump to

Keyboard shortcuts

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