Aquila SDK
Report Ready, health and shutdown through the Aquila game server SDK.
The Aquila SDK is a small HTTP API inside the zone. A Go client wraps it, and any other language calls it directly.
Go
go get github.com/aquila-hosting/aquila-hosting-sdk-goclient, err := sdk.New()
if err != nil {
return err
}
if err := client.Ready(ctx); err != nil {
return err
}
go func() {
for range time.Tick(2 * time.Second) {
_ = client.Health(ctx)
}
}()
_ = client.Watch(ctx, func(gs *sdk.GameServer) {
if gs.State == sdk.StateAllocated {
match := gs.Annotations[sdk.LabelPrefix+"match"]
// start the match
}
})When the match is over, call client.Shutdown(ctx) and exit.
The udp-echo example in the SDK repository is a complete server: it reports Ready and health, counts players, reads the match and shuts down when everyone has left.
Other languages
Send each call to the URL in AQUILA_SDK_URL, with the token from the file in AQUILA_SDK_TOKEN_FILE as Authorization: Bearer <token>. The token is rotated, so read the file on every call.
curl -X POST "$AQUILA_SDK_URL/v1/ready" \
-H "Authorization: Bearer $(cat "$AQUILA_SDK_TOKEN_FILE")"| Call | Does |
|---|---|
POST /v1/ready | Moves the server to Ready |
POST /v1/health | Reports the server is alive |
POST /v1/allocate | Marks the server Allocated, for games with own lobbies |
POST /v1/reserve | Holds the server back for 1 to 3600 seconds |
POST /v1/shutdown | Ends the server |
PUT /v1/players | Reports the player count and capacity |
PUT /v1/labels/{key} | Sets a label allocation can select on |
PUT /v1/annotations/{key} | Sets an annotation |
GET /v1/gameserver | Reads the server's state, labels and annotations |
GET /v1/watch | Streams the server's state as it changes |
Each server may make 10 calls a second, with bursts of 20.
Labels and annotations
Labels and annotations set through the SDK, or by an allocation, are stored under sdk.aquilahosting.com/. A label map set by the game is selected on as sdk.aquilahosting.com/map.
Players
SetPlayers(count, capacity) feeds the player graphs in the console and the fleet's player metrics. Servers without the SDK can report players through a metrics endpoint instead.