fakegs

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 20, 2025 License: MIT Imports: 7 Imported by: 0

README

Fake Game Server with Agones Integration

The fake game server, or short fakegs, is a standalone executable that acts like a very simple game server in a container environment. It's main goal is to be a drop-in replacement for systems managing game servers for testing purposes.

Features

Supported features are:

  • Transition into Agones the states Ready, Allocated and Shutdown after a configurable duration,
  • Exit after a configured duration,
  • Exit with a pre-defined code,
  • Crash with a pre-defined signal.
Agones

The Agones integration allows scheduled state transitions. The state transitions are performed one after another, if set, in the order Ready, Allocated, Shutdown.

Argument Environment Type Default Example Description
--agones-addr AGONES_ADDR string localhost:9357 - Address to reach the Agones SDK server.
--ready-after READY_AFTER string 0s (disabled) 10s Duration after which to transition to Agones state Ready.
--allocated-after ALLOCATED_AFTER string 0s (disabled) 5s Duration after which to transition to Agones state Allocated. When the ready timer is not set, the timer starts immediately.
--shutdown-after SHUTDOWN_AFTER string 0s (disabled) 30s Duration after which to transition to Agones state Shutdown. When the ready and/or allocated timer is not set, the timer starts immediately.

With the given example values, the fakegs transitions to state Ready after 10s, then 5s later to Allocated (in total after 15s), and 30s later to Shutdown (in total after 45s).

Exit Behavior
Argument Environment Type Default Example Description
--exit-after EXIT_AFTER string 0s (disabled) 2m Duration after which to exit.
--exit-code EXIT_CODE int (auto) 0 Exit with this code, when an exit condition is met.
--exit-signal EXIT_SIGNAL int (none) 11 (SIGSEGV) Send this signal, when an exit condition is met.

With the given example values, the fakegs exits after 2m with a crash (SIGSEGV) (--exit-signal would overwrite --exit-code as the exit condition).

Usage

NAME:
   Fake Game Server with Agones integration - A new cli application

USAGE:
   Fake Game Server with Agones integration [global options] command [command options]

COMMANDS:
   help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help
   --version, -v  print the version

   Agones integration

   --agones-addr value          Address to reach the Agones SDK server. (default: "localhost:9357") [$AGONES_ADDR]
   --allocated-after Allocated  Duration after which to transition to Agones state Allocated. When the ready timer is not set, the timer starts immediately. (default: 0s) [$ALLOCATED_AFTER]
   --ready-after Ready          Duration after which to transition to Agones state Ready. (default: 0s) [$READY_AFTER]
   --shutdown-after Shutdown    Duration after which to transition to Agones state Shutdown. When the ready and/or allocated timer is not set, the timer starts immediately. (default: 0s) [$SHUTDOWN_AFTER]

   Exit behavior

   --exit-after value   Duration after which to exit. (default: 0s) [$EXIT_AFTER]
   --exit-code value    Exit with this code, when an exit condition is met. (default: 0) [$EXIT_CODE]
   --exit-signal value  Send this signal, when an exit condition is met. (default: 0) [$EXIT_SIGNAL]

   Logging

   --log.ctx value [ --log.ctx value ]  A list of context field appended to every log. Format: key=value. [$LOG_CTX]
   --log.format value                   Specify the format of logs. Supported formats: 'logfmt', 'json', 'console'. [$LOG_FORMAT]
   --log.level value                    Specify the log level. e.g. 'trace', 'debug', 'info', 'error'. (default: "info") [$LOG_LEVEL]

or with Docker: docker.io/antiphp/fakegs.

Documentation

Overview

Package fakegs contains the fake game server runtime code.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OptFunc

type OptFunc func(*Server)

OptFunc is an option function to apply server options.

func WithExitAfter

func WithExitAfter(dur time.Duration) OptFunc

WithExitAfter applies the option to exit after a specified duration.

func WithUpdateStateAfter

func WithUpdateStateAfter(state agones.State, dur time.Duration, client *agones.Client) OptFunc

WithUpdateStateAfter applies the option to update the Agones state after a specified duration.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the fake game server.

func New

func New(log *logger.Logger, opts ...OptFunc) *Server

New returns a new fake game server.

func (*Server) Run

func (s *Server) Run(ctx context.Context) (string, error)

Run runs the runtime routine for the fake game server and returns a stop reason or error.

Directories

Path Synopsis
cmd
fakegs command
Package main runs the fake game server.
Package main runs the fake game server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL