judge

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STACK_LIMIT_MB     = 128
	STDIO_SIZE_MB      = 32
	SANDBOX_BASE_URL   = "http://localhost:6050"
	MAX_PROCESS_NUMBER = 128
)

Variables

View Source
var COMPILE_FILES = []map[string]interface{}{
	{
		"content": "",
	},
	{
		"name": "stdout",
		"max":  1024 * 1024 * STDIO_SIZE_MB,
	},
	{
		"name": "stderr",
		"max":  1024 * 1024 * STDIO_SIZE_MB,
	},
}

Functions

func Compile

func Compile(compileConfig utils.CompileConfig, code string, language string) (string, error)

Compile compiles specified code and gives an fileId.

func DelFile

func DelFile(fileId string)

DelFile Deletes file in container.

func Judge

func Judge(problem entity.Problem, judge entity.Judge) map[string]interface{}

Judge judges problem; However we only support normal mode:(

func JudgeAllCase

func JudgeAllCase(problem entity.Problem, judgeLanguage string,
	userFileId string, userFileContent string, judgeCaseMode string) ([]runResult, error)

JudgeAllCase judge all cases; However only default is supported

func NewDetailedOJError deprecated

func NewDetailedOJError(code ErrCode, msg string, stdout string, stderr string) error

Deprecated: NewDetailedOJError creates an FULL_OJError with wrap option.

func NewFullOJError

func NewFullOJError(code ErrCode, msg string, stdout string, stderr string) error

func NewOJError

func NewOJError(code ErrCode) error

NewOJError creates an OJError with wrap option.

func NewRawOJError

func NewRawOJError(code ErrCode) error

func SendCompileReq

func SendCompileReq(maxCpuTime int64, maxRealTime int64, maxMemory int64, maxStack int64, srcName string, exeName string, args []string, envs []string, code string) gjson.Result

SendCompileReq build and give compile request.

func StackTraceOJError

func StackTraceOJError(e error) string

StackTraceOJError gives all message and stack info if there's.

Types

type CommandArgs

type CommandArgs struct {
	Id             int
	JudgeGlobalDTO entity.JudgeGlobalCfg
	Input          string
	// contains filtered or unexported fields
}

type ErrCode

type ErrCode int
const (
	OJServerError ErrCode = 10001

	CompileError             ErrCode = 20001
	SubmitError              ErrCode = 20002
	UnsupportedLanguageError ErrCode = 20003
)

func (ErrCode) String

func (i ErrCode) String() string

type OJError

type OJError struct {
	Code   ErrCode
	Msg    string
	Stdout string
	Stderr string
}

func (*OJError) Error

func (err *OJError) Error() string

Error returns full err msg.

func (*OJError) GetType

func (err *OJError) GetType() string

func (*OJError) Is

func (err *OJError) Is(err1 error) bool

Jump to

Keyboard shortcuts

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