rpc

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package rpc wraps the generated connect-rpc client with the daemon's unix-socket transport. CLI and TUI both consume Client; neither speaks connect-rpc primitives directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNotRunning

func IsNotRunning(err error) bool

IsNotRunning reports whether err signals the daemon is unreachable (socket missing, connection refused). Distinct from a daemon-side error.

Types

type Client

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

Client is a thin wrapper around the generated CoreServiceClient with unix-socket dialing and helpful error mapping.

func New

func New(socketPath string) *Client

New constructs a Client targeting the daemon at socketPath. Pass "" to use the default location (paths.Socket()).

func (*Client) BackupVolume

func (c *Client) BackupVolume(ctx context.Context, stack, service, tag string, force bool) (*anovelv1.BackupVolumeResponse, error)

BackupVolume writes a tar.zst snapshot of every volume on the service. `tag` is optional, embedded in the filename when non-empty. `force` cascade-kills the service before backing up.

func (*Client) ClearVolume

func (c *Client) ClearVolume(ctx context.Context, stack, service string, noBackup, force bool) (*anovelv1.ClearVolumeResponse, error)

ClearVolume destroys volumes (auto-backups first unless noBackup).

func (*Client) Debug

func (c *Client) Debug(ctx context.Context, targetID string) (*anovelv1.DebugResponse, error)

Debug returns the dlv-attach hint for a running go-exec target.

func (*Client) DescribeService

func (c *Client) DescribeService(ctx context.Context, stack, service string) (*anovelv1.DescribeServiceResponse, error)

DescribeService returns one service in detail.

func (*Client) Exec

Exec runs cmd inside the target's runtime (container exec, or a sibling process in the target's env for go-exec). The returned server-stream emits one ExecOutput per stdout/stderr line; closes on natural EOF.

func (*Client) GetEnv

func (c *Client) GetEnv(ctx context.Context, stack, service, only string, allStacks bool) (*anovelv1.GetEnvResponse, error)

GetEnv returns the env entries for a service (or every service across every stack with allStacks=true; or every service in the requested stack with service="").

func (*Client) GetTopology

func (c *Client) GetTopology(ctx context.Context, stack, service string) (*anovelv1.GetTopologyResponse, error)

GetTopology returns the dependency-graph text for one service (or every service in the stack if `service` is empty).

func (*Client) KillInfra

func (c *Client) KillInfra(ctx context.Context, stack, service string, force bool) (*anovelv1.KillInfraResponse, error)

KillInfra tears down the service's infrastructure (refuses if any long-runner is still up unless force=true).

func (*Client) KillInfraContainer

func (c *Client) KillInfraContainer(ctx context.Context, stack, service, name string) (*anovelv1.KillInfraContainerResponse, error)

KillInfraContainer stops one infra container (by name) without affecting the rest of the service. Used by the TUI for tab-level infra lifecycle.

func (*Client) KillTarget

func (c *Client) KillTarget(ctx context.Context, id string, timeout time.Duration) (*anovelv1.KillTargetResponse, error)

KillTarget stops the named instance with the requested SIGTERM grace. `timeout` of 0 → daemon default (10s); for immediate SIGKILL, pass a non-nil zero-duration; for any specific value, pass it.

func (*Client) ListRuns

func (c *Client) ListRuns(ctx context.Context, targetID string) (*anovelv1.ListRunsResponse, error)

ListRuns returns the timestamps of archived runs for a target, newest first.

func (*Client) ListServices

func (c *Client) ListServices(ctx context.Context, stack string) (*anovelv1.ListServicesResponse, error)

ListServices returns every service in `stack` (use "" for default, "*" for all stacks).

func (*Client) ListStacks

func (c *Client) ListStacks(ctx context.Context) (*anovelv1.ListStacksResponse, error)

ListStacks returns every registered stack.

func (*Client) ListVolumes

func (c *Client) ListVolumes(ctx context.Context, stack, service string) (*anovelv1.ListVolumesResponse, error)

ListVolumes returns one Volume per compose-declared volume on the service, with current size + backup count.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) (*anovelv1.PingResponse, error)

Ping is the cheapest possible RPC — used to detect an already-running daemon. Returns the connection error wrapped with a NotRunning helper so callers can distinguish "daemon down" from "daemon errored".

func (*Client) PrepareReinstall

func (c *Client) PrepareReinstall(ctx context.Context) (*anovelv1.PrepareReinstallResponse, error)

PrepareReinstall asks the daemon to checkpoint + shut down.

func (*Client) RestartInfraContainer

func (c *Client) RestartInfraContainer(ctx context.Context, stack, service, name string) (*anovelv1.RestartInfraContainerResponse, error)

RestartInfraContainer issues `podman restart` for one infra container — faster than kill+infra-start because it preserves volume bindings.

func (*Client) RestartTarget

func (c *Client) RestartTarget(ctx context.Context, id string, mode anovelv1.Mode) (*anovelv1.RestartTargetResponse, error)

RestartTarget kills then starts the target in one RPC.

func (*Client) RestoreVolume

func (c *Client) RestoreVolume(ctx context.Context, stack, service, from string, force bool) (*anovelv1.RestoreVolumeResponse, error)

RestoreVolume replaces volumes from a backup. `from` is a timestamp prefix; empty means "latest".

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context, force bool) (*anovelv1.ShutdownResponse, error)

Shutdown is the no-checkpoint daemon stop. `force=true` cascade-kills every service's infra + targets. Both variants signal the daemon to exit after the response is sent; callers poll Ping to know when the socket is gone.

func (*Client) SocketPath

func (c *Client) SocketPath() string

SocketPath returns the socket path this client dials. Useful for error messages.

func (*Client) StartInfra

func (c *Client) StartInfra(ctx context.Context, stack, service string, oneShotsMode anovelv1.Mode) (*anovelv1.StartInfraResponse, error)

StartInfra brings up the service's infrastructure containers and auto-runs its one-shots.

func (*Client) StartTarget

func (c *Client) StartTarget(ctx context.Context, id string, mode anovelv1.Mode) (*anovelv1.StartTargetResponse, error)

StartTarget brings up the named target in the requested mode (use MODE_UNSPECIFIED to default to go-exec).

func (*Client) Status

func (c *Client) Status(ctx context.Context) (*anovelv1.StatusResponse, error)

Status returns the full daemon-side state in one round trip.

func (*Client) StreamLogs

func (c *Client) StreamLogs(ctx context.Context, targetID, runID string, follow bool, streamFilter anovelv1.LogStream) (*connect.ServerStreamForClient[anovelv1.LogLine], error)

StreamLogs returns a server-stream of log lines. Caller drains via Receive()/Msg() and Close()s on done. `runID` of "" means current.log; non-empty selects an archived run. `follow` keeps the stream open for new lines past EOF (snapshot + subscribe).

func (*Client) Watch

func (c *Client) Watch(ctx context.Context, stack, service, targetID string) (*connect.ServerStreamForClient[anovelv1.StateEvent], error)

Watch opens a server-streaming subscription to phase events. Filters: empty stack means "any stack"; empty service means "any service in the stack"; empty targetID means "every target". The returned stream closes when the caller's context is cancelled or the daemon exits.

type NotRunningError

type NotRunningError struct {
	SocketPath string
	Cause      error
}

NotRunningError wraps a transport-level failure. Carries the socket path for actionable error messages.

func (*NotRunningError) Error

func (e *NotRunningError) Error() string

func (*NotRunningError) Unwrap

func (e *NotRunningError) Unwrap() error

Jump to

Keyboard shortcuts

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