public Task<Result<HeartbeatMachineResponse>> HeartbeatAsync(OperationContext context, HeartbeatMachineRequest request)
{
return context.PerformOperationAsync(
Tracer,
() =>
{
return _clusterStateKey.UseNonConcurrentReplicatedHashAsync(
context, Configuration.RetryWindow, RedisOperation.UpdateClusterState, async (batch, key) =>
{
(MachineState priorState, BitMachineIdSet inactiveMachineIdSet, BitMachineIdSet closedMachineIdSet) = await batch.HeartbeatAsync(
key,
request.MachineId.Index,
// When readonly, specify Unknown which does not update state
Configuration.DistributedContentConsumerOnly ? MachineState.Unknown : request.DeclaredMachineState,
_clock.UtcNow,
Configuration.MachineStateRecomputeInterval,
Configuration.MachineActiveToClosedInterval,
Configuration.MachineActiveToExpiredInterval);
return Result.Success(new HeartbeatMachineResponse()
{
PriorState = priorState,
InactiveMachines = inactiveMachineIdSet,
ClosedMachines = closedMachineIdSet
});
},
timeout: Configuration.ClusterRedisOperationTimeout).ThrowIfFailureAsync();
},
Counters[GlobalStoreCounters.UpdateClusterState]);