Example #1
0
        public async Task <Result <HeartbeatMachineResponse> > HeartbeatAsync(OperationContext context, HeartbeatMachineRequest request)
        {
            var pr = _primary.HeartbeatAsync(context, request);
            var sr = _secondary.HeartbeatAsync(context, request).FireAndForgetErrorsAsync(context);
            await Task.WhenAll(pr, sr);

            return(await pr);
        }
Example #2
0
        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();

                },