invoker

package
v0.2.0-beta Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package invoker represents solve implementation for running asynchronious tasks like compiling and judging solutions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompileOptions

type CompileOptions struct {
	Source      string
	Target      string
	InputFiles  []MountFile
	TimeLimit   time.Duration
	MemoryLimit int64
}

type CompileReport

type CompileReport struct {
	ExitCode   int
	UsedTime   time.Duration
	UsedMemory int64
	Log        string
}

func (CompileReport) Success

func (r CompileReport) Success() bool

type Compiler

type Compiler interface {
	Name() string
	Compile(ctx context.Context, options CompileOptions) (CompileReport, error)
	CreateExecutable(binaryPath string) (Executable, error)
}

type CompilerManager

type CompilerManager interface {
	GetCompiler(ctx context.Context, name string) (Compiler, error)
	GetCompilerName(name string) (string, error)
	Logger() *logs.Logger
}

type CompilerProcess

type CompilerProcess interface {
	Start() error
	Wait() (ExecuteReport, error)
	Release() error
}

type Executable

type Executable interface {
	CreateProcess(ctx context.Context, options ExecuteOptions) (*safeexec.Process, error)
	Release() error
}

type ExecuteOptions

type ExecuteOptions struct {
	Args        []string
	Stdin       io.Reader
	Stdout      io.Writer
	Stderr      io.Writer
	TimeLimit   time.Duration
	MemoryLimit int64
}

type ExecuteReport

type ExecuteReport struct {
	ExitCode   int
	UsedTime   time.Duration
	UsedMemory int64
}

func (ExecuteReport) Success

func (r ExecuteReport) Success() bool

type Invoker

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

Invoker represents manager for asynchronous actions (invocations).

func New

func New(core *core.Core) *Invoker

New creates a new instance of Invoker.

func (*Invoker) Start

func (s *Invoker) Start() error

Start starts invoker daemons.

This function will spawn config.Invoker.Workers amount of goroutines.

type MountFile

type MountFile struct {
	Source string
	Target string
}

type Problem

type Problem interface {
	Compile(context.Context, CompilerManager) error
	GetExecutables() ([]ProblemExecutable, error)
	GetTestSets() ([]ProblemTestSet, error)
	GetStatements() ([]ProblemStatement, error)
}

type ProblemExecutable

type ProblemExecutable interface {
	Name() string
	Kind() ProblemExecutableKind
	OpenBinary() (*os.File, error)
	GetCompiler(context.Context, CompilerManager) (Compiler, error)
}

type ProblemExecutableKind

type ProblemExecutableKind string
const (
	TestlibChecker    ProblemExecutableKind = "testlib_checker"
	TestlibInteractor ProblemExecutableKind = "testlib_interactor"
)

type ProblemKind

type ProblemKind string
const (
	PolygonProblem  ProblemKind = "polygon"
	CompiledProblem ProblemKind = "compiled"
)

type ProblemPointsPolicy

type ProblemPointsPolicy string
const (
	EachTestPointsPolicy      ProblemPointsPolicy = "each_test"
	CompleteGroupPointsPolicy ProblemPointsPolicy = "complete_group"
)

type ProblemResource

type ProblemResource interface {
	Name() string
	Open() (*os.File, error)
	GetMD5() (string, error)
}

type ProblemStatement

type ProblemStatement interface {
	Locale() string
	GetConfig() (models.ProblemStatementConfig, error)
	GetResources() ([]ProblemResource, error)
}

type ProblemTest

type ProblemTest interface {
	OpenInput() (*os.File, error)
	OpenAnswer() (*os.File, error)
	Points() float64
	Group() string
}

type ProblemTestGroup

type ProblemTestGroup interface {
	Name() string
	PointsPolicy() ProblemPointsPolicy
}

type ProblemTestSet

type ProblemTestSet interface {
	Name() string
	TimeLimit() int64
	MemoryLimit() int64
	GetTests() ([]ProblemTest, error)
	GetGroups() ([]ProblemTestGroup, error)
}

type TaskContext

type TaskContext interface {
	context.Context
	Kind() models.TaskKind
	Status() models.TaskStatus
	ScanConfig(models.TaskConfig) error
	ScanState(any) error
	SetStatus(context.Context, models.TaskStatus) error
	SetState(context.Context, any) error
	SetDeferredState(any) error
	Ping(context.Context, time.Duration) error
	Logger() *logs.Logger
}

Jump to

Keyboard shortcuts

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