sandbox

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Creates sandboxes according to the configuration.

Package sandbox provides a registry of sandboxes for code execution.

Index

Constants

This section is empty.

Variables

View Source
var ErrBusy = errors.New("busy")
View Source
var ErrEmptyRequest = errors.New("empty request")
View Source
var ErrUnknownCommand = errors.New("unknown command")
View Source
var ErrUnknownSandbox = errors.New("unknown sandbox")

Functions

func ApplyConfig

func ApplyConfig(cfg *config.Config) error

ApplyConfig fills engine registry according to the configuration.

func Exec

func Exec(in engine.Request) engine.Execution

Exec executes the code using the appropriate sandbox. Allows no more than pool.Size() concurrent workers at any given time. The request must already be validated by Validate().

func Validate

func Validate(in engine.Request) error

Validate checks if the code execution request is valid.

Types

type Semaphore

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

A Semaphore manages a limited number of tokens that can be acquired or released.

func NewSemaphore

func NewSemaphore(size int) *Semaphore

NewSemaphore creates a new semaphore of the specified size.

func (*Semaphore) Acquire

func (q *Semaphore) Acquire() error

Acquire acquires a token. Returns ErrBusy if no tokens are available.

func (*Semaphore) Release

func (q *Semaphore) Release()

Release releases a token.

func (*Semaphore) Size

func (q *Semaphore) Size() int

Size returns the size of the semaphore.

Jump to

Keyboard shortcuts

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