allocator

package
v0.0.0-...-d330e10 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Localhost             = "127.0.0.1"
	DefaultGameserverPort = 7777

	SimpleGameServerImage = "gcr.io/pixo-bootstrap/multiplayer/gameservers/simple-server:0.0.6"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocationRequest

type AllocationRequest struct {
	ModuleID           int    `json:"module_id,omitempty"`
	OrgID              int    `json:"org_id,omitempty"`
	ImageRegistry      string `json:"image_registry,omitempty"`
	Engine             string `json:"engine,omitempty"`
	BackfillID         string `json:"backfill_id,omitempty"`
	AllocateGameServer bool   `json:"allocate_game_server,omitempty"`
	ServerVersion      string `json:"server_version,omitempty"`
}

type AllocationResponse

type AllocationResponse struct {
	Results GameServer `json:"results"`
	Error   error      `json:"error"`
}

type Allocator

type Allocator interface {
	AllocateGameserver(request AllocationRequest) AllocationResponse
}

type Client

type Client struct {
	abstractClient.ServiceClient
	// contains filtered or unexported fields
}

Client is a struct for the primary API that contains an abstract client

func NewClient

func NewClient(config urlfinder.ClientConfig) *Client

NewClient is a function that returns a ServiceClient

func NewClientWithBasicAuth

func NewClientWithBasicAuth(username, password string, config urlfinder.ClientConfig) (*Client, error)

NewClientWithBasicAuth is a function that returns a ServiceClient with basic auth

func (*Client) AllocateGameserver

func (a *Client) AllocateGameserver(request AllocationRequest) (*GameServer, error)

AllocateGameserver send a request for a gameserver to the allocator

func (*Client) GetBuildWorkflowLogs

func (a *Client) GetBuildWorkflowLogs(workflowName string) (chan *Log, error)

GetBuildWorkflowLogs returns a channel of logs for a build workflow or an error

func (*Client) GetBuildWorkflows

func (a *Client) GetBuildWorkflows() ([]Workflow, error)

GetBuildWorkflows returns a list of build workflows

func (*Client) Login

func (a *Client) Login(username, password string) error

Login send a login request to the platform

type FleetRequest

type FleetRequest struct {
	ServerConfig  platform.MultiplayerServerConfig  `json:"serverConfig,omitempty"`
	ServerVersion platform.MultiplayerServerVersion `json:"serverVersion,omitempty"`
}

type GameServer

type GameServer struct {
	Name           string   `json:"resource_name,omitempty"`
	IP             string   `json:"ipaddress,omitempty"`
	Port           string   `json:"port,omitempty"`
	SessionName    string   `json:"session_name,omitempty"`
	SessionID      string   `json:"session_id,omitempty"`
	OwningUserName string   `json:"owning_user_name,omitempty"`
	OrgID          int      `json:"org_id,omitempty"`
	ModuleID       int      `json:"module_id,omitempty"`
	ServerVersion  string   `json:"server_version,omitempty"`
	MapName        string   `json:"map_name,omitempty"`
	State          string   `json:"state,omitempty"`
	NumPlaying     int      `json:"num_playing,omitempty"`
	Players        []string `json:"players,omitempty"`
	NumBackfill    int      `json:"num_backfill,omitempty"`
	Capacity       int      `json:"capacity,omitempty"`
	Logs           string   `json:"logs,omitempty"`
	SidecarLogs    string   `json:"sidecar_logs,omitempty"`
	CreatedAt      string   `json:"created_at,omitempty"`
}

type Log

type Log struct {
	Step  string `json:"step"`
	Lines string `json:"lines"`
}

Log represents a log line from a build workflow

type Spy

type Spy struct {
	CalledAllocateGameserver bool
}

Spy is a struct that contains fields to track the number of times a method is called.

func NewAllocatorSpy

func NewAllocatorSpy() *Spy

NewAllocatorSpy creates a new instance of the Spy struct.

func (*Spy) AllocateGameserver

func (a *Spy) AllocateGameserver(request AllocationRequest) AllocationResponse

AllocateGameserver is a spy method that sets the CalledAllocateGameserver field to true and returns a dummy AllocationResponse.

type Workflow

type Workflow struct {
	Name      string    `json:"name"`
	Status    string    `json:"status"`
	CreatedAt time.Time `json:"createdAt"`
}

Workflow represents a build workflow

type WorkflowsResponse

type WorkflowsResponse struct {
	Message   string     `json:"message"`
	Workflows []Workflow `json:"workflows"`
}

WorkflowsResponse represents the response from the build/workflows endpoint

Jump to

Keyboard shortcuts

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