Documentation
¶
Index ¶
- Constants
- func HandleServer(log *slog.Logger, mux *http.ServeMux, prefix string, a API, cfg ServerConfig) error
- func IsErrorRetriable(err error) bool
- func MatchesError(err error, code ErrorCode) bool
- type API
- type ByeRequest
- type ByeResponse
- type ClientOptions
- type Error
- type ErrorCode
- type HelloRequest
- type HelloResponse
- type Job
- type JobEngine
- type JobRequest
- type JobResponse
- type ServerConfig
- type TokenChecker
- type UpdateRequest
- type UpdateResponse
- type UpdateStatus
Constants ¶
View Source
const ProtoVersion = 1
Variables ¶
This section is empty.
Functions ¶
func HandleServer ¶
func IsErrorRetriable ¶
func MatchesError ¶
Types ¶
type API ¶
type API interface {
Update(ctx context.Context, req *UpdateRequest) (*UpdateResponse, error)
Job(ctx context.Context, req *JobRequest) (*JobResponse, error)
Hello(ctx context.Context, req *HelloRequest) (*HelloResponse, error)
Bye(ctx context.Context, req *ByeRequest) (*ByeResponse, error)
}
type ByeRequest ¶
type ByeRequest struct {
RoomID string `json:"room_id"`
}
type ByeResponse ¶
type ByeResponse struct{}
type ClientOptions ¶
type HelloRequest ¶
type HelloRequest struct {
SupportedProtoVersions []int32 `json:"supported_proto_versions"`
}
type HelloResponse ¶
type Job ¶
type Job struct {
ID string `json:"id" gorm:"primaryKey"`
FixedTime *time.Duration `json:"fixed_time,omitempty"`
TimeControl *clock.Control `json:"time_control,omitempty" gorm:"serializer:chess"`
StartBoard *chess.RawBoard `json:"start_board,omitempty" gorm:"serializer:chess"`
StartMoves []chess.UCIMove `json:"start_moves,omitempty" gorm:"serializer:json"`
ScoreThreshold int32 `json:"score_threshold,omitempty"`
TimeMargin *time.Duration `json:"time_margin,omitempty"`
White JobEngine `json:"white" gorm:"serializer:json"`
Black JobEngine `json:"black" gorm:"serializer:json"`
}
type JobRequest ¶
type JobResponse ¶
type JobResponse struct {
Job Job `json:"job"`
}
type ServerConfig ¶
type ServerConfig struct {
TokenChecker TokenChecker
}
type TokenChecker ¶
type UpdateRequest ¶
type UpdateRequest struct {
SeqIndex uint64 `json:"seq_index"`
RoomID string `json:"room_id"`
JobID string `json:"job_id"`
From delta.JobCursor `json:"from"`
Delta *delta.JobState `json:"delta"`
Timestamp delta.Timestamp `json:"ts"`
Status UpdateStatus `json:"status,omitempty"`
Error string `json:"error,omitempty"`
}
type UpdateResponse ¶
type UpdateResponse struct{}
type UpdateStatus ¶
type UpdateStatus string
const ( UpdateContinue UpdateStatus = "" UpdateDone UpdateStatus = "done" UpdateFail UpdateStatus = "fail" UpdateAbort UpdateStatus = "abort" )
Click to show internal directories.
Click to hide internal directories.