Documentation
¶
Overview ¶
Package daemonclient implements sessionapi.API against a hive daemon.
Index ¶
- func Spawn(ctx context.Context, binary, dataDir string, env []string) error
- type Client
- func (c *Client) CheckSessionRisk(ctx context.Context, id string) (sessionsvc.Risk, error)
- func (c *Client) CreateFromRequest(ctx context.Context, req sessionsvc.LaunchRequest) (session.Session, error)
- func (c *Client) CreateSession(ctx context.Context, opts sessionsvc.CreateOptions) (*session.Session, error)
- func (c *Client) CreateSessionWithWindows(ctx context.Context, req sessionsvc.NewSessionRequest, ...) (*session.Session, error)
- func (c *Client) DeleteSession(ctx context.Context, id string) error
- func (c *Client) Dial(ctx context.Context) (net.Conn, error)
- func (c *Client) EditSessionTags(ctx context.Context, id string, add, remove []string) (session.Session, error)
- func (c *Client) FetchBatch(ctx context.Context, sessions []*session.Session, ...) map[string]status.TerminalStatus
- func (c *Client) GetSession(ctx context.Context, id string) (session.Session, error)
- func (c *Client) HTTPClient() *http.Client
- func (c *Client) Health(ctx context.Context) (Health, error)
- func (c *Client) Hello(ctx context.Context) (Info, error)
- func (c *Client) ListSessions(ctx context.Context) ([]session.Session, error)
- func (c *Client) Metrics(ctx context.Context) ([]byte, error)
- func (c *Client) Prune(ctx context.Context, all bool) (int, error)
- func (c *Client) RecycleSession(ctx context.Context, id string, w io.Writer) error
- func (c *Client) Reload(ctx context.Context) error
- func (c *Client) RenameSession(ctx context.Context, id, name string) error
- func (c *Client) SessionLaunchOptions(ctx context.Context) (sessionsvc.LaunchOptions, error)
- func (c *Client) SetSessionGroup(ctx context.Context, id, group string) error
- func (c *Client) SetSessionTags(ctx context.Context, id string, tags []string) (session.Session, error)
- func (c *Client) StatusAvailable() bool
- func (c *Client) Stop(ctx context.Context) error
- type Dialer
- type Health
- type Info
- type Options
- type StatusLoopHealth
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Spawn ¶
Spawn starts `<binary> daemon run` detached from the caller (its own session, stdio to <dataDir>/logs/hived.out) and waits up to 5s for /healthz. HIVE_DATA_DIR is set to dataDir and HIVE_CONFIG is made absolute, since the daemon outlives the caller's working directory. A daemon another client started first also counts as ready.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CheckSessionRisk ¶
func (*Client) CreateFromRequest ¶
func (c *Client) CreateFromRequest(ctx context.Context, req sessionsvc.LaunchRequest) (session.Session, error)
func (*Client) CreateSession ¶
func (c *Client) CreateSession(ctx context.Context, opts sessionsvc.CreateOptions) (*session.Session, error)
func (*Client) CreateSessionWithWindows ¶
func (c *Client) CreateSessionWithWindows(ctx context.Context, req sessionsvc.NewSessionRequest, windows []multiplexer.WindowSpec) (*session.Session, error)
func (*Client) Dial ¶
Dial opens a raw connection to the daemon, starting one when AutoStart is set and none answers. `hive daemon dial-stdio` bridges it to ssh.
func (*Client) EditSessionTags ¶
func (*Client) FetchBatch ¶
func (c *Client) FetchBatch(ctx context.Context, sessions []*session.Session, roots []status.RootRepoTarget) map[string]status.TerminalStatus
FetchBatch logs a failure and returns no statuses, the same as an unavailable status service in-process.
func (*Client) GetSession ¶
func (*Client) HTTPClient ¶
HTTPClient reaches the daemon's plain HTTP endpoints, such as /healthz.
func (*Client) ListSessions ¶
func (*Client) RecycleSession ¶
func (*Client) RenameSession ¶
func (*Client) SessionLaunchOptions ¶
func (c *Client) SessionLaunchOptions(ctx context.Context) (sessionsvc.LaunchOptions, error)
func (*Client) SetSessionGroup ¶
func (*Client) SetSessionTags ¶
func (*Client) StatusAvailable ¶
StatusAvailable answers from the last Hello. Until a Hello reports status available, a call starts one in the background (at most one at a time, and one per helloRetry) and answers false, so the TUI's Update never waits on the socket.
type Dialer ¶
Dialer opens one connection to a daemon.
func LocalDialer ¶
LocalDialer reaches the daemon that serves dataDir on this machine.
func UnixDialer ¶
type Options ¶
type Options struct {
Dialer Dialer
Logger zerolog.Logger
// AutoStart starts a daemon when a dial finds none. nil never starts one,
// as for a remote daemon or `hive daemon status --no-start`.
AutoStart func(ctx context.Context) error
// ReadTimeout bounds each read-only call, so a slow remote daemon cannot
// block a caller. A call that changes sessions first asks the daemon for
// Hello under this bound, so a stuck daemon fails it before any change.
// Zero sets no bound and sends no Hello.
ReadTimeout time.Duration
// ConnectTimeout replaces ReadTimeout for a read while the client has no
// connection, since setting one up can take many round trips on a slow link.
ConnectTimeout time.Duration
// RiskTimeout replaces ReadTimeout for a risk check, which runs git and takes
// as long as the repository needs.
RiskTimeout time.Duration
// DeleteTimeout bounds a delete. The service finishes a delete it has
// started, so a cut-off delete cannot leave a half-deleted session. Other
// calls that change sessions have no bound: a clone can take any time, and
// a rename cut off midway leaves tmux and the store apart.
DeleteTimeout time.Duration
// Name is the server this client reaches, for its errors. Empty means the
// daemon on this machine.
Name string
// FailureDetail adds the transport's reason to an error, such as the last
// line ssh printed.
FailureDetail func() string
}