Documentation
¶
Overview ¶
Package server implements the main application logic for Octoplex server.
Index ¶
- Variables
- func Listener(addr string) func() (net.Listener, error)
- func ResetCredentials(cfg config.Config, tokenStore TokenStore) (string, string, error)
- func WithListener(lis net.Listener) func() (net.Listener, error)
- type App
- type CredentialsMode
- type ListenerFunc
- type Params
- type Server
- func (s *Server) AddDestination(ctx context.Context, req *connect.Request[pb.AddDestinationRequest]) (*connect.Response[pb.AddDestinationResponse], error)
- func (s *Server) Authenticate(context.Context, *connect.Request[pb.AuthenticateRequest]) (*connect.Response[pb.AuthenticateResponse], error)
- func (s *Server) Communicate(ctx context.Context, stream *connect.BidiStream[pb.Envelope, pb.Envelope]) error
- func (s *Server) GetClientCount() int
- func (s *Server) ListDestinations(ctx context.Context, req *connect.Request[pb.ListDestinationsRequest]) (*connect.Response[pb.ListDestinationsResponse], error)
- func (s *Server) RemoveDestination(ctx context.Context, req *connect.Request[pb.RemoveDestinationRequest]) (*connect.Response[pb.RemoveDestinationResponse], error)
- func (s *Server) StartDestination(ctx context.Context, req *connect.Request[pb.StartDestinationRequest]) (*connect.Response[pb.StartDestinationResponse], error)
- func (s *Server) StopDestination(ctx context.Context, req *connect.Request[pb.StopDestinationRequest]) (*connect.Response[pb.StopDestinationResponse], error)
- func (s *Server) UpdateDestination(ctx context.Context, req *connect.Request[pb.UpdateDestinationRequest]) (*connect.Response[pb.UpdateDestinationResponse], error)
- func (s *Server) WaitForClient(ctx context.Context) error
- type TokenStore
- type WebSocketProxy
Constants ¶
This section is empty.
Variables ¶
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 ResetCredentials ¶ added in v0.0.15
ResetCredentials resets the API token and the admin password. It returns the raw token strings that can be presented to the user.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is an instance of the app.
func (*App) DispatchAsync ¶
DispatchAsync dispatches a command to be executed synchronously.
func (*App) DispatchSync ¶ added in v0.0.12
DispatchSync dispatches a command to be executed synchronously.
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 ¶
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 (*Server) GetClientCount ¶
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
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.