Documentation
¶
Overview ¶
Package sdkserver implements Agones SDK server (sidecar).
Index ¶
- type LocalSDKServer
- func (l *LocalSDKServer) AddListValue(_ context.Context, in *beta.AddListValueRequest) (*beta.List, error)
- func (l *LocalSDKServer) Allocate(context.Context, *sdk.Empty) (*sdk.Empty, error)
- func (l *LocalSDKServer) Close()
- func (l *LocalSDKServer) EqualSets(expected, received []string) bool
- func (l *LocalSDKServer) GenerateUID()
- func (l *LocalSDKServer) GetConnectedPlayers(_ context.Context, _ *alpha.Empty) (*alpha.PlayerIDList, error)
- func (l *LocalSDKServer) GetCounter(_ context.Context, in *beta.GetCounterRequest) (*beta.Counter, error)
- func (l *LocalSDKServer) GetGameServer(context.Context, *sdk.Empty) (*sdk.GameServer, error)
- func (l *LocalSDKServer) GetList(_ context.Context, in *beta.GetListRequest) (*beta.List, error)
- func (l *LocalSDKServer) GetPlayerCapacity(_ context.Context, _ *alpha.Empty) (*alpha.Count, error)
- func (l *LocalSDKServer) GetPlayerCount(_ context.Context, _ *alpha.Empty) (*alpha.Count, error)
- func (l *LocalSDKServer) Health(stream sdk.SDK_HealthServer) error
- func (l *LocalSDKServer) IsPlayerConnected(_ context.Context, id *alpha.PlayerID) (*alpha.Bool, error)
- func (l *LocalSDKServer) PlayerConnect(_ context.Context, id *alpha.PlayerID) (*alpha.Bool, error)
- func (l *LocalSDKServer) PlayerDisconnect(_ context.Context, id *alpha.PlayerID) (*alpha.Bool, error)
- func (l *LocalSDKServer) Ready(context.Context, *sdk.Empty) (*sdk.Empty, error)
- func (l *LocalSDKServer) RemoveListValue(_ context.Context, in *beta.RemoveListValueRequest) (*beta.List, error)
- func (l *LocalSDKServer) Reserve(ctx context.Context, d *sdk.Duration) (*sdk.Empty, error)
- func (l *LocalSDKServer) SetAnnotation(_ context.Context, kv *sdk.KeyValue) (*sdk.Empty, error)
- func (l *LocalSDKServer) SetExpectedSequence(sequence []string)
- func (l *LocalSDKServer) SetLabel(_ context.Context, kv *sdk.KeyValue) (*sdk.Empty, error)
- func (l *LocalSDKServer) SetPlayerCapacity(_ context.Context, count *alpha.Count) (*alpha.Empty, error)
- func (l *LocalSDKServer) SetSdkName(sdkName string)
- func (l *LocalSDKServer) SetTestMode(testMode bool)
- func (l *LocalSDKServer) Shutdown(context.Context, *sdk.Empty) (*sdk.Empty, error)
- func (l *LocalSDKServer) UpdateCounter(_ context.Context, in *beta.UpdateCounterRequest) (*beta.Counter, error)
- func (l *LocalSDKServer) UpdateList(_ context.Context, in *beta.UpdateListRequest) (*beta.List, error)
- func (l *LocalSDKServer) WatchGameServer(_ *sdk.Empty, stream sdk.SDK_WatchGameServerServer) error
- type Operation
- type SDKServer
- func (s *SDKServer) AddListValue(ctx context.Context, in *beta.AddListValueRequest) (*beta.List, error)
- func (s *SDKServer) Allocate(_ context.Context, e *sdk.Empty) (*sdk.Empty, error)
- func (s *SDKServer) GetConnectedPlayers(_ context.Context, _ *alpha.Empty) (*alpha.PlayerIDList, error)
- func (s *SDKServer) GetCounter(_ context.Context, in *beta.GetCounterRequest) (*beta.Counter, error)
- func (s *SDKServer) GetGameServer(context.Context, *sdk.Empty) (*sdk.GameServer, error)
- func (s *SDKServer) GetList(_ context.Context, in *beta.GetListRequest) (*beta.List, error)
- func (s *SDKServer) GetPlayerCapacity(_ context.Context, _ *alpha.Empty) (*alpha.Count, error)
- func (s *SDKServer) GetPlayerCount(_ context.Context, _ *alpha.Empty) (*alpha.Count, error)
- func (s *SDKServer) Health(stream sdk.SDK_HealthServer) error
- func (s *SDKServer) IsPlayerConnected(_ context.Context, id *alpha.PlayerID) (*alpha.Bool, error)
- func (s *SDKServer) NewSDKServerContext(ctx context.Context) context.Context
- func (s *SDKServer) PlayerConnect(_ context.Context, id *alpha.PlayerID) (*alpha.Bool, error)
- func (s *SDKServer) PlayerDisconnect(_ context.Context, id *alpha.PlayerID) (*alpha.Bool, error)
- func (s *SDKServer) Ready(_ context.Context, e *sdk.Empty) (*sdk.Empty, error)
- func (s *SDKServer) RemoveListValue(ctx context.Context, in *beta.RemoveListValueRequest) (*beta.List, error)
- func (s *SDKServer) Reserve(_ context.Context, d *sdk.Duration) (*sdk.Empty, error)
- func (s *SDKServer) Run(ctx context.Context) error
- func (s *SDKServer) SetAnnotation(_ context.Context, kv *sdk.KeyValue) (*sdk.Empty, error)
- func (s *SDKServer) SetLabel(_ context.Context, kv *sdk.KeyValue) (*sdk.Empty, error)
- func (s *SDKServer) SetPlayerCapacity(_ context.Context, count *alpha.Count) (*alpha.Empty, error)
- func (s *SDKServer) Shutdown(_ context.Context, e *sdk.Empty) (*sdk.Empty, error)
- func (s *SDKServer) UpdateCounter(_ context.Context, in *beta.UpdateCounterRequest) (*beta.Counter, error)
- func (s *SDKServer) UpdateList(ctx context.Context, in *beta.UpdateListRequest) (*beta.List, error)
- func (s *SDKServer) WaitForConnection(ctx context.Context) error
- func (s *SDKServer) WatchGameServer(_ *sdk.Empty, stream sdk.SDK_WatchGameServerServer) error
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(_ context.Context, in *beta.AddListValueRequest) (*beta.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:Beta] [FeatureFlag:CountsAndLists]
func (*LocalSDKServer) Allocate ¶ added in v0.10.0
Allocate logs that an allocate request has been received
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(_ context.Context, _ *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
func (l *LocalSDKServer) GetCounter(_ context.Context, in *beta.GetCounterRequest) (*beta.Counter, error)
GetCounter returns a Counter. Returns not found if the counter does not exist. [Stage:Beta] [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(_ context.Context, in *beta.GetListRequest) (*beta.List, error)
GetList returns a List. Returns not found if the List does not exist. [Stage:Beta] [FeatureFlag:CountsAndLists]
func (*LocalSDKServer) GetPlayerCapacity ¶ added in v1.5.0
GetPlayerCapacity returns the current player capacity. [Stage:Alpha] [FeatureFlag:PlayerTracking]
func (*LocalSDKServer) GetPlayerCount ¶ added in v1.5.0
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(_ 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
PlayerConnect should be called when a player connects. [Stage:Alpha] [FeatureFlag:PlayerTracking]
func (*LocalSDKServer) PlayerDisconnect ¶ added in v1.5.0
func (l *LocalSDKServer) PlayerDisconnect(_ context.Context, id *alpha.PlayerID) (*alpha.Bool, error)
PlayerDisconnect should be called when a player disconnects. [Stage:Alpha] [FeatureFlag:PlayerTracking]
func (*LocalSDKServer) RemoveListValue ¶ added in v1.31.0
func (l *LocalSDKServer) RemoveListValue(_ context.Context, in *beta.RemoveListValueRequest) (*beta.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:Beta] [FeatureFlag:CountsAndLists]
func (*LocalSDKServer) Reserve ¶ added in v0.12.0
Reserve moves this GameServer to the Reserved state for the Duration specified
func (*LocalSDKServer) SetAnnotation ¶
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) 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) UpdateCounter ¶ added in v1.31.0
func (l *LocalSDKServer) UpdateCounter(_ context.Context, in *beta.UpdateCounterRequest) (*beta.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:Beta] [FeatureFlag:CountsAndLists]
func (*LocalSDKServer) UpdateList ¶ added in v1.31.0
func (l *LocalSDKServer) UpdateList(_ context.Context, in *beta.UpdateListRequest) (*beta.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:Beta] [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 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, healthPort int) (*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 *beta.AddListValueRequest) (*beta.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:Beta] [FeatureFlag:CountsAndLists]
func (*SDKServer) Allocate ¶ added in v0.10.0
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(_ context.Context, _ *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(_ context.Context, in *beta.GetCounterRequest) (*beta.Counter, error)
GetCounter returns a Counter. Returns error if the counter does not exist. [Stage:Beta] [FeatureFlag:CountsAndLists]
func (*SDKServer) GetGameServer ¶
GetGameServer returns the current GameServer configuration and state from the backing GameServer CRD
func (*SDKServer) GetList ¶ added in v1.31.0
GetList returns a List. Returns not found if the List does not exist. [Stage:Beta] [FeatureFlag:CountsAndLists]
func (*SDKServer) GetPlayerCapacity ¶ added in v1.5.0
GetPlayerCapacity returns the current player capacity, as set by SDK.SetPlayerCapacity() [Stage:Alpha] [FeatureFlag:PlayerTracking]
func (*SDKServer) GetPlayerCount ¶ added in v1.5.0
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
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
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
PlayerConnect should be called when a player connects. [Stage:Alpha] [FeatureFlag:PlayerTracking]
func (*SDKServer) PlayerDisconnect ¶ added in v1.5.0
PlayerDisconnect should be called when a player disconnects. [Stage:Alpha] [FeatureFlag:PlayerTracking]
func (*SDKServer) Ready ¶
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 *beta.RemoveListValueRequest) (*beta.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:Beta] [FeatureFlag:CountsAndLists]
func (*SDKServer) Reserve ¶ added in v0.12.0
Reserve moves this GameServer to the Reserved state for the Duration specified
func (*SDKServer) SetAnnotation ¶
SetAnnotation adds the Key/Value to be used to set the annotations with the metadataPrefix to the `GameServer` metdata
func (*SDKServer) SetLabel ¶
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
SetPlayerCapacity to change the game server's player capacity. [Stage:Alpha] [FeatureFlag:PlayerTracking]
func (*SDKServer) Shutdown ¶
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(_ context.Context, in *beta.UpdateCounterRequest) (*beta.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:Beta] [FeatureFlag:CountsAndLists]
func (*SDKServer) UpdateList ¶ added in v1.31.0
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:Beta] [FeatureFlag:CountsAndLists]
func (*SDKServer) WaitForConnection ¶ added in v1.32.0
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 ¶
WatchGameServer sends events through the stream when changes occur to the backing GameServer configuration / status