allocator

package
v0.0.0-...-63c973b Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GET_GAMESERVER_PATH = "/api/v1/gameservers"
)

Variables

View Source
var (
	ErrKeyFileInvalid              = errors.New("the private key file for the client certificate is invalid")
	ErrCertFileInvalid             = errors.New("the public key file for the client certificate is invalid")
	ErrCaCertFileInvalid           = errors.New("the CA cert file for server signing certificate is invalid")
	ErrAllocatorServiceHostInvalid = errors.New("the Allocator Service host is invalid")
	ErrAllocatorServicePortInvalid = errors.New("the Allocator Service port is invalid")
	ErrAllocatorServiceNamespace   = errors.New("the Allocator Service namespace is invalid")
)
View Source
var (
	ErrGameServersNotFound = errors.New("gameservers not found")
)
View Source
var (
	NotAvailableGameServerToAllocateMessage = "there is no available GameServer to allocate"
)

Functions

func BuildQueryParams

func BuildQueryParams(path string, filter map[string]string) string

func EncodeFilter

func EncodeFilter(filter map[string]string) string

func HasCapacity

func HasCapacity(group *pb.AssignmentGroup, gs *GameServer) bool

func IsAssignmentGroupValidForAllocation

func IsAssignmentGroupValidForAllocation(group *pb.AssignmentGroup) error

func ValueIsEmpty

func ValueIsEmpty(value string, err error) (bool, error)

Types

type AgonesAllocator

type AgonesAllocator struct {
	Client *AgonesAllocatorClient
}

func NewAgonesAllocator

func NewAgonesAllocator(client *AgonesAllocatorClient) *AgonesAllocator

func (*AgonesAllocator) Allocate

type AgonesAllocatorClient

type AgonesAllocatorClient struct {
	Config   *AgonesAllocatorClientConfig
	DialOpts grpc.DialOption
}

AgonesAllocatorClient is the gRPC Client for Agones Allocator Service

func NewAgonesAllocatorClient

func NewAgonesAllocatorClient(config *AgonesAllocatorClientConfig) (*AgonesAllocatorClient, error)

func (*AgonesAllocatorClient) Allocate

type AgonesAllocatorClientConfig

type AgonesAllocatorClientConfig struct {
	KeyFile              string
	CertFile             string
	CaCertFile           string
	AllocatorServiceHost string
	AllocatorServicePort int
	Namespace            string
	MultiCluster         bool
}

type AgonesDiscoverAllocator

type AgonesDiscoverAllocator struct {
	Client AgonesDiscoverClient
}

func (*AgonesDiscoverAllocator) Allocate

Allocate will only assign a GameServer to an Assignment if the Capacity (Players.Status.Capacity - Players.Stats.Count) is <= the number of the TicketsIds part of the Assignment

func (*AgonesDiscoverAllocator) FindGameServers

func (c *AgonesDiscoverAllocator) FindGameServers(ctx context.Context, filters map[string]string) ([]byte, error)

func (*AgonesDiscoverAllocator) ListGameServers

type AgonesDiscoverClient

type AgonesDiscoverClient interface {
	ListGameServers(ctx context.Context, filter map[string]string) ([]byte, error)
}

type AgonesDiscoverClientHTTP

type AgonesDiscoverClientHTTP struct {
	ServerURI string
	// contains filtered or unexported fields
}

func NewAgonesDiscoverClientHTTP

func NewAgonesDiscoverClientHTTP(serverURI string) (*AgonesDiscoverClientHTTP, error)

func (*AgonesDiscoverClientHTTP) ListGameServers

func (c *AgonesDiscoverClientHTTP) ListGameServers(ctx context.Context, filter map[string]string) ([]byte, error)

type AllocatorService

type AllocatorService struct {
	GameServerAllocator
	// contains filtered or unexported fields
}

func NewAllocatorService

func NewAllocatorService(service GameServerAllocator) *AllocatorService

func (*AllocatorService) Allocate

type GameServer

type GameServer struct {
	UID             string            `json:"uid,omitempty"`
	Name            string            `json:"name,omitempty"`
	Namespace       string            `json:"namespace,omitempty"`
	ResourceVersion string            `json:"resource_version,omitempty"`
	Labels          map[string]string `json:"labels,omitempty"`
	Status          *GameServerStatus `json:"status,omitempty"`
}

func ParseGameServersResponse

func ParseGameServersResponse(resp []byte) ([]*GameServer, error)

type GameServerAllocator

type GameServerAllocator interface {
	Allocate(ctx context.Context, req *pb.AssignTicketsRequest) error
}

type GameServerAllocatorClient

type GameServerAllocatorClient interface {
	Allocate(ctx context.Context, req *pb.AssignTicketsRequest) error
}

GameServerAllocatorClient allocates GameServers without knowing them beforehand Usually that could be done by pushing a GameServerAllocation request or talking directly to the GameServer Allocator Service from Agones

type GameServerAllocatorService

type GameServerAllocatorService interface {
	GameServerAllocatorClient
}

Allocate Dedicated GameServers

type GameServerDiscoveryClient

type GameServerDiscoveryClient interface {
	FindGameServers(ctx context.Context, filters map[string]string) ([]byte, error)
}

GameServerDiscoveryClient communicates with some sort of underlying infrastructure or service and return GameServers for a given filter

type GameServerStatus

type GameServerStatus struct {
	State   string        `json:"state,omitempty"`
	Address string        `json:"address,omitempty"`
	Players *PlayerStatus `json:"players,omitempty"`
}

type GameServersResponse

type GameServersResponse struct {
	Data []*GameServer `json:"data"`
}

type GameSessionAllocatorService

type GameSessionAllocatorService interface {
	GameServerAllocatorClient
	GameServerDiscoveryClient
}

Allocate GameServers by Sessions

type PlayerStatus

type PlayerStatus struct {
	Count    int64    `json:"count"`
	Capacity int64    `json:"capacity"`
	IDs      []string `json:"ids"`
}

Jump to

Keyboard shortcuts

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