Documentation
¶
Index ¶
- Constants
- Variables
- func CompressWithZstd(data []byte) ([]byte, error)
- func DecompressWithZstd(compressedData []byte) ([]byte, error)
- func GetTestfileS3Key(body []byte) string
- func MimeFromFname(fname string) (string, error)
- func MimeToFileExt(mimeType string) (string, error)
- func NewErrorFailedToGetTaskFromDb(taskId string) srvcerror.E
- func NewErrorGetImageWidthAndHeight() srvcerror.E
- func NewErrorImageAlreadyExists(filename string) srvcerror.E
- func NewErrorImageFileExtFromMimeType(mime string) srvcerror.E
- func NewErrorImageInadequateDimensions() srvcerror.E
- func NewErrorImageNotFound(filename string) srvcerror.E
- func NewErrorInternalServerError() srvcerror.E
- func NewErrorInvalidTaskZip(reason string) srvcerror.E
- func NewErrorTaskAlreadyExists(taskId string) srvcerror.E
- func NewErrorTaskNotFound(taskId string) srvcerror.E
- func NewErrorUnsupportedTaskZip(reason string) srvcerror.E
- func NewTaskSrvc(repo TaskPgRepo, publicStore, testfileStore ObjectStore, ...) *taskSrvc
- func Sha2Hex(body []byte) (sha2 string)
- type CacheEntry
- type Example
- type IllustrationImage
- type MarkdownStatement
- type ObjectStore
- type OriginNote
- type Solution
- type StatementImage
- type Subtask
- type Task
- type TaskEvalTestGroupInformation
- type TaskPgRepo
- type TaskPreview
- type TaskService
- type TaskSrvcOption
- type Test
- type TestFileCache
- type TestGroup
- type VisInpSubtaskTest
- type VisibleInputSubtask
Constants ¶
const ( // CacheDir is the standard Linux cache directory for proglv CacheDir = "/var/cache/proglv/testfiles" // MaxCacheSize is the maximum cache size in bytes (10GB) MaxCacheSize = 10 * 1024 * 1024 * 1024 // MaxConcurrentDownloads limits parallel downloads MaxConcurrentDownloads = 10 )
const ErrCodeFailedToGetTaskFromDb = "failed_to_get_task_from_db"
const ErrCodeGetImageWidthAndHeight = "image_width_and_height"
const ErrCodeImageAlreadyExists = "image_already_exists"
const ErrCodeImageFileExtFromMimeType = "image_file_ext_from_mime_type"
const ErrCodeImageInadequateDimensions = "image_inadequate_dimensions"
const ErrCodeImageNotFound = "image_not_found"
const ErrCodeInternalServerError = "internal_server_error"
const ErrCodeInvalidTaskZip = "invalid_task_zip"
const ErrCodeTaskAlreadyExists = "task_already_exists"
const ErrCodeTaskNotFound = "task_not_found"
const ErrCodeUnsupportedTaskZip = "unsupported_task_zip"
Variables ¶
var ErrSomeTaskNotFound = srvcerror.New( "some_task_not_found", "kāds no uzdevumiem netika atrasts", ).SetHttpStatusCode(http.StatusNotFound)
Functions ¶
func CompressWithZstd ¶
CompressWithZstd compresses the given data using Zstandard compression. It returns the compressed data or an error if the compression fails.
func DecompressWithZstd ¶
DecompressWithZstd decompresses data that was compressed with Zstandard. It returns the decompressed data or an error if the decompression fails.
func GetTestfileS3Key ¶
func MimeFromFname ¶
func MimeToFileExt ¶
func NewErrorImageNotFound ¶
func NewErrorInvalidTaskZip ¶
func NewErrorTaskNotFound ¶
func NewTaskSrvc ¶
func NewTaskSrvc( repo TaskPgRepo, publicStore, testfileStore ObjectStore, opts ...TaskSrvcOption, ) *taskSrvc
Types ¶
type CacheEntry ¶
CacheEntry represents a cached file with metadata
type IllustrationImage ¶
type MarkdownStatement ¶
type ObjectStore ¶
type OriginNote ¶
OriginNote represents origin notes with language and information.
type StatementImage ¶
type Task ¶
type Task struct {
// url slug friendly identifier
ShortId string
// full name of the task in multiple languages (key: ISO 639 code)
FullName map[string]string
// original language of the task (ISO 639 code), may be empty
OrigLang string
// markdown with todos, notes, etc.
Readme string
// illustration image
IllustrImg *IllustrationImage
// constraints
MemLimMegabytes int
CpuTimeLimSecs float64
// metadata (origin, difficulty)
OriginOlympiad string
OriginNotes []OriginNote
DifficultyRating int
OriginOrg string
OriginYear string
OlympStage string
OriginDivisions []string
// statement
MdStatements []MarkdownStatement
MdImages []StatementImage
VisInpSubtasks []VisibleInputSubtask
Examples []Example
Subtasks []Subtask
// testing
Tests []Test
Checker string
Interactor string
// scoring
TestGroups []TestGroup
// metadata: authors (free-form names)
Authors []string
// metadata: problem tags (free-form short labels)
ProblemTags []string
// original full archive S3 key (optional)
OgFilesZipS3Key string
Solutions []Solution
}
func (*Task) CheckerPtr ¶
func (*Task) DefaultFullName ¶
DefaultFullName returns the preferred full name, prioritizing OrigLang, then 'lv', then any available name.
func (*Task) FindTestgroupSubtasks ¶
func (*Task) InteractorPtr ¶
type TaskPgRepo ¶
type TaskPgRepo interface {
GetTask(ctx context.Context, shortId string) (Task, error)
GetTaskPreview(ctx context.Context, shortId string) (TaskPreview, error)
SearchTasksByName(ctx context.Context, name string) ([]string, error)
ListTasks(ctx context.Context, limit int, offset int) ([]Task, error)
ListTaskPreviews(ctx context.Context, limit int, offset int) ([]TaskPreview, error)
ResolveNames(ctx context.Context, shortIds []string) ([]string, error)
Exists(ctx context.Context, shortId string) (bool, error)
CreateTask(ctx context.Context, task Task) error
DeleteTask(ctx context.Context, shortId string) error
UpdateStatement(ctx context.Context, taskId string, statement MarkdownStatement) error
AddStatementImg(ctx context.Context, taskId string, img StatementImage) error
DeleteStatementImg(ctx context.Context, taskId string, filename string) error
UpdateIllustrationImg(ctx context.Context, taskId string, img IllustrationImage) error
}
type TaskPreview ¶
type TaskPreview struct {
ShortId string
FullName map[string]string
OrigLang string
IllustrImg *IllustrationImage
DifficultyRating int
OriginOlympiad string
OriginNote string
OriginNoteShort string
OriginOrg string
OriginYear string
OlympStage string
OriginDivisions []string
MdStatementStory string
}
func (*TaskPreview) DefaultFullName ¶
func (t *TaskPreview) DefaultFullName() string
DefaultFullName returns the preferred full name for TaskPreview.
type TaskService ¶
type TaskService interface {
GetTask(ctx context.Context, shortId string) (Task, srvcerror.E)
CreateTask(ctx context.Context, task Task) srvcerror.E
DeleteTask(ctx context.Context, shortId string) srvcerror.E
// test files
UploadTestFile(ctx context.Context, body []byte) srvcerror.E
GetTestDownlUrl(ctx context.Context, testFileSha256 string) (string, srvcerror.E)
DownloadTestFile(ctx context.Context, testFileSha256 string) ([]byte, srvcerror.E)
// illustration image
UploadIllustrationImg(ctx context.Context, mimeType string, body []byte) (string, srvcerror.E)
DeleteIllustrationImg(ctx context.Context, taskId string) srvcerror.E
UpdateIllustrationImg(ctx context.Context, taskId string, img IllustrationImage) srvcerror.E
GetHttpUrlForIllustrImg(ctx context.Context, illstrImgS3Key string) (string, srvcerror.E)
// markdown statement
UpdateStatementMd(ctx context.Context, taskId string, statement MarkdownStatement) srvcerror.E
// markdown statement image
UploadStatementImage(ctx context.Context, taskId string, filename string, mimeType string, body []byte) (string, srvcerror.E)
DeleteStatementImage(ctx context.Context, taskId string, filename string) srvcerror.E
GetHttpUrlForStatementImage(ctx context.Context, statementImageS3Key string) (string, srvcerror.E)
// website
GetTaskPreview(ctx context.Context, shortId string) (TaskPreview, srvcerror.E)
ListTaskPreviews(ctx context.Context) ([]TaskPreview, srvcerror.E)
// taskzip archive format
ImportTaskFromZip(ctx context.Context, zipBytes []byte, overrideId string) (string, srvcerror.E)
ExportTaskAsZip(ctx context.Context, taskId string) ([]byte, srvcerror.E)
// unorganized
GetTaskFullNames(ctx context.Context, shortIds []string) ([]string, srvcerror.E)
ResolveNames(ctx context.Context, shortIds []string) ([]string, srvcerror.E)
SearchTasksByName(ctx context.Context, name string) ([]string, srvcerror.E)
}
type TaskSrvcOption ¶
type TaskSrvcOption func(*taskSrvc)
func WithPublicAPIBaseURL ¶
func WithPublicAPIBaseURL(baseURL string) TaskSrvcOption
func WithTestfileDownloadSigningKey ¶
func WithTestfileDownloadSigningKey(key []byte) TaskSrvcOption
type TestFileCache ¶
type TestFileCache struct {
// contains filtered or unexported fields
}
TestFileCache manages cached test files with size limits and LRU eviction
func NewTestFileCache ¶
func NewTestFileCache() *TestFileCache
NewTestFileCache creates a new test file cache
func (*TestFileCache) GetCacheStats ¶
func (c *TestFileCache) GetCacheStats() (totalSize int64, fileCount int, err error)
GetCacheStats returns cache statistics
type VisInpSubtaskTest ¶
type VisibleInputSubtask ¶
type VisibleInputSubtask struct {
SubtaskId int
Tests []VisInpSubtaskTest
}