sdkserver

package
v1.39.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 41 Imported by: 2

Documentation

Overview

Package sdkserver implements Agones SDK server (sidecar).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LocalSDKServer

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

LocalSDKServer type is the SDKServer implementation for when the sidecar is being run for local development, and doesn't connect to the Kubernetes cluster

func NewLocalSDKServer

func NewLocalSDKServer(filePath string, testSdkName string) (*LocalSDKServer, error)

NewLocalSDKServer returns the default LocalSDKServer

func (*LocalSDKServer) AddListValue added in v1.31.0

func (l *LocalSDKServer) AddListValue(ctx context.Context, in *alpha.AddListValueRequest) (*alpha.List, error)

AddListValue appends a value to the end of a List and returns updated List. Returns not found if the List does not exist. Returns already exists if the value is already in the List. Returns out of range if the List is already at Capacity. [Stage:Alpha] [FeatureFlag:CountsAndLists]

func (*LocalSDKServer) Allocate added in v0.10.0

func (l *LocalSDKServer) Allocate(context.Context, *sdk.Empty) (*sdk.Empty, error)

Allocate logs that an allocate request has been received

func (*LocalSDKServer) Close

func (l *LocalSDKServer) Close()

Close tears down all the things

func (*LocalSDKServer) EqualSets added in v1.6.0

func (l *LocalSDKServer) EqualSets(expected, received []string) bool

EqualSets tells whether expected and received slices contain the same elements. A nil argument is equivalent to an empty slice.

func (*LocalSDKServer) GenerateUID added in v0.12.0

func (l *LocalSDKServer) GenerateUID()

GenerateUID - generate gameserver UID at random for testing

func (*LocalSDKServer) GetConnectedPlayers added in v1.6.0

func (l *LocalSDKServer) GetConnectedPlayers(c context.Context, empty *alpha.Empty) (*alpha.PlayerIDList, error)

GetConnectedPlayers returns the list of the currently connected player ids. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*LocalSDKServer) GetCounter added in v1.31.0

GetCounter returns a Counter. Returns not found if the counter does not exist. [Stage:Alpha] [FeatureFlag:CountsAndLists]

func (*LocalSDKServer) GetGameServer

func (l *LocalSDKServer) GetGameServer(context.Context, *sdk.Empty) (*sdk.GameServer, error)

GetGameServer returns current GameServer configuration.

func (*LocalSDKServer) GetList added in v1.31.0

func (l *LocalSDKServer) GetList(ctx context.Context, in *alpha.GetListRequest) (*alpha.List, error)

GetList returns a List. Returns not found if the List does not exist. [Stage:Alpha] [FeatureFlag:CountsAndLists]

func (*LocalSDKServer) GetPlayerCapacity added in v1.5.0

func (l *LocalSDKServer) GetPlayerCapacity(_ context.Context, _ *alpha.Empty) (*alpha.Count, error)

GetPlayerCapacity returns the current player capacity. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*LocalSDKServer) GetPlayerCount added in v1.5.0

func (l *LocalSDKServer) GetPlayerCount(ctx context.Context, _ *alpha.Empty) (*alpha.Count, error)

GetPlayerCount returns the current player count. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*LocalSDKServer) Health

func (l *LocalSDKServer) Health(stream sdk.SDK_HealthServer) error

Health logs each health ping that comes down the stream

func (*LocalSDKServer) IsPlayerConnected added in v1.6.0

func (l *LocalSDKServer) IsPlayerConnected(c context.Context, id *alpha.PlayerID) (*alpha.Bool, error)

IsPlayerConnected returns if the playerID is currently connected to the GameServer. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*LocalSDKServer) PlayerConnect added in v1.5.0

func (l *LocalSDKServer) PlayerConnect(ctx context.Context, id *alpha.PlayerID) (*alpha.Bool, error)

PlayerConnect should be called when a player connects. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*LocalSDKServer) PlayerDisconnect added in v1.5.0

func (l *LocalSDKServer) PlayerDisconnect(ctx context.Context, id *alpha.PlayerID) (*alpha.Bool, error)

