Documentation
¶
Index ¶
- Constants
- Variables
- type ContestData
- type ContestFullData
- type ContestInfo
- type ContestKind
- type ContestSettings
- type ContestStatus
- type ContestStatusKind
- type DB
- type FinishedJob
- type JobInfo
- type MatchData
- type MatchSettings
- type OpeningBook
- type OpeningBookKind
- type Options
- type RunningJob
- type Schedule
- type ScheduleKey
- type Scheduler
- func (s *Scheduler) AbortContest(contestID string, reason string)
- func (s *Scheduler) CreateContest(ctx context.Context, settings ContestSettings) (ContestInfo, error)
- func (s *Scheduler) GetContest(ctx context.Context, contestID string) (ContestInfo, ContestData, error)
- func (s *Scheduler) IsJobAborted(jobID string) (string, bool)
- func (s *Scheduler) ListAllContests(ctx context.Context) ([]ContestFullData, error)
- func (s *Scheduler) ListContestSucceededJobs(ctx context.Context, contestID string) ([]FinishedJob, error)
- func (s *Scheduler) ListRunningContests() []ContestFullData
- func (s *Scheduler) NextJob(ctx context.Context) (*roomapi.Job, error)
- func (s *Scheduler) OnJobFinished(jobID string, status roomkeeper.JobStatus, game *battle.GameExt)
Constants ¶
View Source
const ContestNameMaxLen = 128
Variables ¶
View Source
var ErrNoSuchContest = errors.New("no such contest")
Functions ¶
This section is empty.
Types ¶
type ContestData ¶
type ContestData struct {
Status ContestStatus `gorm:"embedded;embeddedPrefix:status_"`
LastIndex int64
FailedJobs int64
Match *MatchData `gorm:"-"`
}
func (ContestData) Clone ¶
func (d ContestData) Clone() ContestData
type ContestFullData ¶
type ContestFullData struct {
Info ContestInfo
Data ContestData
}
type ContestInfo ¶
type ContestInfo struct {
ID string `gorm:"primaryKey"`
ContestSettings
PosInQueue uint64
}
func (*ContestInfo) BuildSchedule ¶
func (i *ContestInfo) BuildSchedule(d *ContestData) (Schedule, error)
func (ContestInfo) Clone ¶
func (i ContestInfo) Clone() ContestInfo
func (*ContestInfo) NewData ¶
func (i *ContestInfo) NewData() ContestData
type ContestKind ¶
type ContestKind int
const ( ContestUnknownKind ContestKind = iota ContestMatch )
func (ContestKind) PrettyString ¶
func (k ContestKind) PrettyString() string
type ContestSettings ¶
type ContestSettings struct {
Name string
FixedTime *time.Duration
TimeControl *clock.Control `gorm:"serializer:chess"`
OpeningBook OpeningBook `gorm:"embedded;embeddedPrefix:opening_"`
ScoreThreshold int32
TimeMargin *time.Duration
Kind ContestKind
Players []roomapi.JobEngine `gorm:"serializer:json"`
Match *MatchSettings `gorm:"-"`
}
func (ContestSettings) Clone ¶
func (s ContestSettings) Clone() ContestSettings
func (*ContestSettings) Validate ¶
func (s *ContestSettings) Validate() error
type ContestStatus ¶
type ContestStatus struct {
Kind ContestStatusKind `gorm:"index"`
Reason string
}
func NewStatusAborted ¶
func NewStatusAborted(reason string) ContestStatus
func NewStatusFailed ¶
func NewStatusFailed(reason string) ContestStatus
func NewStatusRunning ¶
func NewStatusRunning() ContestStatus
func NewStatusSucceeded ¶
func NewStatusSucceeded() ContestStatus
type ContestStatusKind ¶
type ContestStatusKind int
const ( ContestUnknownStatus ContestStatusKind = iota ContestRunning ContestSucceeded ContestAborted ContestFailed )
func (ContestStatusKind) IsFinished ¶
func (k ContestStatusKind) IsFinished() bool
func (ContestStatusKind) PrettyString ¶
func (k ContestStatusKind) PrettyString() string
func (ContestStatusKind) String ¶
func (k ContestStatusKind) String() string
type DB ¶
type DB interface {
ListActiveRooms(ctx context.Context) ([]roomkeeper.RoomFullData, error)
ListRunningContestsFull(ctx context.Context) ([]ContestFullData, error)
ListRunningJobs(ctx context.Context) ([]RunningJob, error)
ListContests(ctx context.Context) ([]ContestFullData, error)
CreateContest(ctx context.Context, info ContestInfo, data ContestData) error
UpdateContest(ctx context.Context, contestID string, data ContestData) error
GetContest(ctx context.Context, contestID string) (ContestInfo, ContestData, error)
CreateRunningJob(ctx context.Context, job *RunningJob) error
FinishRunningJob(ctx context.Context, data *ContestData, job *FinishedJob) error
ListContestSucceededJobs(ctx context.Context, contestID string) ([]FinishedJob, error)
}
type FinishedJob ¶
type FinishedJob struct {
JobInfo
Status roomkeeper.JobStatus `gorm:"embedded;embeddedPrefix:status_"`
GameResult chess.Status `gorm:"serializer:chess"`
Index int64 `gorm:"index"`
PGN *string
}
func (FinishedJob) Clone ¶
func (j FinishedJob) Clone() FinishedJob
type JobInfo ¶
type JobInfo struct {
Job roomapi.Job `gorm:"embedded"`
ContestID string `gorm:"index"`
WhiteID int
BlackID int
}
func (JobInfo) ScheduleKey ¶
func (j JobInfo) ScheduleKey() ScheduleKey
type MatchData ¶
type MatchSettings ¶
type MatchSettings struct {
Games int64
}
func (MatchSettings) Clone ¶
func (s MatchSettings) Clone() MatchSettings
type OpeningBook ¶
type OpeningBook struct {
Kind OpeningBookKind
Data string
}
type OpeningBookKind ¶
type OpeningBookKind string
const ( OpeningsNone OpeningBookKind = "" OpeningsPGNLine OpeningBookKind = "pgn_line" OpeningsFEN OpeningBookKind = "fen" OpeningsBuiltin OpeningBookKind = "builtin" BuiltinBookGraham20141F = "graham_2014_1f" BuiltinBookGBSelect2020 = "gb_select_2020" )
type Options ¶
type Options struct {
MaxRunningContests int `toml:"max-running-contests"`
MaxFailedJobs int64 `toml:"max-failed-jobs"`
}
func (*Options) FillDefaults ¶
func (o *Options) FillDefaults()
type RunningJob ¶
type RunningJob struct {
JobInfo
}
func (RunningJob) Clone ¶
func (j RunningJob) Clone() RunningJob
type Schedule ¶
type Schedule struct {
// contains filtered or unexported fields
}
func NewSchedule ¶
func NewSchedule() Schedule
func (*Schedule) Dec ¶
func (s *Schedule) Dec(k ScheduleKey) bool
func (*Schedule) Inc ¶
func (s *Schedule) Inc(k ScheduleKey)
func (*Schedule) Peek ¶
func (s *Schedule) Peek() (ScheduleKey, bool)
type ScheduleKey ¶
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func (*Scheduler) AbortContest ¶
func (*Scheduler) CreateContest ¶
func (s *Scheduler) CreateContest(ctx context.Context, settings ContestSettings) (ContestInfo, error)
func (*Scheduler) GetContest ¶
func (s *Scheduler) GetContest(ctx context.Context, contestID string) (ContestInfo, ContestData, error)
func (*Scheduler) ListAllContests ¶
func (s *Scheduler) ListAllContests(ctx context.Context) ([]ContestFullData, error)
func (*Scheduler) ListContestSucceededJobs ¶
func (*Scheduler) ListRunningContests ¶
func (s *Scheduler) ListRunningContests() []ContestFullData
func (*Scheduler) OnJobFinished ¶
Click to show internal directories.
Click to hide internal directories.