Interface ServiceProvider<T>

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
ServiceProviderImpl

public interface ServiceProvider<T> extends Closeable
The main API for Discovery. This class is essentially a facade over a ProviderStrategy paired with an InstanceProvider
  • Method Details

    • start

      void start() throws Exception
      The provider must be started before use
      Throws:
      Exception - any errors
    • getInstance

      ServiceInstance<T> getInstance() throws Exception
      Return an instance for a single use. IMPORTANT: users should not hold on to the instance returned. They should always get a fresh instance.
      Returns:
      the instance to use
      Throws:
      Exception - any errors
    • getAllInstances

      Collection<ServiceInstance<T>> getAllInstances() throws Exception
      Return the current available set of instances IMPORTANT: users should not hold on to the instance returned. They should always get a fresh list.
      Returns:
      all known instances
      Throws:
      Exception - any errors
    • noteError

      void noteError(ServiceInstance<T> instance)
      Take note of an error connecting to the given instance. The instance will potentially be marked as "down" depending on the DownInstancePolicy.
      Parameters:
      instance - instance that had an error
    • close

      void close() throws IOException
      Close the provider. Note: it's the provider's responsibility to close any caches it manages
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException