storage

package
v0.0.0-...-e238554 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsulStorage

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

ConsulStorage implements storage using Consul KV

func NewConsulStorage

func NewConsulStorage(address, token, keyPrefix string) (*ConsulStorage, error)

NewConsulStorage creates a new Consul-backed storage

func (*ConsulStorage) Cleanup

func (c *ConsulStorage) Cleanup(ctx context.Context, olderThan time.Duration) error

Cleanup removes executions older than the given duration

func (*ConsulStorage) Close

func (c *ConsulStorage) Close() error

Close closes the Consul client

func (*ConsulStorage) Create

func (c *ConsulStorage) Create(ctx context.Context, exec *Execution) error

Create creates a new execution record

func (*ConsulStorage) Delete

func (c *ConsulStorage) Delete(ctx context.Context, id string) error

Delete removes an execution

func (*ConsulStorage) Get

func (c *ConsulStorage) Get(ctx context.Context, id string) (*Execution, error)

Get retrieves an execution by ID

func (*ConsulStorage) List

func (c *ConsulStorage) List(ctx context.Context, status *client.ExecutionStatus) ([]*Execution, error)

List returns all executions (optionally filtered by status)

func (*ConsulStorage) Update

func (c *ConsulStorage) Update(ctx context.Context, exec *Execution) error

Update updates an existing execution

type Execution

type Execution struct {
	ID          string
	Status      client.ExecutionStatus
	Metadata    *client.Metadata
	Stdout      string
	Stderr      string
	ExitCode    int
	Error       string
	ErrorType   string  // Python error type (e.g., "SyntaxError", "NameError")
	ErrorLine   int     // Line number where error occurred
	Result      *string // REPL-style result of last expression
	StartedAt   *time.Time
	FinishedAt  *time.Time
	DurationMs  int64
	ContainerID string // Docker container ID for running executions
	CreatedAt   time.Time
}

Execution represents a stored execution state

func (*Execution) ToExecutionResult

func (e *Execution) ToExecutionResult() *client.ExecutionResult

ToExecutionResult converts a storage Execution to a client ExecutionResult

type MemoryStorage

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

MemoryStorage implements in-memory storage with mutex protection

func NewMemoryStorage

func NewMemoryStorage() *MemoryStorage

NewMemoryStorage creates a new in-memory storage backend

func (*MemoryStorage) Cleanup

func (m *MemoryStorage) Cleanup(ctx context.Context, olderThan time.Duration) error

Cleanup removes executions older than the given duration

func (*MemoryStorage) Close

func (m *MemoryStorage) Close() error

Close is a no-op for memory storage

func (*MemoryStorage) Create

func (m *MemoryStorage) Create(ctx context.Context, exec *Execution) error

Create creates a new execution record

func (*MemoryStorage) Delete

func (m *MemoryStorage) Delete(ctx context.Context, id string) error

Delete removes an execution

func (*MemoryStorage) Get

func (m *MemoryStorage) Get(ctx context.Context, id string) (*Execution, error)

Get retrieves an execution by ID

func (*MemoryStorage) List

func (m *MemoryStorage) List(ctx context.Context, status *client.ExecutionStatus) ([]*Execution, error)

List returns all executions (optionally filtered by status)

func (*MemoryStorage) Update

func (m *MemoryStorage) Update(ctx context.Context, exec *Execution) error

Update updates an existing execution

type Storage

type Storage interface {
	// Create creates a new execution record
	Create(ctx context.Context, exec *Execution) error

	// Get retrieves an execution by ID
	Get(ctx context.Context, id string) (*Execution, error)

	// Update updates an existing execution
	Update(ctx context.Context, exec *Execution) error

	// Delete removes an execution
	Delete(ctx context.Context, id string) error

	// List returns all executions (optionally filtered by status)
	List(ctx context.Context, status *client.ExecutionStatus) ([]*Execution, error)

	// Cleanup removes executions older than the given duration
	Cleanup(ctx context.Context, olderThan time.Duration) error

	// Close closes the storage backend
	Close() error
}

Storage defines the interface for execution state storage

Jump to

Keyboard shortcuts

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