Documentation
¶
Overview ¶
Package exec implements the tailkitd exec integration: an in-memory registry of tool commands watched for live updates, a safe runner, a job store, and the HTTP handlers for POST /exec/{tool}/{cmd} and GET /exec/jobs/{id}.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecEntry ¶
ExecEntry is a resolved, ready-to-run entry in the command registry. It pairs the Tool metadata with the specific Command so the runner has everything it needs without a second lookup.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler holds the dependencies for the exec HTTP endpoints and exposes methods that return http.HandlerFunc values for registration on the mux.
func NewHandler ¶
NewHandler constructs an exec Handler.
type JobStore ¶
type JobStore struct {
// contains filtered or unexported fields
}
JobStore is an in-memory store for async job results. Jobs are evicted automatically after jobTTL (5 minutes). Concurrent access is safe.
func NewJobStore ¶
NewJobStore constructs a JobStore and starts the background eviction goroutine. The goroutine exits when ctx is done — pass the same context as the server lifetime.
func (*JobStore) GetResult ¶
GetResult retrieves a job result by ID. Returns (result, true) if the job exists (accepted, running, or completed). Returns (zero, false) if the job has been evicted or never existed.
func (*JobStore) NewJob ¶
NewJob creates a new job entry with status "accepted" and returns its ID. The returned ID should be given to the caller immediately before the job runs.
func (*JobStore) StartEviction ¶
func (s *JobStore) StartEviction(ctx interface{ Done() <-chan struct{} })
StartEviction begins the background eviction loop. Call once after construction. The loop exits when ctx is cancelled.
func (*JobStore) StoreResult ¶
StoreResult replaces the job entry for id with the completed result. If id does not exist (evicted between acceptance and completion), the result is stored anyway — a late store is better than losing it.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maintains an in-memory index of all registered tool commands, keyed by "tool/command". It watches the tools directory with fsnotify and rebuilds the index automatically when files are created, modified, or deleted.
The index is rebuilt atomically — readers always see either the old or the new complete index, never a partial rebuild.
func NewRegistry ¶
NewRegistry constructs an exec Registry and performs an initial load from dir. It starts a background goroutine that watches dir with fsnotify and rebuilds the index on any change. The goroutine exits when ctx is cancelled.