judge

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callbacker

type Callbacker interface {
	Callback(Response) error
}

type ChanCallback

type ChanCallback struct {
	// contains filtered or unexported fields
}

func NewChanCallback

func NewChanCallback(c chan Response) *ChanCallback

func (*ChanCallback) Callback

func (cc *ChanCallback) Callback(r Response) error

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url string, opts ...ClientOption) *Client

func (Client) Status

func (dc Client) Status(ctx context.Context) (ServerStatus, error)

func (Client) SubmitCallback

func (dc Client) SubmitCallback(ctx context.Context, sub Submission, callback string) error

func (Client) SubmitStream

func (dc Client) SubmitStream(ctx context.Context, sub Submission, res chan SubmissionStatus) error

type ClientOption

type ClientOption func(*Client)

type Enqueuer

type Enqueuer interface {
	Enqueue(context.Context, Submission) (<-chan Response, error)

	SupportedProblems() ([]string, error)
	SupportedLanguages() ([]string, error)
}

type HTTPCallback

type HTTPCallback struct {
	// contains filtered or unexported fields
}

func NewHTTPCallback

func NewHTTPCallback(url string) HTTPCallback

func (HTTPCallback) Callback

func (h HTTPCallback) Callback(r Response) error

type HTTPConfig

type HTTPConfig struct {
	Host string `json:"host" mapstructure:"host"`
	Port string `json:"port" mapstructure:"port"`
}

type HTTPServer

type HTTPServer struct {
	HTTPConfig
	Enqueuer
	// contains filtered or unexported fields
}

func NewHTTPServer

func NewHTTPServer(cfg HTTPConfig, j Enqueuer, logger *zap.Logger) *HTTPServer

func (*HTTPServer) Run

func (s *HTTPServer) Run() error

func (*HTTPServer) ToString

func (s *HTTPServer) ToString() (string, error)

type IsolateWorkerProvider

type IsolateWorkerProvider struct {
	// contains filtered or unexported fields
}

func NewIsolateWorkerProvider

func NewIsolateWorkerProvider(minSandboxId, maxSandboxId, workerCount int) (*IsolateWorkerProvider, error)

func (*IsolateWorkerProvider) Get

func (wp *IsolateWorkerProvider) Get() *Worker

func (*IsolateWorkerProvider) Put

func (wp *IsolateWorkerProvider) Put(w *Worker)

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

func NewQueue

func NewQueue(logger *zap.Logger, problemStore problems.Store, languageStore language.Store, workerProvider WorkerProvider) (*Queue, error)

func (*Queue) Enqueue

func (j *Queue) Enqueue(ctx context.Context, sub Submission) (<-chan Response, error)

func (*Queue) Run

func (j *Queue) Run()

func (*Queue) SupportedLanguages

func (q *Queue) SupportedLanguages() ([]string, error)

func (*Queue) SupportedProblems

func (q *Queue) SupportedProblems() ([]string, error)

type Response

type Response struct {
	Test   string
	Status problems.Status
	Done   bool
	Error  string
}

type Server

type Server struct {
	ServerConfig
	// contains filtered or unexported fields
}

func NewServer

func NewServer(cfg ServerConfig) (*Server, error)

func (*Server) Run

func (s *Server) Run()

type ServerConfig

type ServerConfig struct {
	HTTPConfig  `mapstructure:",squash"`
	SandboxIds  string `json:"sandbox_ids" mapstructure:"sandbox_ids"`
	WorkerCount int    `json:"worker_count" mapstructure:"worker_count"`
	ProblemsDir string `json:"problems_dir" mapstructure:"problems_dir"`
	Mode        string `json:"mode" mapstructure:"mode"`
}

type ServerStatus

type ServerStatus struct {
	Host         string        `json:"host"`
	Port         string        `json:"port"`
	Url          string        `json:"url"`
	Load         float64       `json:"load"`
	Uptime       time.Duration `json:"uptime"`
	ProblemList  []string      `json:"problem_list"`
	LanguageList []string      `json:"language_list"`
}

func ParseServerStatus

func ParseServerStatus(s string) (res ServerStatus, err error)

func (ServerStatus) String

func (s ServerStatus) String() string

func (ServerStatus) SupportsLanguage

func (s ServerStatus) SupportsLanguage(want string) bool

func (ServerStatus) SupportsProblem

func (s ServerStatus) SupportsProblem(want string) bool

type Submission

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

	Stream      bool   `json:"stream"`
	CallbackUrl string `json:"callback_url"`
}

type SubmissionStatus

type SubmissionStatus struct {
	Response
	Time time.Time
}

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

func NewWorker

func NewWorker(id int, sandboxProvider *language.SandboxProvider) *Worker

func (Worker) Judge

func (w Worker) Judge(ctx context.Context, plogger *zap.Logger, p problems.Judgeable, src []byte, lang language.Language, c Callbacker) (st problems.Status, err error)

type WorkerProvider

type WorkerProvider interface {
	Get() *Worker
	Put(*Worker)
}

type WriterCallback

type WriterCallback struct {
	// contains filtered or unexported fields
}

func NewWriterCallback

func NewWriterCallback(w io.Writer, afterFunc func()) *WriterCallback

func (*WriterCallback) Callback

func (wc *WriterCallback) Callback(r Response) error

func (*WriterCallback) Error

func (wc *WriterCallback) Error() error

Jump to

Keyboard shortcuts

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