client

package
v0.1.0-proto2m Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides a programmatic interface to interact with a running GAPI daemon.

func New

func New(cfg *config.Config) (*Client, error)

New creates a new Client using the provided configuration.

func NewFromBus

func NewFromBus(bus *eventbus.EventBus[*anypb.Any]) *Client

NewFromBus creates a new Client using an existing EventBus (for in-process use).

The returned Client does NOT own the bus: Close is a no-op on it, and the caller that built the bus remains responsible for shutting it down.

func (*Client) AgentStatus

func (c *Client) AgentStatus(ctx context.Context) ([]*protopkg.AgentStatus, error)

AgentStatus queries the daemon for the status of all agents.

func (*Client) Close

func (c *Client) Close() error

Close releases the daemon connection this Client dialled.

WITHOUT IT EVERY INVOCATION LEFT A DEAD PEER IN THE DAEMON FOR A FULL MINUTE (GAPI-DIV-124). A gapictl process exited without a graceful QUIC close, so the daemon learned of it only when MaxIdleTimeout expired - config.QUICIdleTimeout, 60 seconds - at which point handleConn's AcceptStream returned and the deferred delete removed the peer. The daemon therefore carried every control invocation of the last minute in its peer set, and fanned every reply out to all of them.

Idempotent, because callers defer it and some paths also close explicitly: EventBus.Close guards on its own closed flag.

func (*Client) GetLogs

func (c *Client) GetLogs(ctx context.Context, agentID string) (<-chan string, error)

GetLogs subscribes to the logs for a specific agent and returns a channel of log lines. The subscription is automatically cleaned up when the context is cancelled.

func (*Client) Lifecycle

func (c *Client) Lifecycle(ctx context.Context, agentIDs []string, action protopkg.LifecycleControl_Action) []Result

Lifecycle sends a lifecycle action to a set of agents and waits for their transition.

func (*Client) LifecycleWithOpts

func (c *Client) LifecycleWithOpts(ctx context.Context, agentIDs []string, action protopkg.LifecycleControl_Action, opts LifecycleOptions) []Result

LifecycleWithOpts sends a lifecycle action with options.

func (*Client) Ping

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

Ping sends a ping to the daemon and waits for a pong.

func (*Client) ReloadAgents

func (c *Client) ReloadAgents(ctx context.Context) error

ReloadAgents triggers a reload of the agent registry on the daemon.

func (*Client) Shutdown

func (c *Client) Shutdown(ctx context.Context, action string) error

Shutdown requests a system shutdown from the daemon. action is one of "poweroff", "reboot", "halt" (the topic's documented payload vocabulary); in PID-1 mode the daemon answers with the full init teardown.

func (*Client) Start

func (c *Client) Start(ctx context.Context, agentIDs []string) []Result

Start triggers the START action for the given agents.

func (*Client) StartWithOpts

func (c *Client) StartWithOpts(ctx context.Context, agentIDs []string, opts LifecycleOptions) []Result

StartWithOpts triggers the START action with options.

func (*Client) Stop

func (c *Client) Stop(ctx context.Context, agentIDs []string) []Result

Stop triggers the STOP action for the given agents.

type LifecycleOptions

type LifecycleOptions struct {
	Env           map[string]string
	RestartPolicy string
}

LifecycleOptions defines optional parameters for lifecycle actions.

type Result

type Result struct {
	AgentID string
	Status  *protopkg.LifecycleStatus
	Err     error
}

Result represents the outcome of a lifecycle action on a specific agent.

Jump to

Keyboard shortcuts

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