PlayerDisconnect should be called when a player disconnects. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*LocalSDKServer) Ready

Ready logs that the Ready request has been received

func (*LocalSDKServer) RemoveListValue added in v1.31.0

func (l *LocalSDKServer) RemoveListValue(ctx context.Context, in *alpha.RemoveListValueRequest) (*alpha.List, error)

RemoveListValue removes a value from a List and returns updated List. Returns not found if the List does not exist. Returns not found if the value is not in the List. [Stage:Alpha] [FeatureFlag:CountsAndLists]

func (*LocalSDKServer) Reserve added in v0.12.0

func (l *LocalSDKServer) Reserve(ctx context.Context, d *sdk.Duration) (*sdk.Empty, error)

Reserve moves this GameServer to the Reserved state for the Duration specified

func (*LocalSDKServer) SetAnnotation

func (l *LocalSDKServer) SetAnnotation(_ context.Context, kv *sdk.KeyValue) (*sdk.Empty, error)

SetAnnotation applies a Annotation to the backing GameServer metadata

func (*LocalSDKServer) SetExpectedSequence added in v0.12.0

func (l *LocalSDKServer) SetExpectedSequence(sequence []string)

SetExpectedSequence set expected request sequence which would be verified against after run was completed

func (*LocalSDKServer) SetLabel

func (l *LocalSDKServer) SetLabel(_ context.Context, kv *sdk.KeyValue) (*sdk.Empty, error)

SetLabel applies a Label to the backing GameServer metadata

func (*LocalSDKServer) SetPlayerCapacity added in v1.5.0

func (l *LocalSDKServer) SetPlayerCapacity(_ context.Context, count *alpha.Count) (*alpha.Empty, error)

SetPlayerCapacity to change the game server's player capacity. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*LocalSDKServer) SetSdkName added in v1.6.0

func (l *LocalSDKServer) SetSdkName(sdkName string)

SetSdkName set SDK name to be added to the logs

func (*LocalSDKServer) SetTestMode added in v0.12.0

func (l *LocalSDKServer) SetTestMode(testMode bool)

SetTestMode set test mode to collect the sequence of performed requests

func (*LocalSDKServer) Shutdown

func (l *LocalSDKServer) Shutdown(context.Context, *sdk.Empty) (*sdk.Empty, error)

Shutdown logs that the shutdown request has been received

func (*LocalSDKServer) UpdateCounter added in v1.31.0

func (l *LocalSDKServer) UpdateCounter(ctx context.Context, in *alpha.UpdateCounterRequest) (*alpha.Counter, error)

UpdateCounter updates the given Counter. Unlike the SDKServer, this LocalSDKServer UpdateCounter does not batch requests, and directly updates the localsdk gameserver. Returns error if the Counter does not exist (name cannot be updated). Returns error if the Count is out of range [0,Capacity]. [Stage:Alpha] [FeatureFlag:CountsAndLists]

func (*LocalSDKServer) UpdateList added in v1.31.0

func (l *LocalSDKServer) UpdateList(ctx context.Context, in *alpha.UpdateListRequest) (*alpha.List, error)

UpdateList returns the updated List. Returns not found if the List does not exist (name cannot be updated). **THIS WILL OVERWRITE ALL EXISTING LIST.VALUES WITH ANY REQUEST LIST.VALUES** Use AddListValue() or RemoveListValue() for modifying the List.Values field. Returns invalid argument if the field mask path(s) are not field(s) of the List. If a field mask path(s) is specified, but the value is not set in the request List object, then the default value for the variable will be set (i.e. 0 for "capacity", empty list for "values"). [Stage:Alpha] [FeatureFlag:CountsAndLists]

func (*LocalSDKServer) WatchGameServer

func (l *LocalSDKServer) WatchGameServer(_ *sdk.Empty, stream sdk.SDK_WatchGameServerServer) error

WatchGameServer will return current GameServer configuration, 3 times, every 5 seconds

type Operation

