judge

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 2024 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	URL        string
	HttpClient *http.Client
}

func NewClient

func NewClient(URL string) *Client

func (Client) Judge added in v0.4.0

func (c Client) Judge(ctx context.Context, sub Submission, callback ResultCallback) (*problems.Status, error)

type Judge added in v0.4.0

type Judge struct {
	SandboxProvider sandbox.Provider
	ProblemStore    ProblemStore
	LanguageStore   language.Store
	RateLimit       time.Duration

	Tokens chan struct{}
	Logger *slog.Logger
}

func (*Judge) Judge added in v0.4.0

func (j *Judge) Judge(ctx context.Context, sub Submission, callback ResultCallback) (*problems.Status, error)

type Judger added in v0.4.0

type Judger interface {
	Judge(ctx context.Context, sub Submission, callback ResultCallback) (*problems.Status, error)
}

type ParallelEvaluator added in v0.4.0

type ParallelEvaluator struct {
	Runner problems.Runner
	Tokens chan struct{}
	Logger *slog.Logger
}

func (*ParallelEvaluator) Evaluate added in v0.4.0

func (pe *ParallelEvaluator) Evaluate(ctx context.Context, skeleton problems.Status, compiledSolution problems.Solution, sandboxProvider sandbox.Provider, statusUpdater problems.StatusUpdater) (problems.Status, error)

type ProblemStore added in v0.4.0

type ProblemStore interface {
	GetProblem(string) (problems.Problem, error)
}

type Result added in v0.4.0

type Result struct {
	Index  int              `json:"index"`
	Test   string           `json:"test"`
	Status *problems.Status `json:"status"`
	Error  string           `json:"error"`
}

type ResultCallback added in v0.4.0

type ResultCallback func(Result) error

type Server

type Server struct {
	Logger       *slog.Logger
	Judger       Judger
	ProblemStore problems.Store

	Config struct {
		Port string
	}
}

func NewServer

func NewServer(logger *slog.Logger, judger Judger, problemStore problems.Store, opts ...ServerOption) Server

func (Server) PostJudgeHandler added in v0.4.0

func (s Server) PostJudgeHandler() echo.HandlerFunc

func (Server) Run

func (s Server) Run() error

type ServerOption added in v0.4.0

type ServerOption func(*Server)

func WithPortServerOption added in v0.4.0

func WithPortServerOption(port int) ServerOption

type Submission

type Submission struct {
	ID       string `json:"id"`
	Problem  string `json:"problem"`
	Language string `json:"language"`
	Source   []byte `json:"source"`
}

Jump to

Keyboard shortcuts

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