Documentation ¶
Overview ¶
Package sdk is the Go game server sdk.
Index ¶
- type Alpha
- func (a *Alpha) GetConnectedPlayers() ([]string, error)
- func (a *Alpha) GetPlayerCapacity() (int64, error)
- func (a *Alpha) GetPlayerCount() (int64, error)
- func (a *Alpha) IsPlayerConnected(id string) (bool, error)
- func (a *Alpha) PlayerConnect(id string) (bool, error)
- func (a *Alpha) PlayerDisconnect(id string) (bool, error)
- func (a *Alpha) SetPlayerCapacity(capacity int64) error
- type Beta
- func (b *Beta) AppendListValue(key, value string) error
- func (b *Beta) DecrementCounter(key string, amount int64) error
- func (b *Beta) DeleteListValue(key, value string) error
- func (b *Beta) GetCounterCapacity(key string) (int64, error)
- func (b *Beta) GetCounterCount(key string) (int64, error)
- func (b *Beta) GetListCapacity(key string) (int64, error)
- func (b *Beta) GetListLength(key string) (int, error)
- func (b *Beta) GetListValues(key string) ([]string, error)
- func (b *Beta) IncrementCounter(key string, amount int64) error
- func (b *Beta) ListContains(key, value string) (bool, error)
- func (b *Beta) SetCounterCapacity(key string, amount int64) error
- func (b *Beta) SetCounterCount(key string, amount int64) error
- func (b *Beta) SetListCapacity(key string, amount int64) error
- type ErrorLog
- type GameServerCallback
- type SDK
- func (s *SDK) Allocate() error
- func (s *SDK) Alpha() *Alpha
- func (s *SDK) Beta() *Beta
- func (s *SDK) GameServer() (*sdk.GameServer, error)
- func (s *SDK) Health() error
- func (s *SDK) Ready() error
- func (s *SDK) Reserve(d time.Duration) error
- func (s *SDK) SetAnnotation(key, value string) error
- func (s *SDK) SetLabel(key, value string) error
- func (s *SDK) Shutdown() error
- func (s *SDK) WatchGameServer(f GameServerCallback) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alpha ¶ added in v1.5.0
type Alpha struct {
// contains filtered or unexported fields
}
Alpha is the struct for Alpha SDK functionality.
func (*Alpha) GetConnectedPlayers ¶ added in v1.6.0
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.
func (*Alpha) GetPlayerCapacity ¶ added in v1.5.0
GetPlayerCapacity gets the last player capacity that was set through the SDK. If the player capacity is set from outside the SDK, use SDK.GameServer() instead.
func (*Alpha) GetPlayerCount ¶ added in v1.6.0
GetPlayerCount returns the current player count.
func (*Alpha) 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.
func (*Alpha) PlayerConnect ¶ added in v1.6.0
PlayerConnect increases the SDK’s stored player count by one, and appends this playerID to status.players.id. Will return true and add the playerID to the list of playerIDs if the playerIDs was not already in the list of connected playerIDs.
func (*Alpha) PlayerDisconnect ¶ added in v1.6.0
PlayerDisconnect Decreases the SDK’s stored player count by one, and removes the playerID from status.players.id. Will return true and remove the supplied playerID from the list of connected playerIDs if the playerID value exists within the list.
func (*Alpha) SetPlayerCapacity ¶ added in v1.5.0
SetPlayerCapacity changes the player capacity to a new value.
type Beta ¶ added in v1.41.0
type Beta struct {
// contains filtered or unexported fields
}
Beta is the struct for Beta SDK functionality.
func (*Beta) AppendListValue ¶ added in v1.41.0
AppendListValue appends a string to a List's values list, given the List's key (name) and the string value. Will error if the string already exists in the list. Will error if the key was not predefined in the GameServer resource on creation.
func (*Beta) DecrementCounter ¶ added in v1.41.0
DecrementCounter decreases the current count by the given nonnegative integer amount. The Counter Will not go below 0. Will execute the decrement operation against the current CRD value. Will error if the count is at 0 (to the latest knowledge of the SDK), and no decrement will occur.
func (*Beta) DeleteListValue ¶ added in v1.41.0
DeleteListValue removes a string from a List's values list, given the List's key (name) and the string value. Will error if the string does not exist in the list. Will error if the key was not predefined in the GameServer resource on creation.
func (*Beta) GetCounterCapacity ¶ added in v1.41.0
GetCounterCapacity returns the Capacity for a Counter, given the Counter's key (name). Will error if the key was not predefined in the GameServer resource on creation.
func (*Beta) GetCounterCount ¶ added in v1.41.0
GetCounterCount returns the Count for a Counter, given the Counter's key (name). Will error if the key was not predefined in the GameServer resource on creation.
func (*Beta) GetListCapacity ¶ added in v1.41.0
GetListCapacity returns the Capacity for a List, given the List's key (name). Will error if the key was not predefined in the GameServer resource on creation.
func (*Beta) GetListLength ¶ added in v1.41.0
GetListLength returns the length of the Values list for a List, given the List's key (name). Will error if the key was not predefined in the GameServer resource on creation.
func (*Beta) GetListValues ¶ added in v1.41.0
GetListValues returns the Values for a List, given the List's key (name). Will error if the key was not predefined in the GameServer resource on creation.
func (*Beta) IncrementCounter ¶ added in v1.41.0
IncrementCounter increases a counter by the given nonnegative integer amount. Will execute the increment operation against the current CRD value. Will max at max(int64). Will error if the key was not predefined in the GameServer resource on creation. Returns error if the count is at the current capacity (to the latest knowledge of the SDK), and no increment will occur.
Note: A potential race condition here is that if count values are set from both the SDK and through the K8s API (Allocation or otherwise), since the SDK append operation back to the CRD value is batched asynchronous any value incremented past the capacity will be silently truncated.
func (*Beta) ListContains ¶ added in v1.41.0
ListContains returns if a string exists in a List's values list, given the List's key (name) and the string value. Search is case-sensitive. Will error if the key was not predefined in the GameServer resource on creation.
func (*Beta) SetCounterCapacity ¶ added in v1.41.0
SetCounterCapacity sets the capacity for the given Counter. A capacity of 0 is no capacity.
func (*Beta) SetCounterCount ¶ added in v1.41.0
SetCounterCount sets a count to the given value. Use with care, as this will overwrite any previous invocations’ value. Cannot be greater than Capacity.
type GameServerCallback ¶ added in v0.4.0
type GameServerCallback func(gs *sdk.GameServer)
GameServerCallback is a function definition to be called when a GameServer CRD has been changed.
type SDK ¶
type SDK struct {
// contains filtered or unexported fields
}
SDK is an instance of the Agones SDK.
func NewSDK ¶
NewSDK starts a new SDK instance, defaulting to a connection at "localhost:9357" unless overridden by "AGONES_SDK_GRPC_HOST" and "AGONES_SDK_GRPC_PORT" environment variables. Blocks until connection and handshake are made. Times out after 30 seconds.
func (*SDK) GameServer ¶ added in v0.3.0
func (s *SDK) GameServer() (*sdk.GameServer, error)
GameServer retrieve the GameServer details.
func (*SDK) Health ¶
Health sends a ping to the sidecar health check to indicate that this Game Server is healthy.
func (*SDK) Reserve ¶ added in v0.12.0
Reserve marks the Game Server as Reserved for a given duration, at which point it will return the GameServer to a Ready state. Do note, the smallest unit available in the time.Duration argument is a second.
func (*SDK) SetAnnotation ¶ added in v0.4.0
SetAnnotation sets a metadata annotation on the `GameServer` with the prefix "agones.dev/sdk-".
func (*SDK) SetLabel ¶ added in v0.4.0
SetLabel sets a metadata label on the `GameServer` with the prefix "agones.dev/sdk-".
func (*SDK) WatchGameServer ¶ added in v0.4.0
func (s *SDK) WatchGameServer(f GameServerCallback) error
WatchGameServer asynchronously calls the given GameServerCallback with the current GameServer configuration when the backing GameServer configuration is updated. This function can be called multiple times to add more than one GameServerCallback.