Couchbase SDK 2 : bulk read operations , how to failover to replicas

hi @ashikaumanga

I commented on you second post on stackoverflow :smile:
Great job, looks like you figured it out yourself!

As said on SO, the throw would probably look “more Rx” if replaced with a return Observable.error(t1);.
Now that I look at it a second time, I think I see one potential improvement:

You are using first(). This will error if no value is emitted, which is a possibility if the key doesn’t exist.
You may want another behavior in this case? Other options are take(1) that will just result in an empty observable or firstOrDefault(null) that will emit null instead of throwing (or whatever default value you pass to the operator).

I will add this as well on SO.
Happy coding!

1 Like