Documentation
¶
Index ¶
- Constants
- func LaunchGameServer(config *Config, port uint32) (*os.Process, error)
- type Config
- type MasterClient
- type ServerController
- type SpawnerService
- func (s *SpawnerService) CheckStatus(context.Context, *hotel_pb.CheckStatusRequest) (*hotel_pb.CheckStatusResponse, error)
- func (s *SpawnerService) GetStatus() hotel_pb.SpawnerStatus
- func (s *SpawnerService) SpawnServer(context.Context, *hotel_pb.SpawnServerRequest) (*hotel_pb.SpawnServerResponse, error)
Constants ¶
const DEFAULT_PORT uint32 = 3002
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { SupportedGameID shared.GameIDType `json:"supportedGameId"` MaxGameServers uint32 `json:"maxGameServers"` GameServerPath string `json:"gameServerPath"` GameServerFlags []string `json:"gameServerFlags"` // Whether the spawner should start game servers immediately, versus // waiting for clients to request spawns. Autorun bool `json:"autorun"` // The internet hostname that the spawner and gameservers are running on. // This can be left empty, and the master server will infer host automatically. // However, for a single docker network stack, this is a bad idea because // the master server will discover the docker IP for the spawner rather than // the public IP. So, the best practice is to always set this. Host string `json:"host"` // Port that the spawner is running on. Port uint32 `json:"port"` }
Config contains global configuration for the hotel spawner instance. The configuration is loaded from a JSON file provided at runtime.
func LoadConfig ¶
LoadConfig loads and returns a spawner config from the given path.
type MasterClient ¶
type MasterClient struct {
Addr string
}
MasterClient manages the RPC connection to the master server.
func NewMasterClient ¶
func NewMasterClient(addr string) MasterClient
NewMasterClient initializes and returns a MasterClient.
func (*MasterClient) Register ¶
func (c *MasterClient) Register(port uint32, spawnerStatus hotel_pb.SpawnerStatus) error
Register makes an RPC to the master server to register this spawner instance.
type ServerController ¶
type ServerController struct {
// contains filtered or unexported fields
}
ServerController manages the lifecycle of game server processes.
func NewServerController ¶
func NewServerController(config *Config) *ServerController
NewServerController initializes and returns a ServerController.
func (*ServerController) Capacity ¶
func (c *ServerController) Capacity() int
Capacity returns the number of available server slots on this instance.
func (*ServerController) NumRunningServers ¶
func (c *ServerController) NumRunningServers() int
NumRunningServers returns the number of currently running game serfvers.
func (*ServerController) SpawnServer ¶
func (c *ServerController) SpawnServer() (uint32, error)
SpawnServer attempts to spawn a server process and return its port.
type SpawnerService ¶
type SpawnerService struct {
// contains filtered or unexported fields
}
SpawnerService contains RPC implementations for the spawner service.
func NewSpawnerService ¶
func NewSpawnerService(config *Config, controller *ServerController) SpawnerService
NewSpawnerService creates and initializes a SpawnerService.
func (*SpawnerService) CheckStatus ¶
func (s *SpawnerService) CheckStatus(context.Context, *hotel_pb.CheckStatusRequest) (*hotel_pb.CheckStatusResponse, error)
CheckStatus returns the current status via RPC.
func (*SpawnerService) GetStatus ¶
func (s *SpawnerService) GetStatus() hotel_pb.SpawnerStatus
GetStatus returns the status proto representing the current status of the spawner.
func (*SpawnerService) SpawnServer ¶
func (s *SpawnerService) SpawnServer(context.Context, *hotel_pb.SpawnServerRequest) (*hotel_pb.SpawnServerResponse, error)
SpawnServer attempts to spawn a game server via the incoming RPC request.