Class TransparentReplicaGetHelper


  • @Experimental
    @Public
    public class TransparentReplicaGetHelper
    extends Object
    The TransparentReplicaGetHelper abstracts common logic to first grab the active document and if that fails tries all available replicas and returns the first result. NOTE: Using these APIs is eventually consistent meaning that you cannot rely on a previous successful mutation to a document be reflected in the result. Use this API only if you favor availability over consistency on the read path.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      rx.Single<JsonDocument> getFirstPrimaryOrReplica​(String id, Bucket bucket)
      Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them (using the environments KV timeout for both primary and replica).
      rx.Single<JsonDocument> getFirstPrimaryOrReplica​(String id, Bucket bucket, long timeout)
      Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them (with a custom timeout value applied to both primary and replica).
      rx.Single<JsonDocument> getFirstPrimaryOrReplica​(String id, Bucket bucket, long primaryTimeout, long replicaTimeout)
      Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them (with custom primary and replica timeout values).
      static <D extends Document<?>>
      rx.Single<D>
      getFirstPrimaryOrReplica​(String id, Class<D> target, Bucket bucket)
      Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them (using the environments KV timeout for both primary and replica).
      static <D extends Document<?>>
      rx.Single<D>
      getFirstPrimaryOrReplica​(String id, Class<D> target, Bucket bucket, long timeout)
      Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them (with a custom timeout value applied to both primary and replica).
      static <D extends Document<?>>
      rx.Single<D>
      getFirstPrimaryOrReplica​(String id, Class<D> target, Bucket bucket, long primaryTimeout, long replicaTimeout)
      Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them.
    • Constructor Detail

      • TransparentReplicaGetHelper

        public TransparentReplicaGetHelper()
    • Method Detail

      • getFirstPrimaryOrReplica

        @Experimental
        @Public
        public rx.Single<JsonDocument> getFirstPrimaryOrReplica​(String id,
                                                                Bucket bucket,
                                                                long primaryTimeout,
                                                                long replicaTimeout)
        Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them (with custom primary and replica timeout values).
        Parameters:
        id - the document ID to fetch.
        bucket - the bucket to use when fetching the doc.
        primaryTimeout - the timeout to use in MS when fetching the primary.
        replicaTimeout - the timeout to use in MS when subsequently fetching the replicas and primary.
        Returns:
        an Single with either 0 or 1 JsonDocument.
      • getFirstPrimaryOrReplica

        @Experimental
        @Public
        public rx.Single<JsonDocument> getFirstPrimaryOrReplica​(String id,
                                                                Bucket bucket,
                                                                long timeout)
        Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them (with a custom timeout value applied to both primary and replica).
        Parameters:
        id - the document ID to fetch.
        bucket - the bucket to use when fetching the doc.
        timeout - the timeout to use for both primary and replica fetches (separately)
        Returns:
        an Single with either 0 or 1 JsonDocument.
      • getFirstPrimaryOrReplica

        @Experimental
        @Public
        public rx.Single<JsonDocument> getFirstPrimaryOrReplica​(String id,
                                                                Bucket bucket)
        Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them (using the environments KV timeout for both primary and replica).
        Parameters:
        id - the document ID to fetch.
        bucket - the bucket to use when fetching the doc.
        Returns:
        an Single with either 0 or 1 JsonDocument.
      • getFirstPrimaryOrReplica

        @Experimental
        @Public
        public static <D extends Document<?>> rx.Single<D> getFirstPrimaryOrReplica​(String id,
                                                                                    Class<D> target,
                                                                                    Bucket bucket)
        Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them (using the environments KV timeout for both primary and replica).
        Parameters:
        id - the document ID to fetch.
        target - the custom document type to use.
        bucket - the bucket to use when fetching the doc.
        Returns:
      • getFirstPrimaryOrReplica

        @Experimental
        @Public
        public static <D extends Document<?>> rx.Single<D> getFirstPrimaryOrReplica​(String id,
                                                                                    Class<D> target,
                                                                                    Bucket bucket,
                                                                                    long timeout)
        Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them (with a custom timeout value applied to both primary and replica).
        Parameters:
        id - the document ID to fetch.
        target - the custom document type to use.
        bucket - the bucket to use when fetching the doc.
        timeout - the timeout to use for both primary and replica fetches (separately)
        Returns:
      • getFirstPrimaryOrReplica

        @Experimental
        @Public
        public static <D extends Document<?>> rx.Single<D> getFirstPrimaryOrReplica​(String id,
                                                                                    Class<D> target,
                                                                                    Bucket bucket,
                                                                                    long primaryTimeout,
                                                                                    long replicaTimeout)
        Asynchronously fetch the document from the primary and if that operations fails try all the replicas and return the first document that comes back from them.
        Parameters:
        id - the document ID to fetch.
        target - the custom document type to use.
        bucket - the bucket to use when fetching the doc.
        primaryTimeout - the timeout to use in MS when fetching the primary.
        replicaTimeout - the timeout to use in MS when subsequently fetching the replicas and primary.
        Returns: