runner

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 4 Imported by: 13

Documentation

Overview

Package runner provides common interface for program runner together with common types including Result, Limit, Size and Status.

Status

Status defines the program running result status including

Normal
Program Error
    Resource Limit Exceeded (Time / Memory / Output)
    Unauthorized Access (Disallowed Syscall)
    Runtime Error (Signaled / Nonzero Exit Status)
Program Runner Error

Size

Size defines size in bytes, underlying type is uint64 so it is effective to store up to EiB of size

Limit

Limit defines Time & Memory restriction on program runner

Result

Result defines program running result including Status, ExitStatus, Detailed Error, Time, Memory, SetupTime and RunningTime (in real clock)

Runner

General interface to run a program, including a context for cancellation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limit added in v0.2.0

type Limit struct {
	TimeLimit   time.Duration // user CPU time limit (in ns)
	MemoryLimit Size          // user memory limit (in bytes)
}

Limit represents the resource limit for traced process

func (Limit) String added in v0.2.0

func (l Limit) String() string

type Result added in v0.2.0

type Result struct {
	Status            // result status
	ExitStatus int    // exit status (signal number if signalled)
	Error      string // potential detailed error message (for program runner error)

	Time   time.Duration // used user CPU time  (underlying type int64 in ns)
	Memory Size          // used user memory    (underlying type uint64 in bytes)

	// metrics for the program runner
	SetUpTime   time.Duration
	RunningTime time.Duration
}

Result is the program runner result

func (Result) String added in v0.2.0

func (r Result) String() string

type Runner

type Runner interface {
	Run(context.Context) Result
}

Runner interface defines method to start running

type Size added in v0.2.0

type Size uint64

Size stores number of byte for the object. E.g. Memory. Maximum size is bounded by 64-bit limit

func (Size) Byte added in v0.2.0

func (s Size) Byte() uint64

Byte return size in bytes

func (Size) EiB added in v0.2.0

func (s Size) EiB() uint64

EiB return size in EiB

func (Size) GiB added in v0.2.0

func (s Size) GiB() uint64

GiB return size in GiB

func (Size) KiB added in v0.2.0

func (s Size) KiB() uint64

KiB return size in KiB

func (Size) MiB added in v0.2.0

func (s Size) MiB() uint64

MiB return size in MiB

func (Size) PiB added in v0.2.0

func (s Size) PiB() uint64

PiB return size in PiB

func (*Size) Set added in v0.5.2

func (s *Size) Set(str string) error

Set parse the size value from string

func (Size) String added in v0.2.0

func (s Size) String() string

String stringer interface for print

func (Size) TiB added in v0.2.0

func (s Size) TiB() uint64

TiB return size in TiB

type Status added in v0.2.0

type Status int

Status is the result Status

const (
	StatusInvalid Status = iota // 0 not initialized
	// Normal
	StatusNormal // 1 normal

	// Resource Limit Exceeded
	StatusTimeLimitExceeded   // 2 tle
	StatusMemoryLimitExceeded // 3 mle
	StatusOutputLimitExceeded // 4 ole

	// Unauthorized Access
	StatusDisallowedSyscall // 5 ban

	// Runtime Error
	StatusSignalled         // 6 signalled
	StatusNonzeroExitStatus // 7 nonzero exit status

	// Programmer Runner Error
	StatusRunnerError // 8 runner error
)

Result Status for program runner

func (Status) Error added in v0.2.0

func (t Status) Error() string

func (Status) String added in v0.2.0

func (t Status) String() string

Directories

Path Synopsis
Package unshare implements runner that uses Linux unshare syscall & mount namespace & rlimit to restrict program access
Package unshare implements runner that uses Linux unshare syscall & mount namespace & rlimit to restrict program access

Jump to

Keyboard shortcuts

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