code: private static Observable<BinaryRequest> assembleRequests(final ClusterFacade core, final String id,
          final ReplicaMode type, final String bucket) {
          if (type != ReplicaMode.ALL) {
              return Observable.just((BinaryRequest) new ReplicaGetRequest(id, bucket, (short) type.ordinal()));
          }
  
          return Observable.defer(new Func0<Observable<GetClusterConfigResponse>>() {
                  @Override
                  public Observable<GetClusterConfigResponse> call() {
                      return core.send(new GetClusterConfigRequest());
                  }
              })
              .map(new Func1<GetClusterConfigResponse, Integer>() {
                  @Override
                  public Integer call(GetClusterConfigResponse response) {
                      CouchbaseBucketConfig conf = (CouchbaseBucketConfig) response.config().bucketConfig(bucket);
                      return conf.numberOfReplicas();
                  }
              })
              .flatMap(new Func1<Integer, Observable<BinaryRequest>>() {
                  @Override
                  public Observable<BinaryRequest> call(Integer max) {
                      List<BinaryRequest> requests = new ArrayList<BinaryRequest>();
                      requests.add(new GetRequest(id, bucket));
                      for (int i = 0; i < max; i++) {
                          requests.add(new ReplicaGetRequest(id, bucket, (short) (i + 1)));
                      }
                      return Observable.from(requests);
                  }
              });
      }
docs: Helper method to assemble all possible/needed replica get requests.
  
  The number of configured replicas is also loaded on demand for each request. In the future, this can be
  maybe optimized.
  
  @param core the core reference.
  @param id the id of the document to load from the replicas.
  @param type the replica mode type.
  @param bucket the name of the bucket to load it from.
  @return a list of requests to perform (both regular and replica get).