public async Task <BoolResult> OnChangeCheckpointAsync(OperationContext context, CheckpointState initialState, CheckpointManifest manifest) { _activeCheckpointInfo = _activeCheckpointInfo with { Manifest = manifest }; if (initialState.FileName == null) { return(BoolResult.Success); } return(await context.PerformOperationAsync( Tracer, async() => { var(state, index) = await _storage.ReadModifyWriteAsync <CheckpointState, int>(context, initialState.FileName.Value, state => { var index = state.Consumers.Count; var updated = state.Consumers.TryAdd(_primaryMachineLocation); if (!updated) { index = state.Consumers.IndexOf(_primaryMachineLocation); } return (state, index, updated); }, defaultValue: () => initialState).ThrowIfFailureAsync(); var locations = GetCandidateLocations(state, index); _activeCheckpointInfo = new CheckpointInfoSnapshot(manifest, locations); return Result.Success(index); },
public record CheckpointInfoSnapshot(CheckpointManifest Manifest, IReadOnlyList <MachineLocation> Locations);