controller

package
v0.0.0-...-87b4795 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: AGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WaitOrStop

func WaitOrStop(ctx context.Context, cmd *exec.Cmd, interrupt os.Signal, killDelay time.Duration) error

WaitOrStop waits for the already-started command cmd by calling its Wait method.

If cmd does not return before ctx is done, WaitOrStop sends it the given interrupt signal. If killDelay is positive, WaitOrStop waits that additional period for Wait to return before sending os.Kill.

Types

type Controller

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

Handler is a struct which represents the backend handler

func NewController

func NewController(logger zerolog.Logger, cache cache.LRUCache, db *db.DB) *Controller

NewController creates a new controller

func (*Controller) Compile

func (c *Controller) Compile(ctx context.Context, sourceCode string) (*serialize.ExecutionResponse, error)

Compile compiles the given source code

func (*Controller) GetExecutionSteps

func (c *Controller) GetExecutionSteps(ctx context.Context, sourceCode string) (serialize.ExecutionResponse, error)

GetExecutionSteps gets the execution steps for the given source code

type Event

type Event struct {
	Message string
	Kind    string        // "stdout" or "stderr"
	Delay   time.Duration // time to wait before printing Message
}

type Recorder

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

Recorder records the standard and error outputs of a sandbox program (comprised of playback headers) and converts it to a sequence of Events. It sanitizes each Event's Message to ensure it is valid UTF-8.

Playground programs precede all their writes with a header (described below) that describes the time the write occurred (in playground time) and the length of the data that will be written. If a non-header is encountered where a header is expected, the output is scanned for the next header and the intervening text string is added to the sequence an event occurring at the same time as the preceding event.

A playback header has this structure:

4 bytes: "\x00\x00PB", a magic header
8 bytes: big-endian int64, unix time in nanoseconds
4 bytes: big-endian int32, length of the next write

func (*Recorder) Events

func (r *Recorder) Events() ([]Event, error)

func (*Recorder) Stderr

func (r *Recorder) Stderr() io.Writer

func (*Recorder) Stdout

func (r *Recorder) Stdout() io.Writer

Jump to

Keyboard shortcuts

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