server

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: AGPL-3.0-or-later Imports: 31 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) 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 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) AddDestination added in v0.0.12

func (s *Server) AddDestination(ctx context.Context, req *pb.AddDestinationRequest) (*pb.AddDestinationResponse, error)

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) ListDestinations added in v0.0.12

func (s *Server) ListDestinations(ctx context.Context, req *pb.ListDestinationsRequest) (*pb.ListDestinationsResponse, error)

func (*Server) RemoveDestination added in v0.0.12

func (s *Server) RemoveDestination(ctx context.Context, req *pb.RemoveDestinationRequest) (*pb.RemoveDestinationResponse, error)

func (*Server) StartDestination added in v0.0.12

func (s *Server) StartDestination(ctx context.Context, req *pb.StartDestinationRequest) (*pb.StartDestinationResponse, error)

func (*Server) StopDestination added in v0.0.12

func (s *Server) StopDestination(ctx context.Context, req *pb.StopDestinationRequest) (*pb.StopDestinationResponse, error)

func (*Server) UpdateDestination added in v0.0.12

func (s *Server) UpdateDestination(ctx context.Context, req *pb.UpdateDestinationRequest) (*pb.UpdateDestinationResponse, error)

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