health

open suspend override fun health(stream: Flow<Unit>)(source)

Notifies Agones that this instance is still running and healthy. This notification must be sent periodically, otherwise this instance will be marked as Unhealthy and eventually removed. The interval is configured in the Agones GameServer resource and tolerates short delays. These health checks are independent of the normal application lifecycle and should be sent from the beginning. They can be sent at an arbitrary interval.

This method should be called only once and the emitting of pings in the Flow should happen in some thread related to the general game loop of this instance. If it is called in an independent thread, the health pings may not necessarily reflect the real health of this instance. The health ping should be sent at a slightly faster interval than is configured within the GameServer resource, so that the status does not switch to Unhealthy.

Parameters

stream

The Flow that should emit the health pings to the AgonesSdk whenever the Flow emits Unit. Defaults to a single ping, if not specified.

See also

Samples


fun main() { 
   //sampleStart 
   // host and port are supplied by the default environment variables
val sdk = GrpcAgonesSdk()

// create a flow
val healthFlow = MutableSharedFlow<Unit>()

// bind the flow to the health endpoint (async)
launch {
    sdk.health(healthFlow)
}

// emit health pings
healthFlow.emit(Unit) 
   //sampleEnd
}