stella

package module
v0.0.0-...-72b55a3 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

README

stella

Code Execution Api built for concurrency

Getting Started (WIP)

First install the stella-compilers image

Open your favorite command line tool and run docker pull khai52/stella-compilers:latest

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Languages = []Language{
	{
		Id:            1,
		Name:          "Go",
		Version:       "latest",
		Image:         "golang",
		Cmd:           []string{"go", "run", "/main.go"},
		TestCmd:       []string{"sh", "-c", "go mod init main;go test -json *.go"},
		EntryFileName: "main.go",
		TestFileName:  "main_test.go",
		TestFramework: GoTestFramework,
	},
	{
		Id:            2,
		Name:          "NodeJS",
		Version:       "latest",
		Image:         "node",
		Cmd:           []string{"node", "main.js"},
		TestCmd:       []string{"jest", "main.test.js", "-c", "{}", "--json"},
		EntryFileName: "main.js",
		TestFileName:  "main.test.js",
		TestFramework: JestTestFramework,
	},
	{
		Id:            3,
		Name:          "Python",
		Version:       "latest",
		Image:         "python",
		Cmd:           []string{"python", "main.py"},
		EntryFileName: "main.py",
	},
	{
		Id:            4,
		Name:          "C++",
		Version:       "latest",
		Image:         "cpp",
		Cmd:           []string{"sh", "-c", "g++ -o main main.cpp && ./main"},
		EntryFileName: "main.cpp",
	},
}

Functions

This section is empty.

Types

type ExecutionService

type ExecutionService interface {
	ExecuteSubmission(input SubmissionInput) (*SubmissionOutput, error)
}

ExecutionService handles execution of submissions

type Language

type Language struct {
	Id            int
	Name          string
	Version       string
	Image         string   // Docker Image
	Cmd           []string // Command to run the language's program for submission
	TestCmd       []string
	EntryFileName string
	TestFileName  string
	TestFramework TestFramework
}

type SubmissionInput

type SubmissionInput struct {
	Token           string `json:"token,omitempty"`
	SourceCode      string `json:"source_code,omitempty"`
	LanguageId      int    `json:"language_id,omitempty"`
	AdditionalFiles string `json:"additional_files,omitempty"`
	ExpectedOutput  string `json:"expected_output,omitempty"`
	TestSourceCode  string `json:"test_source_code,omitempty"`
	StdIn           string `json:"std_in,omitempty"`
}

func (SubmissionInput) MarshalBinary

func (s SubmissionInput) MarshalBinary() ([]byte, error)

type SubmissionLanguage

type SubmissionLanguage struct {
	Id   int    `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

type SubmissionOutput

type SubmissionOutput struct {
	Stdout        string  `json:"stdout,omitempty"`
	Stderr        string  `json:"stderr,omitempty"`
	ExitCode      int     `json:"exit_code,omitempty"`
	Token         string  `json:"token"`
	Memory        float32 `json:"memory,omitempty"`
	Executed      bool    `json:"executed"`
	OutputMatched bool    `json:"output_matched"`
	Time          float32 `json:"time,string,omitempty"`
}

func (SubmissionOutput) MarshalBinary

func (s SubmissionOutput) MarshalBinary() ([]byte, error)

type SubmissionService

type SubmissionService interface {
	CreateSubmission(input SubmissionInput) (*SubmissionOutput, error)
	GetSubmission(token string) (*SubmissionOutput, error)
}

type Test

type Test struct {
	Description string `json:"description"`
	Passed      bool   `json:"passed"`
	RawOutput   string `json:"raw_output"`
	Duration    int    `json:"duration"` // In Milliseconds
}

type TestFramework

type TestFramework string
const (
	JestTestFramework TestFramework = "jest"
	GoTestFramework   TestFramework = "gotest"
)

type TestParseOutput

type TestParseOutput struct {
	Passed []Test
	Failed []Test
}

type TestService

type TestService interface {
	ParseTestOutput(stdout string, framework TestFramework) (*TestParseOutput, error)
}

handles parsing of test framework's json output

type TestSubmissionInput

type TestSubmissionInput struct {
	SourceCode      string `json:"source_code,omitempty"`
	TestSourceCode  string `json:"test_source_code,omitempty"`
	LanguageId      int    `json:"language_id,omitempty"`
	AdditionalFiles string `json:"additional_files,omitempty"`
	FrameworkId     int    `json:"framework_id,omitempty"`
}

type TestSubmissionOutput

type TestSubmissionOutput struct {
	Token   string `json:"token"`
	Passed  []Test `json:"passed"`
	Failed  []Test `json:"failed"`
	Success bool   `json:"success"`
	Total   int    `json:"total"`
}

Directories

Path Synopsis
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
lib
env
pkg

Jump to

Keyboard shortcuts

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