Documentation
¶
Index ¶
- 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) 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
Constants ¶
This section is empty.
Variables ¶
This section is empty.
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) 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"])
}
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.