Documentation
¶
Index ¶
- func ExecuteSync(ctx context.Context, exec Executor) error
- type Action
- type CreateExecutor
- type DeleteExecutor
- type Executor
- type RecycleExecutor
- type ResultMessenger
- type Service
- type SessionCreator
- type SessionDeleter
- type SessionRecycler
- type ShellExecutor
- type SpawnWindowsExecutor
- type TmuxExecutor
- type TmuxOpener
- type WindowKiller
- type WindowSpawner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CreateExecutor ¶
type CreateExecutor struct {
// ResultSessionID and ResultSessionName are populated with the created
// session's ID and name before the done channel fires. Safe to read
// after receiving from done.
ResultSessionID string
ResultSessionName string
// contains filtered or unexported fields
}
CreateExecutor executes a session creation with streaming output.
func (*CreateExecutor) Execute ¶
func (e *CreateExecutor) Execute(ctx context.Context) (output <-chan string, done <-chan error, cancel context.CancelFunc)
Execute starts the create operation and returns channels for output and completion.
type DeleteExecutor ¶
type DeleteExecutor struct {
// contains filtered or unexported fields
}
DeleteExecutor executes a session delete operation.
func (*DeleteExecutor) Execute ¶
func (e *DeleteExecutor) Execute(ctx context.Context) (output <-chan string, done <-chan error, cancel context.CancelFunc)
Execute deletes the session asynchronously. Returns nil output channel (non-streaming).
type Executor ¶
type Executor interface {
// Execute runs the command asynchronously. Returns:
// - output: streaming output lines (nil for non-streaming commands)
// - done: receives error (or nil) when complete
// - cancel: cancels the operation
Execute(ctx context.Context) (output <-chan string, done <-chan error, cancel context.CancelFunc)
}
Executor executes a command, optionally with streaming output.
type RecycleExecutor ¶
type RecycleExecutor struct {
// contains filtered or unexported fields
}
RecycleExecutor executes a session recycle operation with streaming output.
func (*RecycleExecutor) Execute ¶
func (e *RecycleExecutor) Execute(ctx context.Context) (output <-chan string, done <-chan error, cancel context.CancelFunc)
Execute starts the recycle operation and returns channels for output and completion. Returns non-nil output channel with streaming recycle progress.
type ResultMessenger ¶ added in v0.63.0
type ResultMessenger interface {
ResultMessage() string
}
ResultMessenger is an Executor with a message for the user after it succeeds. Read it only after the done channel delivers.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service creates command executors based on action type.
func NewService ¶
func NewService(deleter SessionDeleter, recycler SessionRecycler, tmuxOpener TmuxOpener, windowSpawner WindowSpawner, windowKiller WindowKiller, creator SessionCreator) *Service
NewService creates a new command service with the given dependencies.
func (*Service) CreateExecutor ¶
CreateExecutor creates an executor for the given action. Returns error if the action type is not supported.
func (*Service) NewCreateExecutor ¶
func (s *Service) NewCreateExecutor(opts sessionsvc.CreateOptions) *CreateExecutor
NewCreateExecutor creates a CreateExecutor for streaming session creation.
type SessionCreator ¶
type SessionCreator interface {
CreateSession(ctx context.Context, opts sessionsvc.CreateOptions) (*session.Session, error)
}
SessionCreator is the interface for creating sessions.
type SessionDeleter ¶
SessionDeleter is the interface for deleting sessions.
type SessionRecycler ¶
type SessionRecycler interface {
RecycleSession(ctx context.Context, id string, w io.Writer) error
}
SessionRecycler is the interface for recycling sessions.
type ShellExecutor ¶
type ShellExecutor struct {
// contains filtered or unexported fields
}
ShellExecutor executes a shell command.
func (*ShellExecutor) Execute ¶
func (e *ShellExecutor) Execute(ctx context.Context) (output <-chan string, done <-chan error, cancel context.CancelFunc)
Execute runs the shell command asynchronously. Returns nil output channel (non-streaming).
type SpawnWindowsExecutor ¶
type SpawnWindowsExecutor struct {
// contains filtered or unexported fields
}
SpawnWindowsExecutor executes a TypeSpawnWindows action.
func (*SpawnWindowsExecutor) Execute ¶
func (e *SpawnWindowsExecutor) Execute(ctx context.Context) (<-chan string, <-chan error, context.CancelFunc)
Execute runs the SpawnWindows action asynchronously.
type TmuxExecutor ¶
type TmuxExecutor struct {
// contains filtered or unexported fields
}
TmuxExecutor opens or creates a tmux session via the TmuxOpener interface.
func (*TmuxExecutor) Execute ¶
func (e *TmuxExecutor) Execute(ctx context.Context) (output <-chan string, done <-chan error, cancel context.CancelFunc)
func (*TmuxExecutor) ResultMessage ¶ added in v0.63.0
func (e *TmuxExecutor) ResultMessage() string
ResultMessage reports a launch whose commands all finished, because the user gets no terminal to attach to and would otherwise see nothing happen.
type TmuxOpener ¶
type TmuxOpener interface {
OpenTmuxSession(ctx context.Context, name, path, remote, targetWindow string, background bool) (multiplexer.LaunchResult, error)
}
TmuxOpener opens or creates tmux sessions for hive sessions.
type WindowKiller ¶
type WindowKiller interface {
KillTmuxWindow(ctx context.Context, target multiplexer.Target) error
}
WindowKiller kills one tmux window for KillWindow actions.
type WindowSpawner ¶
type WindowSpawner interface {
// AddWindowsToTmuxSession adds windows to an existing tmux session.
AddWindowsToTmuxSession(ctx context.Context, tmuxName, workDir string, windows []multiplexer.WindowSpec, background bool) error
// CreateSessionWithWindows creates a new Hive session, optionally runs shCmd in its directory,
// then opens windows in it. Non-zero shCmd exit aborts window creation.
CreateSessionWithWindows(ctx context.Context, req sessionsvc.NewSessionRequest, windows []multiplexer.WindowSpec, background bool) error
}
WindowSpawner handles window operations for SpawnWindows actions.