style: rename Result -> ExecutorResult
This commit is contained in:
parent
8162c63b44
commit
a3deb3d974
10
README.md
10
README.md
|
@ -36,22 +36,22 @@ The program parse the TOML file to run multiple stages.
|
|||
|
||||
Each stage contains a executor and parser.
|
||||
|
||||
Executor takes a `Cmd` and returns a `Result`.
|
||||
Executor takes a `Cmd` and returns a `ExecutorResult`.
|
||||
|
||||
Parser takes a `Result` and its config and returns a `ParserResult`.
|
||||
Parser takes a `ExecutorResult` and its config and returns a `ParserResult`.
|
||||
|
||||
### `Cmd`
|
||||
|
||||
Check <https://github.com/criyle/go-judge#rest-api-interface>.
|
||||
Check `Cmd` in <https://github.com/criyle/go-judge#rest-api-interface>.
|
||||
|
||||
Some extra fields:
|
||||
|
||||
- `CopyInCwd bool`: set to `true` to add everything in the current working directory to `CopyIn`.
|
||||
- `CopyInCached map[string]string`: key: file name in sandbox, value: file name used in `CopyOutCached`.
|
||||
|
||||
### `Result`
|
||||
### `ExecutorResult`
|
||||
|
||||
Check <https://github.com/criyle/go-judge#rest-api-interface>.
|
||||
Check `Result` in <https://github.com/criyle/go-judge#rest-api-interface>.
|
||||
|
||||
### `ParserResult`
|
||||
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
|
||||
type Dummy struct{}
|
||||
|
||||
func (e *Dummy) Run(stage.Cmd) (*stage.Result, error) {
|
||||
return &stage.Result{
|
||||
func (e *Dummy) Run(stage.Cmd) (*stage.ExecutorResult, error) {
|
||||
return &stage.ExecutorResult{
|
||||
Status: stage.Status(envexec.StatusInvalid),
|
||||
ExitStatus: 0,
|
||||
Error: "I'm a dummy",
|
||||
|
|
|
@ -105,10 +105,10 @@ func convertPBFile(i stage.CmdFile) *pb.Request_File {
|
|||
return nil
|
||||
}
|
||||
|
||||
func convertPBResult(res []*pb.Response_Result) []stage.Result {
|
||||
var ret []stage.Result
|
||||
func convertPBResult(res []*pb.Response_Result) []stage.ExecutorResult {
|
||||
var ret []stage.ExecutorResult
|
||||
for _, r := range res {
|
||||
ret = append(ret, stage.Result{
|
||||
ret = append(ret, stage.ExecutorResult{
|
||||
Status: stage.Status(r.Status),
|
||||
ExitStatus: int(r.ExitStatus),
|
||||
Error: r.Error,
|
||||
|
|
|
@ -16,7 +16,7 @@ type Sandbox struct {
|
|||
cachedMap map[string]string
|
||||
}
|
||||
|
||||
func (e *Sandbox) Run(cmd stage.Cmd) (*stage.Result, error) {
|
||||
func (e *Sandbox) Run(cmd stage.Cmd) (*stage.ExecutorResult, error) {
|
||||
slog.Info("sandbox run", "cmd", cmd)
|
||||
if cmd.CopyIn == nil {
|
||||
cmd.CopyIn = make(map[string]stage.CmdFile)
|
||||
|
|
|
@ -15,7 +15,7 @@ type Config struct {
|
|||
|
||||
type Dummy struct{}
|
||||
|
||||
func (e *Dummy) Run(result *stage.Result, configAny any) (
|
||||
func (e *Dummy) Run(result *stage.ExecutorResult, configAny any) (
|
||||
*stage.ParserResult, error,
|
||||
) {
|
||||
var config Config
|
||||
|
|
|
@ -3,7 +3,7 @@ package stage
|
|||
var executorMap = map[string]Executor{}
|
||||
|
||||
type Executor interface {
|
||||
Run(Cmd) (*Result, error)
|
||||
Run(Cmd) (*ExecutorResult, error)
|
||||
Cleanup() error
|
||||
}
|
||||
|
||||
|
|
|
@ -104,8 +104,8 @@ func (s *Status) UnmarshalJSON(b []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Result defines single command result
|
||||
type Result struct {
|
||||
// ExecutorResult defines single command result
|
||||
type ExecutorResult struct {
|
||||
Status Status `json:"status"`
|
||||
ExitStatus int `json:"exitStatus"`
|
||||
Error string `json:"error,omitempty"`
|
||||
|
@ -119,7 +119,7 @@ type Result struct {
|
|||
Buffs map[string][]byte `json:"-"`
|
||||
}
|
||||
|
||||
func (r Result) String() string {
|
||||
func (r ExecutorResult) String() string {
|
||||
type Result struct {
|
||||
Status Status
|
||||
ExitStatus int
|
||||
|
|
|
@ -3,7 +3,7 @@ package stage
|
|||
var parserMap = map[string]Parser{}
|
||||
|
||||
type Parser interface {
|
||||
Run(*Result, any) (*ParserResult, error)
|
||||
Run(*ExecutorResult, any) (*ParserResult, error)
|
||||
}
|
||||
|
||||
func RegisterParser(name string, parser Parser) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user