Class RemoteStore

java.lang.Object
me.ahoo.cosid.store.remote.RemoteStore
All Implemented Interfaces:
AutoCloseable, me.ahoo.cosid.store.Store

public final class RemoteStore extends Object implements me.ahoo.cosid.store.Store
The remote store (06-stores.md ยง2.5, 08-remote.md): both primitives as calls to cosid-server, which runs them on its own backing store. One round trip per call over the JDK HttpClient; no third-party dependency.

Errors the primitives have an outcome for map to it (410 โ†’ RangeSealedException, 409 slots_exhausted โ†’ AcquireResult.Exhausted, 409 lease_lost โ†’ an empty renew or a false release, ...); every other failure throws a RemoteStoreException.

  • Field Details

    • DEFAULT_CONNECT_TIMEOUT

      public static final Duration DEFAULT_CONNECT_TIMEOUT
      The connect timeout when none is configured.
  • Constructor Details

    • RemoteStore

      public RemoteStore(URI baseUrl, Optional<String> token, Duration connectTimeout, Duration requestTimeout)
      A store on a server.
      Parameters:
      baseUrl - the server, such as http://cosid-server:8080
      token - the bearer token; empty for a server that allows anonymous calls
      connectTimeout - the connect timeout
      requestTimeout - the timeout of each call
  • Method Details

    • baseUrl

      public URI baseUrl()
      The server.
      Returns:
      the base URL, without a trailing slash
    • ranges

      public me.ahoo.cosid.segment.RangeStore ranges()
      Specified by:
      ranges in interface me.ahoo.cosid.store.Store
    • slots

      public me.ahoo.cosid.lease.SlotLeaseStore slots()
      Specified by:
      slots in interface me.ahoo.cosid.store.Store
    • close

      public void close()
      Closes the HTTP client.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface me.ahoo.cosid.store.Store