isolator

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Isolator

type Isolator interface {
	Run(ctx context.Context, req Request) (Result, error)
}

Isolator runs caller code in an isolated environment and returns its result. An error is returned only for infrastructure failures (e.g. interpreter not found); a non-zero exit of the executed code is a normal Result, not an error.

type Noop

type Noop struct {
	Result Result
	Err    error
}

Noop is a deterministic isolator used for unit tests of surrounding logic. It does not execute anything; it echoes a fixed result derived from the request.

func NewNoop

func NewNoop() *Noop

func (*Noop) Run

func (n *Noop) Run(_ context.Context, req Request) (Result, error)

type Process

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

Process runs each request as a python subprocess inside the locked container: an ephemeral tmpdir as cwd, its own process-group (so timeouts kill all children), and a shared cap on combined stdout+stderr. Network/privilege isolation is enforced by how the container/pod is launched (see quickstart), not inside this process.

func NewProcess

func NewProcess(python string) *Process

func (*Process) Run

func (p *Process) Run(ctx context.Context, req Request) (Result, error)

type Request

type Request struct {
	Code           string
	Stdin          string
	Timeout        time.Duration
	MaxOutputBytes int
}

Request is a single sandboxed execution request.

type Result

type Result struct {
	Stdout    string
	Stderr    string
	ExitCode  int
	Duration  time.Duration
	Truncated bool
	TimedOut  bool
}

Result is the outcome of a single execution. It is never persisted.

Jump to

Keyboard shortcuts

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