cli

package
v0.0.0-...-a3e1a49 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const CurrentConfigPath = "./anycable.toml"
View Source
const DefaultConfigPath = "/etc/anycable/anycable.toml"

Variables

This section is empty.

Functions

func NewConfig

func NewConfig() *config.Config

NewConfig returns a new AnyCable configuration combining default values and values from the environment.

func NewConfigFromCLI

func NewConfigFromCLI(args []string, opts ...cliOption) (*config.Config, error, bool)

NewConfigFromCLI reads config from os.Args. It returns config, error (if any) and a bool value indicating that the execution was interrupted (e.g., usage message or version was shown), no further action required.

func WithCLICustomOptions

func WithCLICustomOptions(factory customOptionsFactory) cliOption

func WithCLIName

func WithCLIName(name string) cliOption

func WithCLIUsageHeader

func WithCLIUsageHeader(desc string) cliOption

func WithCLIVersion

func WithCLIVersion(str string) cliOption

Types

type Embedded

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

A minimal interface to the underlying Runner for embedding AnyCable into your own Go HTTP application.

func (*Embedded) HTTPBroadcastHandler

func (e *Embedded) HTTPBroadcastHandler() (http.Handler, error)

HTTPBroadcastHandler returns an HTTP handler to process broadcasting requests

func (*Embedded) SSEHandler

func (e *Embedded) SSEHandler(ctx context.Context) (http.Handler, error)

SSEHandler returns an HTTP handler to serve SSE connections via AnyCable. Please, provide your HTTP server's shutdown context to terminate SSE connections gracefully on server shutdown.

func (*Embedded) Shutdown

func (e *Embedded) Shutdown(ctx context.Context) error

Shutdown stops the AnyCable node gracefully.

func (*Embedded) WebSocketHandler

func (e *Embedded) WebSocketHandler() (http.Handler, error)

WebSocketHandler returns an HTTP handler to serve WebSocket connections via AnyCable.

type Option

type Option func(*Runner) error

Option represents a Runner configuration function

func WithBroadcasters

func WithBroadcasters(fn broadcastersFactory) Option

WithBroadcaster is an Option to set Runner broadaster

func WithBroker

func WithBroker(fn brokerFactory) Option

WithBroker is an Option to set Runner broker

func WithController

func WithController(fn controllerFactory) Option

WithController is an Option to set Runner controller

func WithDefaultBroadcaster

func WithDefaultBroadcaster() Option

WithDefaultBroadcaster is an Option to set Runner subscriber to default broadcaster from config

func WithDefaultBroker

func WithDefaultBroker() Option

WithDefaultBroker is an Option to set Runner broker to default broker from config

func WithDefaultRPCController

func WithDefaultRPCController() Option

WithDefaultRPCController is an Option to set Runner controller to default rpc.Controller

func WithDefaultSubscriber

func WithDefaultSubscriber() Option

WithDefaultSubscriber is an Option to set Runner subscriber to pubsub.NewSubscriber

func WithDisconnector

func WithDisconnector(fn disconnectorFactory) Option

WithDisconnector is a an Option to set Runner disconnector

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger set ups a logger for the AnyCable app

func WithName

func WithName(name string) Option

WithName is an Option to set Runner name

func WithShutdownable

func WithShutdownable(instance Shutdownable) Option

WithShutdowable adds a new shutdownable instance to be shutdown at server stop

func WithSubscriber

func WithSubscriber(fn subscriberFactory) Option

WithSubscriber is an Option to set Runner subscriber

func WithTelemetry

func WithTelemetry(props ...string) Option

WithTelemetry enables AnyCable telemetry unless ANYCABLE_DISABLE_TELEMETRY is set. You can pass custom properties as pairs of key and value.

func WithWebSocketEndpoint

func WithWebSocketEndpoint(path string, fn websocketHandler) Option

WithWebSocketEndpoint is an Option to set a custom websocket handler at the specified path

func WithWebSocketHandler

func WithWebSocketHandler(fn websocketHandler) Option

WithWebSocketHandler is an Option to set a custom websocket handler

type Runner

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

func NewRunner

func NewRunner(c *config.Config, options []Option) (*Runner, error)

NewRunner creates returns new Runner structure

func (*Runner) Embed

func (r *Runner) Embed() (*Embedded, error)

Embed starts the application without setting up HTTP handlers, signalts, etc. You can use it to embed AnyCable into your own Go HTTP application.

func (*Runner) Instrumenter

func (r *Runner) Instrumenter() metricspkg.Instrumenter

func (*Runner) Router

func (r *Runner) Router() *router.RouterController

func (*Runner) Run

func (r *Runner) Run() error

Run starts the instance

func (*Runner) SetRouter

func (r *Runner) SetRouter(router *router.RouterController)

type Shutdownable

type Shutdownable interface {
	Shutdown(ctx context.Context) error
}

Jump to

Keyboard shortcuts

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