type Operation string

Operation is a synchronisation action

type SDKServer

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

SDKServer is a gRPC server, that is meant to be a sidecar for a GameServer that will update the game server status on SDK requests

func NewSDKServer

func NewSDKServer(gameServerName, namespace string, kubeClient kubernetes.Interface,
	agonesClient versioned.Interface, logLevel logrus.Level) (*SDKServer, error)

NewSDKServer creates a SDKServer that sets up an InClusterConfig for Kubernetes

func (*SDKServer) AddListValue added in v1.31.0

func (s *SDKServer) AddListValue(ctx context.Context, in *alpha.AddListValueRequest) (*alpha.List, error)

AddListValue collapses all append a value to the end of a List requests into a single UpdateList request. Returns not found if the List does not exist. Returns already exists if the value is already in the List. Returns out of range if the List is already at Capacity. [Stage:Alpha] [FeatureFlag:CountsAndLists]

func (*SDKServer) Allocate added in v0.10.0

func (s *SDKServer) Allocate(ctx context.Context, e *sdk.Empty) (*sdk.Empty, error)

Allocate enters an Allocate state change into the workqueue, so it can be updated

func (*SDKServer) GetConnectedPlayers added in v1.6.0

func (s *SDKServer) GetConnectedPlayers(c context.Context, empty *alpha.Empty) (*alpha.PlayerIDList, error)

GetConnectedPlayers returns the list of the currently connected player ids. This is always accurate, even if the value hasn’t been updated to the GameServer status yet. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*SDKServer) GetCounter added in v1.31.0

func (s *SDKServer) GetCounter(ctx context.Context, in *alpha.GetCounterRequest) (*alpha.Counter, error)

GetCounter returns a Counter. Returns error if the counter does not exist. [Stage:Alpha] [FeatureFlag:CountsAndLists]

func (*SDKServer) GetGameServer

func (s *SDKServer) GetGameServer(context.Context, *sdk.Empty) (*sdk.GameServer, error)

GetGameServer returns the current GameServer configuration and state from the backing GameServer CRD

func (*SDKServer) GetList added in v1.31.0

func (s *SDKServer) GetList(ctx context.Context, in *alpha.GetListRequest) (*alpha.List, error)

GetList returns a List. Returns not found if the List does not exist. [Stage:Alpha] [FeatureFlag:CountsAndLists]

func (*SDKServer) GetPlayerCapacity added in v1.5.0

func (s *SDKServer) GetPlayerCapacity(ctx context.Context, _ *alpha.Empty) (*alpha.Count, error)

GetPlayerCapacity returns the current player capacity, as set by SDK.SetPlayerCapacity() [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*SDKServer) GetPlayerCount added in v1.5.0

func (s *SDKServer) GetPlayerCount(ctx context.Context, _ *alpha.Empty) (*alpha.Count, error)

GetPlayerCount returns the current player count. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*SDKServer) Health

func (s *SDKServer) Health(stream sdk.SDK_HealthServer) error

Health receives each health ping, and tracks the last time the health check was received, to track if a GameServer is healthy

func (*SDKServer) IsPlayerConnected added in v1.6.0

func (s *SDKServer) IsPlayerConnected(ctx context.Context, id *alpha.PlayerID) (*alpha.Bool, error)

IsPlayerConnected returns if the playerID is currently connected to the GameServer. This is always accurate, even if the value hasn’t been updated to the GameServer status yet. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*SDKServer) NewSDKServerContext added in v1.18.0

func (s *SDKServer) NewSDKServerContext(ctx context.Context) context.Context

NewSDKServerContext returns a Context that cancels when SIGTERM or os.Interrupt is received and the GameServer's Status is shutdown

func (*SDKServer) PlayerConnect added in v1.5.0

func (s *SDKServer) PlayerConnect(ctx context.Context, id *alpha.PlayerID) (*alpha.Bool, error)

PlayerConnect should be called when a player connects. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*SDKServer) PlayerDisconnect added in v1.5.0

