public static IEnumerable <Task <IGetReplicaResult> > GetAllReplicasAsync(this ICouchbaseCollection collection, string id, Action <GetAllReplicasOptions> configureOptions) { var options = new GetAllReplicasOptions(); configureOptions(options); return(collection.GetAllReplicasAsync(id, options)); }
public IEnumerable <Task <IGetReplicaResult> > GetAllReplicasAsync(string id, GetAllReplicasOptions options) { var vBucket = (VBucket)_bucket.KeyMapper.MapKey(id); if (!vBucket.HasReplicas) { Log.LogWarning($"Call to GetAllReplicas for key [{id}] but none are configured. Only the active document will be retrieved."); } var tasks = new List <Task <IGetReplicaResult> >(vBucket.Replicas.Length + 1); var transcoder = options.Transcoder ?? _transcoder; // get primary tasks.Add(GetPrimary(id, options.CancellationToken, transcoder)); // get replicas tasks.AddRange(vBucket.Replicas.Select(index => GetReplica(id, index, options.CancellationToken, transcoder))); return(tasks); }