Interface ILocationService


public interface ILocationService
A LocationService interface to manage connections and their registrations. All operations are non-blocking.
  • Method Details

    • asScala

      csw.location.api.scaladsl.LocationService asScala()
      Returns the Scala API for this instance of location service
      Returns:
      (undocumented)
    • find

      <L extends Location> CompletableFuture<Optional<L>> find(TypedConnection<L> connection)
      Resolve the location for a connection from the local cache

      Parameters:
      connection - a connection to resolve to with its registered location
      Returns:
      a CompletableFuture which completes with the resolved location if found or Empty otherwise. It can fail with RegistrationListingFailed.
    • list

      Lists all locations registered

      Returns:
      a CompletableFuture which completes with a List of all registered locations or can fail with RegistrationListingFailed
    • list

      Filters all locations registered based on a component type

      Parameters:
      componentType - list components of this componentType
      Returns:
      a CompletableFuture which completes with filtered locations or can fail with RegistrationListingFailed
    • list

      Filters all locations registered based on a hostname

      Parameters:
      hostname - list components running on this hostname
      Returns:
      a CompletableFuture which completes with filtered locations or can fail with RegistrationListingFailed
    • list

      Filters all locations registered based on a connection type

      Parameters:
      connectionType - list components of this connectionType
      Returns:
      a CompletableFuture which completes with filtered locations or can fail with RegistrationListingFailed
    • listByPrefix

      CompletableFuture<List<Location>> listByPrefix(String prefix)
      Filters all locations registered based on a prefix.

      Note that all locations having subsystem prefix that starts with the given prefix value will be listed

      Parameters:
      prefix - list components by this prefix
      Returns:
      a CompletableFuture which completes with filtered locations or can fail with RegistrationListingFailed
    • register

      Registers a connection to location

      Parameters:
      registration - the Registration holding connection and it's corresponding location to register with LocationService
      Returns:
      a CompletableFuture which completes with Registration result or can fail with RegistrationFailed or OtherLocationIsRegistered
    • resolve

      <L extends Location> CompletableFuture<Optional<L>> resolve(TypedConnection<L> connection, Duration within)
      Resolves the location based on the given connection

      Parameters:
      connection - a connection to resolve to with its registered location
      within - the time for which a connection is looked-up within LocationService
      Returns:
      a CompletableFuture which completes with the resolved location if found or None otherwise. It can fail with RegistrationListingFailed.
    • subscribe

      msocket.api.Subscription subscribe(Connection connection, Consumer<TrackingEvent> consumer)
      Subscribe to tracking events for a connection by providing a consumer For each event accept method of consumer interface is invoked. Use this method if you do not want to handle materialization and happy with a side-effecting callback instead

      Note that callbacks are not thread-safe on the JVM. If you are doing side effects/mutations inside the callback, you should ensure that it is done in a thread-safe way inside an actor.

      Parameters:
      connection - the connection that is to be tracked
      consumer - the Consumer function that consumes TrakingEvent
      Returns:
      a killswitch which can be shutdown to unsubscribe the consumer
    • track

      akka.stream.javadsl.Source<TrackingEvent,msocket.api.Subscription> track(Connection connection)
      Tracks the connection and send events for modification or removal of its location

      Parameters:
      connection - the connection that is to be tracked
      Returns:
      A stream that emits events related to the connection. It can be cancelled using KillSwitch. This will stop giving events for earlier tracked connection
    • unregister

      CompletableFuture<akka.Done> unregister(Connection connection)
      Unregisters the connection

      Note that this method is idempotent, which means multiple calls to unregister the same connection will be no-op once successfully unregistered from location service

      Parameters:
      connection - an already registered connection
      Returns:
      a CompletableFuture which completes after un-registration happens successfully and fails otherwise with UnregistrationFailed
    • unregisterAll

      CompletableFuture<akka.Done> unregisterAll()
      Unregisters all connections registered

      Note that it is highly recommended to use this method for testing purpose only

      Returns:
      a CompletableFuture which completes after all connections are unregistered successfully or fails otherwise with RegistrationListingFailed