Documentation
¶
Index ¶
- type AgonesSDK
- type AlphaFeature
- type MockAlpha
- func (a *MockAlpha) GetConnectedPlayers() ([]string, error)
- func (a *MockAlpha) GetPlayerCapacity() (int64, error)
- func (a *MockAlpha) GetPlayerCount() (int64, error)
- func (a *MockAlpha) IsPlayerConnected(id string) (bool, error)
- func (a *MockAlpha) PlayerConnect(id string) (bool, error)
- func (a *MockAlpha) PlayerDisconnect(id string) (bool, error)
- func (a *MockAlpha) SetPlayerCapacity(capacity int64) error
- type MockSDK
- func (m *MockSDK) Allocate() error
- func (m *MockSDK) Alpha() AlphaFeature
- func (m *MockSDK) GameServer() (interface{}, error)
- func (m *MockSDK) Health() error
- func (m *MockSDK) Ready() error
- func (m *MockSDK) Reserve(duration time.Duration) error
- func (m *MockSDK) SetAnnotation(key, value string) error
- func (m *MockSDK) SetLabel(key, value string) error
- func (m *MockSDK) Shutdown() error
- func (m *MockSDK) WatchGameServer(f func(gs interface{})) error
- type RealSDK
- func (r *RealSDK) Allocate() error
- func (r *RealSDK) Alpha() AlphaFeature
- func (r *RealSDK) GameServer() (interface{}, error)
- func (r *RealSDK) Health() error
- func (r *RealSDK) Ready() error
- func (r *RealSDK) Reserve(d time.Duration) error
- func (r *RealSDK) SetAnnotation(k, v string) error
- func (r *RealSDK) SetLabel(k, v string) error
- func (r *RealSDK) Shutdown() error
- func (r *RealSDK) WatchGameServer(f func(interface{})) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgonesSDK ¶
type AgonesSDK interface {
// Lifecycle
Ready() error
Allocate() error
Shutdown() error
Reserve(duration time.Duration) error
// Health
Health() error
// Metadata
SetLabel(key, value string) error
SetAnnotation(key, value string) error
// Data
// We use interface{} here to avoid strict dependency on the official sdk.GameServer struct
// in your tests, but you can cast it in your application code.
GameServer() (interface{}, error)
WatchGameServer(f func(gs interface{})) error
// Features
Alpha() AlphaFeature
}
AgonesSDK defines the contract that both the Real and Mock SDKs must satisfy.
type AlphaFeature ¶
type AlphaFeature interface {
PlayerConnect(id string) (bool, error)
PlayerDisconnect(id string) (bool, error)
SetPlayerCapacity(capacity int64) error
GetPlayerCapacity() (int64, error)
GetPlayerCount() (int64, error)
IsPlayerConnected(id string) (bool, error)
GetConnectedPlayers() ([]string, error)
}
AlphaFeature defines the contract for Player Tracking (Alpha).
type MockAlpha ¶
type MockAlpha struct{}
MockAlpha handles the Alpha feature set (Player Tracking, etc.)
func (*MockAlpha) GetConnectedPlayers ¶
func (*MockAlpha) GetPlayerCapacity ¶
func (*MockAlpha) GetPlayerCount ¶
func (*MockAlpha) IsPlayerConnected ¶
func (*MockAlpha) SetPlayerCapacity ¶
type MockSDK ¶
type MockSDK struct {
// contains filtered or unexported fields
}
MockSDK mimics the Agones SDK behavior by printing logs.
func NewMockSDK ¶
NewMockSDK initializes the mock and the nested Alpha mock.
func (*MockSDK) Alpha ¶
func (m *MockSDK) Alpha() AlphaFeature
func (*MockSDK) GameServer ¶
GameServer usually returns *sdk.GameServer. We return nil here to keep this mock dependency-free.
func (*MockSDK) SetAnnotation ¶
func (*MockSDK) WatchGameServer ¶
WatchGameServer usually takes a callback function.
type RealSDK ¶
type RealSDK struct {
// contains filtered or unexported fields
}
RealSDK wraps the official SDK to satisfy the AgonesSDK interface.
func NewRealSDK ¶
func (*RealSDK) Alpha ¶
func (r *RealSDK) Alpha() AlphaFeature
Alpha Wrapper We need this because r.client.Alpha() returns *sdk.Alpha (struct), but our interface expects AlphaFeature (interface).
func (*RealSDK) GameServer ¶
Data methods - Returning the raw struct as interface{}