Documentation
¶
Index ¶
- Constants
- Variables
- type AccountLogic
- type CompileLogic
- type CompileOutput
- type CreateAccountInput
- type CreateAccountOutput
- type CreateProblemInput
- type CreateProblemOutput
- type CreateSessionInput
- type CreateSessionOutput
- type CreateSubmissionInput
- type CreateSubmissionOutput
- type CreateTestCaseInput
- type CreateTestCaseOutput
- type DeleteProblemInput
- type DeleteSessionInput
- type DeleteTestCaseInput
- type DeleteTestCaseOutput
- type ExecuteLogic
- type ExecuteOutput
- type ExecuteSubmissionInput
- type GetAccountInput
- type GetAccountOutput
- type GetAccountProblemSubmissionListInput
- type GetAccountProblemSubmissionListOutput
- type GetProblemInput
- type GetProblemListInput
- type GetProblemListOutput
- type GetProblemOutput
- type GetProblemSubmissionListInput
- type GetProblemSubmissionListOutput
- type GetProblemTestCaseListInput
- type GetProblemTestCaseListOutput
- type GetSubmissionInput
- type GetSubmissionListInput
- type GetSubmissionListOutput
- type GetSubmissionOutput
- type GetTestCaseInput
- type GetTestCaseOutput
- type HashLogic
- type JudgeLogic
- type Problem
- type ProblemLogic
- type RoleLogic
- type Submission
- type SubmissionLogic
- type TestCase
- type TestCaseLogic
- type TokenLogic
- type UpdateProblemInput
- type UpdateProblemOutput
- type UpdateTestCaseInput
- type UpdateTestCaseOutput
Constants ¶
View Source
const ( AccountRoleAdmin = "Admin" AccountRoleProblemSetter = "ProblemSetter" AccountRoleContester = "Contester" AccountRoleWorker = "Worker" )
Variables ¶
View Source
var ( ErrProblemNotFound = status.Error(codes.NotFound, "problem not found") ErrTestCaseNotFound = status.Error(codes.NotFound, "test case not found") ErrAccountNotFound = status.Error(codes.NotFound, "account not found") ErrPermissionDenied = status.Error(codes.PermissionDenied, "permission denied") ErrInternal = status.Error(codes.Internal, "internal error") ErrTokenInvalid = status.Error(codes.Unauthenticated, "invalid authentication token") ErrAccountAlreadyExists = status.Error(codes.AlreadyExists, "account name already exists") )
View Source
var ( PermissionAccountsReadSelf = gorbac.NewLayerPermission("accounts:read:self") PermissionAccountsWriteSelf = gorbac.NewLayerPermission("accounts:write:self") PermissionAccountsReadAll = gorbac.NewLayerPermission("accounts:read") PermissionAccountsWriteAll = gorbac.NewLayerPermission("accounts:write") PermissionTestCasesReadSelf = gorbac.NewLayerPermission("testcases:read:self") PermissionTestCasesWriteSelf = gorbac.NewLayerPermission("testcases:write:self") PermissionTestCasesReadAll = gorbac.NewLayerPermission("testcases:read") PermissionTestCasesWriteAll = gorbac.NewLayerPermission("testcases:write") PermissionSubmissionsReadSelf = gorbac.NewLayerPermission("submissions:read:self") PermissionSubmissionsWriteSelf = gorbac.NewLayerPermission("submissions:write:self") PermissionSubmissionsReadAll = gorbac.NewLayerPermission("submissions:read") PermissionSubmissionsWriteAll = gorbac.NewLayerPermission("submissions:write") PermissionProblemsReadSelf = gorbac.NewLayerPermission("problems:read:self") PermissionProblemsWriteSelf = gorbac.NewLayerPermission("problems:write:self") PermissionProblemsReadAll = gorbac.NewLayerPermission("problems:read") PermissionProblemsWriteAll = gorbac.NewLayerPermission("problems:write") )
Functions ¶
This section is empty.
Types ¶
type AccountLogic ¶
type AccountLogic interface { CreateAccount(ctx context.Context, in CreateAccountInput) (CreateAccountOutput, error) GetAccount(ctx context.Context, in GetAccountInput) (GetAccountOutput, error) CreateSession(ctx context.Context, in CreateSessionInput) (CreateSessionOutput, error) DeleteSession(ctx context.Context, in DeleteSessionInput) error }
func NewAccountLogic ¶
func NewAccountLogic( database database.Database, accountDataAccessor database.AccountDataAccessor, passwordDataAccessor database.AccountPasswordDataAccessor, hashLogic HashLogic, tokenLogic TokenLogic, roleLogic RoleLogic, takenAccountNameCache cache.TakenAccountName, logger *zap.Logger, ) AccountLogic
type CompileLogic ¶
type CompileLogic interface {
Compile(ctx context.Context, content string) (CompileOutput, error)
}
type CompileOutput ¶
type CreateAccountInput ¶
type CreateProblemInput ¶
type CreateProblemOutput ¶
type CreateProblemOutput struct {
Problem Problem
}
type CreateSessionInput ¶
type CreateSessionOutput ¶
type CreateSubmissionInput ¶
type CreateSubmissionOutput ¶
type CreateSubmissionOutput struct {
Submission Submission
}
type CreateTestCaseInput ¶
type CreateTestCaseOutput ¶
type CreateTestCaseOutput struct {
TestCase TestCase
}
type DeleteProblemInput ¶
type DeleteSessionInput ¶
type DeleteSessionInput struct {
Token string
}
type DeleteTestCaseInput ¶
type DeleteTestCaseOutput ¶
type DeleteTestCaseOutput struct{}
type ExecuteLogic ¶
type ExecuteOutput ¶
type ExecuteSubmissionInput ¶
type GetAccountInput ¶
type GetAccountProblemSubmissionListOutput ¶
type GetAccountProblemSubmissionListOutput struct { Submissions []Submission TotalSubmissionsCount uint64 }
type GetProblemInput ¶
type GetProblemListInput ¶
type GetProblemListOutput ¶
type GetProblemOutput ¶
type GetProblemOutput struct {
Problem Problem
}
type GetProblemSubmissionListOutput ¶
type GetProblemSubmissionListOutput struct { Submissions []Submission TotalSubmissionsCount uint64 }
type GetSubmissionInput ¶
type GetSubmissionListInput ¶
type GetSubmissionListOutput ¶
type GetSubmissionListOutput struct { Submissions []Submission TotalSubmissionsCount uint64 }
type GetSubmissionOutput ¶
type GetSubmissionOutput struct {
Submission Submission
}
type GetTestCaseInput ¶
type GetTestCaseOutput ¶
type GetTestCaseOutput struct {
TestCase TestCase
}
type HashLogic ¶
type HashLogic interface { HashPassword(ctx context.Context, plainPassword string) (string, error) IsHashEqual(ctx context.Context, plainPassword string, hashedPassword string) (bool, error) }
func NewHashLogic ¶
type JudgeLogic ¶
type JudgeLogic interface {
Judge(ctx context.Context, submission Submission) (ojs.SubmissionResult, error)
}
func NewJudgeLogic ¶
func NewJudgeLogic( problemDataAccessor database.ProblemDataAccessor, submissionDataAccessor database.SubmissionDataAccessor, testCaseDataAccessor database.TestCaseDataAccessor, dockerClient *client.Client, judgeConfig configs.Judge, appArguments utils.Arguments, logger *zap.Logger, ) (JudgeLogic, error)
type ProblemLogic ¶
type ProblemLogic interface { CreateProblem(ctx context.Context, in CreateProblemInput) (CreateProblemOutput, error) GetProblem(ctx context.Context, in GetProblemInput) (GetProblemOutput, error) GetProblemList(ctx context.Context, in GetProblemListInput) (GetProblemListOutput, error) UpdateProblem(ctx context.Context, in UpdateProblemInput) (UpdateProblemOutput, error) DeleteProblem(ctx context.Context, in DeleteProblemInput) error }
func NewProblemLogic ¶
func NewProblemLogic( logger *zap.Logger, accountDataAccessor database.AccountDataAccessor, problemDataAccessor database.ProblemDataAccessor, submissionDataAccessor database.SubmissionDataAccessor, testCaseDataAccessor database.TestCaseDataAccessor, tokenLogic TokenLogic, roleLogic RoleLogic, ) ProblemLogic
type RoleLogic ¶
type RoleLogic interface {
AccountHasPermission(ctx context.Context, accountRole string, permissions ...gorbac.Permission) (bool, error)
}
func NewRoleLogic ¶
type Submission ¶
type Submission struct { ID uint64 AuthorID uint64 OfProblemID uint64 Content string Language string Status ojs.SubmissionStatus Result ojs.SubmissionResult }
type SubmissionLogic ¶
type SubmissionLogic interface { CreateSubmission(ctx context.Context, in CreateSubmissionInput) (CreateSubmissionOutput, error) GetSubmission(ctx context.Context, in GetSubmissionInput) (GetSubmissionOutput, error) GetSubmissionList(ctx context.Context, in GetSubmissionListInput) (GetSubmissionListOutput, error) GetAccountProblemSubmissionList(ctx context.Context, in GetAccountProblemSubmissionListInput) (GetAccountProblemSubmissionListOutput, error) GetProblemSubmissionList(ctx context.Context, in GetProblemSubmissionListInput) (GetProblemSubmissionListOutput, error) ExecuteSubmission(ctx context.Context, in ExecuteSubmissionInput) error }
func NewSubmissionLogic ¶
func NewSubmissionLogic( logger *zap.Logger, accountDataAccessor database.AccountDataAccessor, problemDataAccessor database.ProblemDataAccessor, submissionDataAccessor database.SubmissionDataAccessor, testCaseDataAccessor database.TestCaseDataAccessor, tokenLogic TokenLogic, judgeLogic JudgeLogic, roleLogic RoleLogic, submissionCreatedProducer producer.SubmissionCreatedProducer, database database.Database, ) SubmissionLogic
type TestCaseLogic ¶
type TestCaseLogic interface { CreateTestCase(ctx context.Context, in CreateTestCaseInput) (CreateTestCaseOutput, error) GetTestCase(ctx context.Context, in GetTestCaseInput) (GetTestCaseOutput, error) GetProblemTestCaseList(ctx context.Context, in GetProblemTestCaseListInput) (GetProblemTestCaseListOutput, error) UpdateTestCase(ctx context.Context, in UpdateTestCaseInput) (UpdateTestCaseOutput, error) DeleteTestCase(ctx context.Context, in DeleteTestCaseInput) error }
func NewTestCaseLogic ¶
func NewTestCaseLogic( logger *zap.Logger, accountDataAccessor database.AccountDataAccessor, problemDataAccessor database.ProblemDataAccessor, submissionDataAccessor database.SubmissionDataAccessor, testCaseDataAccessor database.TestCaseDataAccessor, tokenLogic TokenLogic, roleLogic RoleLogic, ) TestCaseLogic
type TokenLogic ¶
type TokenLogic interface { CreateTokenString(ctx context.Context, accountID uint64, accountName string, accountRole int8) (string, time.Time, error) VerifyTokenString(ctx context.Context, token string) (accountId uint64, accountName string, accountRole int8, expiresAt time.Time, err error) WithDatabase(database database.Database) TokenLogic }
func NewTokenLogic ¶
func NewTokenLogic( accountDataAccessor database.AccountDataAccessor, tokenPublicKeyDataAccessor database.TokenPublicKeyDataAccessor, logger *zap.Logger, authConfig configs.Auth, tokenPublicKeyCache cache.TokenPublicKey, ) (TokenLogic, error)
type UpdateProblemInput ¶
type UpdateProblemOutput ¶
type UpdateProblemOutput struct {
Problem Problem
}
type UpdateTestCaseInput ¶
type UpdateTestCaseOutput ¶
type UpdateTestCaseOutput struct {
TestCase TestCase
}
Click to show internal directories.
Click to hide internal directories.