feat: gamemaster

This commit is contained in:
Ilia Denisov
2026-05-03 07:59:03 +02:00
committed by GitHub
parent a7cee15115
commit 3e2622757e
229 changed files with 41521 additions and 1098 deletions
@@ -0,0 +1,98 @@
package handlers
import (
"context"
"galaxy/gamemaster/internal/domain/engineversion"
"galaxy/gamemaster/internal/domain/runtime"
"galaxy/gamemaster/internal/service/adminbanish"
"galaxy/gamemaster/internal/service/adminforce"
"galaxy/gamemaster/internal/service/adminpatch"
"galaxy/gamemaster/internal/service/adminstop"
"galaxy/gamemaster/internal/service/commandexecute"
engineversionsvc "galaxy/gamemaster/internal/service/engineversion"
"galaxy/gamemaster/internal/service/livenessreply"
"galaxy/gamemaster/internal/service/orderput"
"galaxy/gamemaster/internal/service/registerruntime"
"galaxy/gamemaster/internal/service/reportget"
)
//go:generate go run go.uber.org/mock/mockgen -destination=./mocks/mock_services.go -package=mocks galaxy/gamemaster/internal/api/internalhttp/handlers RegisterRuntimeService,ForceNextTurnService,StopRuntimeService,PatchRuntimeService,BanishRaceService,LivenessService,CommandExecuteService,OrderPutService,ReportGetService,MembershipInvalidator,EngineVersionService,RuntimeRecordsReader
// RegisterRuntimeService wires the `internalRegisterRuntime` handler
// to the underlying register-runtime orchestrator.
type RegisterRuntimeService interface {
Handle(ctx context.Context, in registerruntime.Input) (registerruntime.Result, error)
}
// ForceNextTurnService wires the `internalForceNextTurn` handler.
type ForceNextTurnService interface {
Handle(ctx context.Context, in adminforce.Input) (adminforce.Result, error)
}
// StopRuntimeService wires the `internalStopRuntime` handler.
type StopRuntimeService interface {
Handle(ctx context.Context, in adminstop.Input) (adminstop.Result, error)
}
// PatchRuntimeService wires the `internalPatchRuntime` handler.
type PatchRuntimeService interface {
Handle(ctx context.Context, in adminpatch.Input) (adminpatch.Result, error)
}
// BanishRaceService wires the `internalBanishRace` handler.
type BanishRaceService interface {
Handle(ctx context.Context, in adminbanish.Input) (adminbanish.Result, error)
}
// LivenessService wires the `internalGameLiveness` handler.
type LivenessService interface {
Handle(ctx context.Context, in livenessreply.Input) (livenessreply.Result, error)
}
// CommandExecuteService wires the `internalExecuteCommands` handler.
type CommandExecuteService interface {
Handle(ctx context.Context, in commandexecute.Input) (commandexecute.Result, error)
}
// OrderPutService wires the `internalPutOrders` handler.
type OrderPutService interface {
Handle(ctx context.Context, in orderput.Input) (orderput.Result, error)
}
// ReportGetService wires the `internalGetReport` handler.
type ReportGetService interface {
Handle(ctx context.Context, in reportget.Input) (reportget.Result, error)
}
// MembershipInvalidator wires the `internalInvalidateMemberships`
// handler. Backed by `service/membership.Cache.Invalidate`.
type MembershipInvalidator interface {
// Invalidate purges the in-process membership cache entry for
// gameID. The call is fire-and-forget and never returns an error;
// missing entries are a no-op.
Invalidate(gameID string)
}
// EngineVersionService wires every engine-version registry handler. The
// service exposes one Go-error-returning method per OpenAPI operation;
// the handler layer translates the wrapped sentinel errors into
// `engine_version_*` codes via `mapServiceError`.
type EngineVersionService interface {
List(ctx context.Context, statusFilter *engineversion.Status) ([]engineversion.EngineVersion, error)
Get(ctx context.Context, version string) (engineversion.EngineVersion, error)
ResolveImageRef(ctx context.Context, version string) (string, error)
Create(ctx context.Context, in engineversionsvc.CreateInput) (engineversion.EngineVersion, error)
Update(ctx context.Context, in engineversionsvc.UpdateInput) (engineversion.EngineVersion, error)
Deprecate(ctx context.Context, in engineversionsvc.DeprecateInput) error
}
// RuntimeRecordsReader exposes the read-only subset of
// `ports.RuntimeRecordStore` required by the get/list runtime
// handlers. The narrower surface keeps the handler layer from
// inadvertently mutating runtime state.
type RuntimeRecordsReader interface {
Get(ctx context.Context, gameID string) (runtime.RuntimeRecord, error)
List(ctx context.Context) ([]runtime.RuntimeRecord, error)
ListByStatus(ctx context.Context, status runtime.Status) ([]runtime.RuntimeRecord, error)
}