Documentation
¶
Index ¶
- Variables
- func RunContainerToCompletion(ctx context.Context, opts RunOnceContainerOptions) (int, error)
- type BackgroundGameServer
- func (s *BackgroundGameServer) BaseURL() *url.URL
- func (s *BackgroundGameServer) ContainerName() string
- func (s *BackgroundGameServer) GracefulShutdown(ctx context.Context) error
- func (s *BackgroundGameServer) History() []MetricSample
- func (s *BackgroundGameServer) Shutdown(ctx context.Context) error
- func (s *BackgroundGameServer) Start(ctx context.Context) error
- func (s *BackgroundGameServer) TerminateSilently(ctx context.Context) error
- type GameServerOptions
- type MetricSample
- type RunOnceContainer
- type RunOnceContainerOptions
- type RunOnceContainerResult
- type ShardingStepState
Constants ¶
This section is empty.
Variables ¶
var DatabaseReshardingTables = []string{
"GlobalStates",
"AuditLogEvents",
"AuthEntries",
"Players",
"PlayerNameSearches",
"PlayerDeletionRecords",
"PlayerEventLogSegments",
"InAppPurchases",
"DatabaseScanCoordinators",
"DatabaseScanWorkers",
"StaticGameConfigs",
"SegmentEstimates",
}
DatabaseReshardingTables is the set of database tables whose row counts are validated across resharding steps. It mirrors the legacy Scripts/legacy-tests.py table list.
MetaInfo is deliberately excluded because it grows monotonically (a row is appended on each server startup) and therefore can't be compared for equality step-to-step. The list is an explicit allow-list for fidelity with the legacy test; it needs to be kept in sync if the SDK schema changes.
Functions ¶
func RunContainerToCompletion ¶
func RunContainerToCompletion(ctx context.Context, opts RunOnceContainerOptions) (int, error)
RunContainerToCompletion is a convenience function that creates and runs a container to completion. It returns the exit code and any error that occurred.
Types ¶
type BackgroundGameServer ¶
type BackgroundGameServer struct {
// contains filtered or unexported fields
}
BackgroundGameServer wraps a running container with a background metrics collector.
func NewGameServer ¶
func NewGameServer(opts GameServerOptions) *BackgroundGameServer
NewGameServer creates a wrapper with the given options (does not start the container).
func (*BackgroundGameServer) BaseURL ¶
func (s *BackgroundGameServer) BaseURL() *url.URL
BaseURL returns the discovered host base URL for convenience (e.g. for client tests).
func (*BackgroundGameServer) ContainerName ¶
func (s *BackgroundGameServer) ContainerName() string
ContainerName returns the container name for network sharing purposes.
func (*BackgroundGameServer) GracefulShutdown ¶
func (s *BackgroundGameServer) GracefulShutdown(ctx context.Context) error
GracefulShutdown requests a clean shutdown via the system HTTP server's /gracefulShutdown endpoint, waits for the server to flush its state and self-exit, and then tears down the container. This is the shutdown path to use after populating an on-disk SQLite database, so that the shard files are checkpointed and closed cleanly before they are read from the host. The server must have been started with DisableSigtermWait=true, otherwise it would block waiting for SIGTERM after the graceful shutdown.
func (*BackgroundGameServer) History ¶
func (s *BackgroundGameServer) History() []MetricSample
History returns a copy of the current in-memory metrics history.
func (*BackgroundGameServer) Shutdown ¶
func (s *BackgroundGameServer) Shutdown(ctx context.Context) error
Shutdown stops the metrics collector first, then terminates the container.
func (*BackgroundGameServer) Start ¶
func (s *BackgroundGameServer) Start(ctx context.Context) error
Start launches the server container, waits for readiness, and starts metrics collection.
func (*BackgroundGameServer) TerminateSilently ¶
func (s *BackgroundGameServer) TerminateSilently(ctx context.Context) error
TerminateSilently helps internal error paths to try to clean up without masking errors.
type GameServerOptions ¶
type GameServerOptions struct {
Image string // e.g. "lovely-wombats-build/server:test"
SystemPort string // container port for SystemHttpServer (usually "8888/tcp")
PollInterval time.Duration // how often to collect metrics
HistoryLimit int // max samples kept in memory (0 or <0 => unbounded)
Env map[string]string
ExposedPorts []string // optional override; defaults to []string{Port}
ContainerName string // optional; useful in CI logs
Cmd []string // optional command/args to run inside the container (e.g. ["gameserver", "-LogLevel=Information"])
ExtraArgs []string // additional args to append to the default Cmd
ExtraEnv map[string]string // additional env vars to merge with defaults (overrides on conflict)
Mounts []string // optional bind mounts in "host:container" format
// Persistent on-disk SQLite support (used by the database-resharding test, which needs the shard
// files to survive across multiple server invocations). When unset, the server uses the default
// stateless in-memory SQLite.
SqlitePersistDir string // when non-empty, use on-disk SQLite stored in this (container) directory instead of in-memory
NumActiveShards int // when > 0, sets --Database:NumActiveShards (triggers resharding at startup against existing shard files)
DisableSigtermWait bool // when true, sets --Environment:WaitForSigtermBeforeExit=false so an HTTP graceful shutdown lets the process self-exit
DisableExitOnLogError bool // when true, sets --Environment:ExitOnLogError=false so transient errors under heavy load don't terminate the server
}
GameServerOptions configures the server container and the poller behavior.
type MetricSample ¶
type MetricSample struct {
At time.Time
Raw string // Placeholder: raw response or serialized snapshot
Err error // Non-nil if collection failed
Duration time.Duration
}
MetricSample is a single metrics collection result.
type RunOnceContainer ¶
type RunOnceContainer struct {
// contains filtered or unexported fields
}
RunOnceContainer wraps a container that runs to completion.
func NewRunOnceContainer ¶
func NewRunOnceContainer(opts RunOnceContainerOptions) *RunOnceContainer
NewRunOnceContainer creates a wrapper for a run-once container with the given options.
func (*RunOnceContainer) Cleanup ¶
func (r *RunOnceContainer) Cleanup(ctx context.Context) error
Cleanup terminates and removes the container if it's still running.
func (*RunOnceContainer) ExitCode ¶
func (r *RunOnceContainer) ExitCode() int
ExitCode returns the exit code of the completed container. Returns -1 if the container hasn't completed yet.
func (*RunOnceContainer) IsCompleted ¶
func (r *RunOnceContainer) IsCompleted() bool
IsCompleted returns true if the container has finished running.
type RunOnceContainerOptions ¶
type RunOnceContainerOptions struct {
Image string // e.g. "myorg/myapp:latest"
Cmd []string // command/args to run inside the container
Env map[string]string // environment variables
ExposedPorts []string // optional ports to expose (e.g. ["8080/tcp"])
ContainerName string // optional; useful in CI logs
LogPrefix string // prefix for container logs (e.g. "[build] ")
WorkingDir string // optional working directory inside container
Mounts []string // optional bind mounts in "host:container" format
AutoRemove bool // equivalent to docker run --rm (default: true)
Network string // network mode (e.g. "container:name", "bridge", "host")
ExtraDockerArgs []string // additional docker run arguments for other flags
}
RunOnceContainerOptions configures a container that runs to completion.
type RunOnceContainerResult ¶
RunOnceContainerResult holds the result of a completed run-once container.
type ShardingStepState ¶
ShardingStepState captures the per-table row counts observed for one resharding step, keyed by table name. Each value is the list of row counts across the active shards (index = shard number). It is the Go equivalent of the legacy ShardingStepState.
func ValidateShardingStep ¶
func ValidateShardingStep(shardDir string, tables []string, numShards, numActiveShards int, priorSteps []ShardingStepState) (ShardingStepState, error)
ValidateShardingStep reads the current shard state from shardDir, validates table existence per shard, compares the row counts against all prior steps, and returns the new step state (to be appended to the running list of prior steps by the caller). It is a direct port of the legacy DatabaseShardingValidationTask.