runner

package
v0.0.0-...-c269f4c Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: MIT Imports: 4 Imported by: 0

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 canclation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limit

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

func (l Limit) String() string

type Result

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

func (r Result) String() string

type Runner

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

Runner interface defines method to start running

type Size

type Size uint64

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

func (Size) Byte

func (s Size) Byte() uint64

Byte return size in bytes

func (Size) EiB

func (s Size) EiB() uint64

EiB return size in EiB

func (Size) GiB

func (s Size) GiB() uint64

GiB return size in GiB

func (Size) KiB

func (s Size) KiB() uint64

KiB return size in KiB

func (Size) MiB

func (s Size) MiB() uint64

MiB return size in MiB

func (Size) PiB

func (s Size) PiB() uint64

PiB return size in PiB

func (*Size) Set

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

Set parse the size value from string

func (Size) String

func (s Size) String() string

String stringer interface for print

func (Size) TiB

func (s Size) TiB() uint64

TiB return size in TiB

type Status

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

func (t Status) Error() string

func (Status) String

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