Documentation
¶
Index ¶
- Constants
- func StartActivityHeartbeat(ctx context.Context, c client.Client, envID, source string, ...) (stop func())
- func StartInputHeartbeat(ctx context.Context, c client.Client, envID, source string, ...) (stop func())
- type Client
- type ContainerState
- type ExecOutput
- type InputActivity
- type Service
- func (c *Service) Exec(args []string, input *InputActivity) error
- func (c *Service) ExecCapture(ctx context.Context, args []string, maxBytes int) (ExecOutput, error)
- func (c *Service) GetLogsAsString(follow bool, tail int64) (string, error)
- func (c *Service) GetPreviousLogsAsString(tail int64) (string, error)
- func (c *Service) Logs(follow bool, tail int64) error
- func (c *Service) PortForward(ports []string) error
- func (c *Service) UseCrashedPod() ContainerState
Constants ¶
const ( ActivitySourceExec = "exec" ActivitySourceLogs = "logs" ActivitySourcePortForward = "port-forward" )
Activity sources the backend accepts for a heartbeat.
const ActivityHeartbeatInterval = 2 * time.Minute
ActivityHeartbeatInterval is how often a long-running session tells the backend the environment is still in use, so it is not stopped mid-session for having no recent visit. It is short so that one failed report can't end a session under a short timeout. The backend records one audit event per five minutes however often it hears from a session.
Variables ¶
This section is empty.
Functions ¶
func StartActivityHeartbeat ¶ added in v1.11.0
func StartActivityHeartbeat(ctx context.Context, c client.Client, envID, source string, interval time.Duration) (stop func())
StartActivityHeartbeat reports activity on an environment every interval until ctx is done, stop is called or activityMaxSession passes. The first report goes out after one interval: fetching the kubeconfig already counts as the start of the session.
A failed report must never end the session. It is logged, and repeated failures warn the user once. A report can't be cancelled, so stop waits for one in flight only briefly: the session is over by then, and it must not be held up by a stalled API.
func StartInputHeartbeat ¶ added in v1.11.0
func StartInputHeartbeat(ctx context.Context, c client.Client, envID, source string, interval time.Duration, input *InputActivity) (stop func())
StartInputHeartbeat is StartActivityHeartbeat for a session that only counts as activity while it has input: it skips an interval that had none.
Types ¶
type Client ¶ added in v1.7.0
type Client struct {
Path string
}
Client points at the environment's kubeconfig saved in ~/.shipyard, for tools such as telepresence that need a file rather than a parsed config.
type ContainerState ¶ added in v1.10.0
type ContainerState struct {
Pod string
Container string
// Init is set when Container is an init container
Init bool
Ready bool
RestartCount int32
// Reason and ExitCode describe the last time the container stopped, if it has
Reason string
ExitCode *int32
}
ContainerState describes a service container's restarts and how it last stopped.
type ExecOutput ¶ added in v1.9.0
ExecOutput is what a non-interactive command wrote before it finished.
type InputActivity ¶ added in v1.11.0
type InputActivity struct {
// contains filtered or unexported fields
}
InputActivity records whether a session has had input since the last report. An exec session counts as activity only while someone is using it, as in the web terminal, so a forgotten shell does not keep an environment running.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) ExecCapture ¶ added in v1.9.0
ExecCapture runs a command in the service's pod and returns what it wrote.
This is Exec without the terminal: no stdin is attached and no TTY is requested, so it fits a caller that has one request and wants one response, such as the MCP server. Dropping the TTY also keeps stdout and stderr on separate streams, which a TTY merges.
A command that exits non-zero is not an error here: its output and exit code are the answer. An error means the exec never ran or the stream broke.
maxBytes caps each stream; zero or less means no cap. Cap what you hand to a model: `cat` on a large file otherwise fills its context with one tool result.
func (*Service) GetLogsAsString ¶ added in v1.8.0
GetLogsAsString returns logs as a string instead of printing them This is used by the MCP logs service to capture log output
func (*Service) GetPreviousLogsAsString ¶ added in v1.10.0
GetPreviousLogsAsString returns the logs of the container's previous run, the one that crashed.
func (*Service) PortForward ¶
func (*Service) UseCrashedPod ¶ added in v1.10.0
func (c *Service) UseCrashedPod() ContainerState
UseCrashedPod switches this Service (logs, exec and port-forward alike) to the pod and container most likely to explain a crash, which may be an init container or a sidecar, and returns that container's state. Use a fresh Service for anything else.