executorregistry

package
v0.40.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Port        string
	DatabaseURL string
	LogLevel    slog.Level
}

func LoadConfigFromEnv

func LoadConfigFromEnv() (Config, error)

type ExecuteRequest

type ExecuteRequest struct {
	ExecutorID string          `json:"executor_id"`
	Tool       string          `json:"tool"`
	Arguments  json.RawMessage `json:"arguments"`
	TimeoutMs  int             `json:"timeout_ms,omitempty"`
}

type ExecuteResponse

type ExecuteResponse struct {
	Output   string `json:"output"`
	ExitCode int    `json:"exit_code"`
}

type Executor

type Executor struct {
	ID          string    `json:"id"`
	WorkspaceID string    `json:"workspace_id"`
	Name        string    `json:"name"`
	Type        string    `json:"type"`
	Status      string    `json:"status"`
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
}

type ExecutorCapability

type ExecutorCapability struct {
	ExecutorID  string            `json:"executor_id"`
	Tools       []string          `json:"tools"`
	Environment map[string]string `json:"environment"`
	Resources   ResourceInfo      `json:"resources"`
	Description string            `json:"description"`
	WorkingDir  string            `json:"working_dir"`
	ProbedAt    *time.Time        `json:"probed_at,omitempty"`
}

type ExecutorInfo

type ExecutorInfo struct {
	Executor
	Capabilities ExecutorCapability `json:"capabilities"`
	LastSeen     *time.Time         `json:"last_seen,omitempty"`
}

type ResourceInfo

type ResourceInfo struct {
	CPUCores int    `json:"cpu_cores,omitempty"`
	MemoryGB int    `json:"memory_gb,omitempty"`
	DiskGB   int    `json:"disk_gb,omitempty"`
	GPU      string `json:"gpu,omitempty"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg Config, store *Store) *Server

func (*Server) Routes

func (s *Server) Routes() http.Handler

type Store

type Store struct {
	*sql.DB
}

Store provides database access for the executor registry.

func NewStore

func NewStore(databaseURL string) (*Store, error)

NewStore opens a database connection and runs migrations.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying database connection. Satisfies io.Closer.

func (*Store) CreateExecutor

func (s *Store) CreateExecutor(ctx context.Context, executor Executor, tunnelToken, registryToken string) error

CreateExecutor inserts an executor and its associated capabilities and heartbeat rows.

func (*Store) GetExecutor

func (s *Store) GetExecutor(ctx context.Context, id string) (*ExecutorInfo, error)

GetExecutor retrieves a single executor by ID. Returns nil if not found.

func (*Store) ListExecutors

func (s *Store) ListExecutors(ctx context.Context, workspaceID string) ([]ExecutorInfo, error)

ListExecutors returns all executors in a workspace with their capabilities and last heartbeat.

func (*Store) UpdateCapabilities

func (s *Store) UpdateCapabilities(ctx context.Context, executorID string, cap ExecutorCapability) error

UpdateCapabilities updates the capability fields for an executor.

func (*Store) UpdateExecutorStatus

func (s *Store) UpdateExecutorStatus(ctx context.Context, executorID, status string) error

UpdateExecutorStatus updates the status of an executor.

func (*Store) UpdateHeartbeat

func (s *Store) UpdateHeartbeat(ctx context.Context, executorID string, systemInfo json.RawMessage) error

UpdateHeartbeat updates the last_seen timestamp and system_info for an executor.

func (*Store) ValidateRegistryToken

func (s *Store) ValidateRegistryToken(ctx context.Context, executorID, token string) (bool, error)

ValidateRegistryToken checks whether the given registry token matches the stored hash.

func (*Store) ValidateTunnelToken

func (s *Store) ValidateTunnelToken(ctx context.Context, executorID, token string) (bool, error)

ValidateTunnelToken checks whether the given tunnel token matches the stored hash.

type TunnelRegistry

type TunnelRegistry struct {
	// contains filtered or unexported fields
}

TunnelRegistry is an in-memory registry mapping executor_id to yamux.Session.

func NewTunnelRegistry

func NewTunnelRegistry() *TunnelRegistry

NewTunnelRegistry creates a new TunnelRegistry.

func (*TunnelRegistry) ExecViaTunnel

func (tr *TunnelRegistry) ExecViaTunnel(executorID string, httpReq *http.Request) (ExecuteResponse, error)

ExecViaTunnel opens a yamux stream to the specified executor, writes the given HTTP request over it, reads back the HTTP response, decodes it into an ExecuteResponse, and closes the stream before returning.

func (*TunnelRegistry) Get

func (tr *TunnelRegistry) Get(executorID string) (*yamux.Session, bool)

Get returns the yamux session for the given executor, if one exists.

func (*TunnelRegistry) Register

func (tr *TunnelRegistry) Register(executorID string, session *yamux.Session)

Register adds a yamux session for the given executor. If a session already exists for the executor, the old session is closed before registering the new one.

func (*TunnelRegistry) Unregister

func (tr *TunnelRegistry) Unregister(executorID string)

Unregister closes and removes the yamux session for the given executor.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL