server

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2025 License: AGPL-3.0-or-later Imports: 42 Imported by: 0

Documentation

Overview

Package server implements the main application logic for Octoplex server.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOtherInstanceDetected is returned when another instance of the app is
	// detected on startup.
	ErrOtherInstanceDetected = errors.New("another instance is currently running")

	// ErrAuthenticationCannotBeDisabled is returned when it is not permitted for
	// authentication mode to be "none".
	ErrAuthenticationCannotBeDisabled = errors.New("authentication cannot be disabled")
)

Functions

func Listener

func Listener(addr string) func() (net.Listener, error)

WithListener creates a TCP listener on the given address.

func ResetCredentials added in v0.0.15

func ResetCredentials(cfg config.Config, tokenStore TokenStore) (string, string, error)

ResetCredentials resets the API token and the admin password. It returns the raw token strings that can be presented to the user.

func WithListener

func WithListener(lis net.Listener) func() (net.Listener, error)

WithListener returns the provided listener.

Types

type App

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

App is an instance of the app.

func New

func New(params Params) (*App, error)

New creates a new application instance.

func (*App) DispatchAsync

func (a *App) DispatchAsync(clientID event.ClientID, cmd event.Command)

DispatchAsync dispatches a command to be executed synchronously.

func (*App) DispatchSync added in v0.0.12

func (a *App) DispatchSync(cmd event.Command) (event.Event, error)

DispatchSync dispatches a command to be executed synchronously.

func (*App) Run

func (a *App) Run(ctx context.Context) error

Run starts the application, and blocks until it exits.

func (*App) Stop

func (a *App) Stop(ctx context.Context) error

Stop stops all containers and networks created by any instance of the app.

type CredentialsMode added in v0.0.15

type CredentialsMode int

CredentialsMode represents the mode of credentials used by the server.

This is related to config.AuthMode, but represents the actual state of the server rather than the user's stated preference.

const (
	CredentialsModeEnabled CredentialsMode = iota
	CredentialsModeDisabled
)

type ListenerFunc

type ListenerFunc func() (net.Listener, error)

ListenerFunc is a function that returns a net.Listener.

type Params

type Params struct {
	Config          config.Config
	Store           *store.FileStore
	TokenStore      *store.TokenStore
	DockerClient    container.DockerClient
	ListenerTLSFunc func() (net.Listener, error) // ListenerTLSFunc overrides the configured TLS listen address. May be nil.
	ChanSize        int
	WaitForClient   bool
	Logger          *slog.Logger
}

Params holds the parameters for running the application.

type Server

type Server struct {
	connectpb.UnimplementedAPIServiceHandler
	// contains filtered or unexported fields
}

Server is the gRPC server that handles incoming commands and outgoing events.

func (*Server) AddDestination added in v0.0.12

func (*Server) Authenticate added in v0.0.15

func (*Server) Communicate

func (s *Server) Communicate(ctx context.Context, stream *connect.BidiStream[pb.Envelope, pb.Envelope]) error

func (*Server) GetClientCount

func (s *Server) GetClientCount() int

GetClientCount returns the number of connected clients.

func (*Server) ListDestinations added in v0.0.12

func (*Server) RemoveDestination added in v0.0.12

func (*Server) StartDestination added in v0.0.12

func (*Server) StopDestination added in v0.0.12

func (*Server) UpdateDestination added in v0.0.12

func (*Server) WaitForClient

func (s *Server) WaitForClient(ctx context.Context) error

WaitForClient waits for _any_ client to connect and complete the handshake. It times out if no client has connected after 10 seconds.

type TokenStore added in v0.0.15

type TokenStore interface {
	Get(key string) (domain.Token, error)
	Put(key string, value domain.Token) error
	Delete(key string) error
}

TokenStore is a store for tokens.

type WebSocketProxy added in v0.0.15

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

WebSocketProxy bridges WebSocket connections to ConnectRPC bidirectional streams.

func (*WebSocketProxy) GetConnectionCount added in v0.0.15

func (p *WebSocketProxy) GetConnectionCount() int

GetConnectionCount returns the number of active WebSocket connections.

func (*WebSocketProxy) Handler added in v0.0.15

func (p *WebSocketProxy) Handler() http.HandlerFunc

Handler handles incoming WebSocket connections.

Jump to

Keyboard shortcuts

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