processor

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package processor provides builtin processors and processor plugin loader

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InputLabel

func InputLabel(name string) []string

func OutputLabel

func OutputLabel(name string) []string

Types

type Code

type Code int
const (
	Ok Code = iota
	RuntimeError
	MemoryExceed
	TimeExceed
	OutputExceed
	SystemError
	DangerousSyscall
	ExitError
)

type Processor

type Processor interface {
	// Report human-readable label for each input and output
	Label() (inputlabel []string, outputlabel []string)
	// Given a fixed number of input files, generate output to  corresponding files
	// with execution result. It's ok if result == nil, which means success.
	Run(input []string, output []string) (result *Result)
}

Processor takes a series of input (files) and generates a series of outputs.

func LoadPlugin

func LoadPlugin(plugin string) (Processor, error)

Plugin describes how to build a custom processor by creating a shared library with specific symbol exposed.

Conventionally, plugin is written in go which is compiled to a shared library (plugin) and is loaded in runtime. However we also plan to support C/C++ plugin due to its popularity.

Load a go plugin as processor. The plugin requires two exported functions:

func Label() (input []string, output []string)
func Main(inputs []string, outputs []string) int

type Result

type Result struct {
	// Result status:OK/RE/MLE/...
	Code              Code
	RealTime, CpuTime *time.Duration
	Memory            *utils.ByteValue
	Msg               string
}

Code is required, others are optional

func (Result) Serialize added in v0.0.27

func (r Result) Serialize() []byte

func (*Result) Unserialize added in v0.0.27

func (r *Result) Unserialize(data []byte) error

Jump to

Keyboard shortcuts

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