func (s *SDKServer) PlayerDisconnect(ctx context.Context, id *alpha.PlayerID) (*alpha.Bool, error)

PlayerDisconnect should be called when a player disconnects. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*SDKServer) Ready

func (s *SDKServer) Ready(ctx context.Context, e *sdk.Empty) (*sdk.Empty, error)

Ready enters the RequestReady state change for this GameServer into the workqueue so it can be updated

func (*SDKServer) RemoveListValue added in v1.31.0

func (s *SDKServer) RemoveListValue(ctx context.Context, in *alpha.RemoveListValueRequest) (*alpha.List, error)

RemoveListValue collapses all remove a value from a List requests into a single UpdateList request. Returns not found if the List does not exist. Returns not found if the value is not in the List. [Stage:Alpha] [FeatureFlag:CountsAndLists]

func (*SDKServer) Reserve added in v0.12.0

func (s *SDKServer) Reserve(ctx context.Context, d *sdk.Duration) (*sdk.Empty, error)

Reserve moves this GameServer to the Reserved state for the Duration specified

func (*SDKServer) Run

func (s *SDKServer) Run(ctx context.Context) error

Run processes the rate limited queue. Will block until stop is closed

func (*SDKServer) SetAnnotation

func (s *SDKServer) SetAnnotation(_ context.Context, kv *sdk.KeyValue) (*sdk.Empty, error)

SetAnnotation adds the Key/Value to be used to set the annotations with the metadataPrefix to the `GameServer` metdata

func (*SDKServer) SetLabel

func (s *SDKServer) SetLabel(_ context.Context, kv *sdk.KeyValue) (*sdk.Empty, error)

SetLabel adds the Key/Value to be used to set the label with the metadataPrefix to the `GameServer` metdata

func (*SDKServer) SetPlayerCapacity added in v1.5.0

func (s *SDKServer) SetPlayerCapacity(ctx context.Context, count *alpha.Count) (*alpha.Empty, error)

SetPlayerCapacity to change the game server's player capacity. [Stage:Alpha] [FeatureFlag:PlayerTracking]

func (*SDKServer) Shutdown

func (s *SDKServer) Shutdown(ctx context.Context, e *sdk.Empty) (*sdk.Empty, error)

Shutdown enters the Shutdown state change for this GameServer into the workqueue so it can be updated. If gracefulTermination feature is enabled, Shutdown will block on GameServer being shutdown.

func (*SDKServer) UpdateCounter added in v1.31.0

func (s *SDKServer) UpdateCounter(ctx context.Context, in *alpha.UpdateCounterRequest) (*alpha.Counter, error)

UpdateCounter collapses all UpdateCounterRequests for a given Counter into a single request. UpdateCounterRequest must be one and only one of Capacity, Count, or CountDiff. Returns error if the Counter does not exist (name cannot be updated). Returns error if the Count is out of range [0,Capacity]. [Stage:Alpha] [FeatureFlag:CountsAndLists]

func (*SDKServer) UpdateList added in v1.31.0

func (s *SDKServer) UpdateList(ctx context.Context, in *alpha.UpdateListRequest) (*alpha.List, error)

UpdateList collapses all update capacity requests for a given List into a single UpdateList request. This function currently only updates the Capacity of a List. Returns error if the List does not exist (name cannot be updated). Returns error if the List update capacity is out of range [0,1000]. [Stage:Alpha] [FeatureFlag:CountsAndLists]

func (*SDKServer) WaitForConnection added in v1.32.0

func (s *SDKServer) WaitForConnection(ctx context.Context) error

WaitForConnection attempts a GameServer GET every 3s until the client responds. This is a workaround for the informer hanging indefinitely on first LIST due to a flaky network to the Kubernetes service endpoint.

func (*SDKServer) WatchGameServer

func (s *SDKServer) WatchGameServer(_ *sdk.Empty, stream sdk.SDK_WatchGameServerServer) error

WatchGameServer sends events through the stream when changes occur to the backing GameServer configuration / status

Jump to

Keyboard shortcuts

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