Documentation
¶
Index ¶
- func ExecuteSync(ctx context.Context, exec Executor) error
- type Action
- type CreateExecutor
- type DeleteExecutor
- type Deps
- type Executor
- type RecycleExecutor
- type ResultMessenger
- type Service
- type SessionCreator
- type SessionDeleter
- type SessionRecycler
- type SessionWindowCreator
- type ShellExecutor
- type SpawnWindowsExecutor
- type TmuxExecutor
- type TmuxOpener
- type WindowAdder
- type WindowKiller
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 Deps ¶ added in v0.68.0
type Deps struct {
Deleter SessionDeleter
Recycler SessionRecycler
Creator SessionCreator
WindowCreator SessionWindowCreator
TmuxOpener TmuxOpener
WindowAdder WindowAdder
WindowKiller WindowKiller
// LocalRemote is the remote of the TUI's working directory. It fills an
// empty remote on a new session, because the session API may run in a
// process with another working directory.
LocalRemote string
}
Deps are the collaborators executors call. Deleter, Recycler, Creator, and WindowCreator are the session API, which may run in a daemon; the rest run in the TUI's process. Only WindowKiller may be nil, which disables KillWindow.
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 (*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 SessionWindowCreator ¶ added in v0.68.0
type SessionWindowCreator interface {
CreateSessionWithWindows(ctx context.Context, req sessionsvc.NewSessionRequest, windows []multiplexer.WindowSpec) (*session.Session, error)
}
SessionWindowCreator creates a Hive session, optionally runs shCmd in its directory, then opens windows in it. Non-zero shCmd exit aborts window creation.
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.
func (*SpawnWindowsExecutor) SessionToSwitchTo ¶ added in v0.68.0
func (e *SpawnWindowsExecutor) SessionToSwitchTo() *session.Session
SessionToSwitchTo is the session a foreground spawn created. The session API creates in the background, so the TUI switches to it itself. Read it only after the done channel delivers.
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 WindowAdder ¶ added in v0.68.0
type WindowAdder interface {
AddWindowsToTmuxSession(ctx context.Context, tmuxName, workDir string, windows []multiplexer.WindowSpec, background bool) error
}
WindowAdder adds windows to an existing tmux session.
type WindowKiller ¶
type WindowKiller interface {
KillTmuxWindow(ctx context.Context, target multiplexer.Target) error
}
WindowKiller kills one tmux window for KillWindow actions.