server

package
v0.0.11 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOtherInstanceDetected = errors.New("another instance is currently running")

ErrOtherInstanceDetected is returned when another instance of the app is detected on startup.

Functions

func Listener

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

WithListener creates a TCP listener on the given address.

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) Dispatch

func (a *App) Dispatch(cmd event.Command) event.Event

Dispatch dispatches a command to be executed synchronously.

func (*App) DispatchAsync

func (a *App) DispatchAsync(cmd event.Command)

DispatchAsync 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 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
	DockerClient  container.DockerClient
	ListenerFunc  func() (net.Listener, error) // ListenerFunc overrides the configured 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 {
	pb.UnimplementedInternalAPIServer
	// contains filtered or unexported fields
}

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

func (*Server) Communicate

func (s *Server) Communicate(stream pb.InternalAPI_CommunicateServer) error

func (*Server) GetClientCount

func (s *Server) GetClientCount() int

GetClientCount returns the number of connected clients.

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.

Jump to

Keyboard shortcuts

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