Interface ServiceDiscovery<T>

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable
    All Known Implementing Classes:
    ServiceDiscoveryImpl

    public interface ServiceDiscovery<T>
    extends java.io.Closeable
    • Method Detail

      • start

        void start()
            throws java.lang.Exception
        The discovery must be started before use
        Throws:
        java.lang.Exception - errors
      • registerService

        void registerService​(ServiceInstance<T> service)
                      throws java.lang.Exception
        Register/re-register a service
        Parameters:
        service - service to add
        Throws:
        java.lang.Exception - errors
      • updateService

        void updateService​(ServiceInstance<T> service)
                    throws java.lang.Exception
        Update a service
        Parameters:
        service - service to update
        Throws:
        java.lang.Exception - errors
      • unregisterService

        void unregisterService​(ServiceInstance<T> service)
                        throws java.lang.Exception
        Unregister/remove a service instance
        Parameters:
        service - the service
        Throws:
        java.lang.Exception - errors
      • serviceCacheBuilder

        ServiceCacheBuilder<T> serviceCacheBuilder()
        Allocate a new service cache builder. The refresh padding is defaulted to 1 second.
        Returns:
        new cache builder
      • queryForNames

        java.util.Collection<java.lang.String> queryForNames()
                                                      throws java.lang.Exception
        Return the names of all known services
        Returns:
        list of service names
        Throws:
        java.lang.Exception - errors
      • queryForInstances

        java.util.Collection<ServiceInstance<T>> queryForInstances​(java.lang.String name)
                                                            throws java.lang.Exception
        Return all known instances for the given service
        Parameters:
        name - name of the service
        Returns:
        list of instances (or an empty list)
        Throws:
        java.lang.Exception - errors
      • queryForInstance

        ServiceInstance<T> queryForInstance​(java.lang.String name,
                                            java.lang.String id)
                                     throws java.lang.Exception
        Return a service instance POJO
        Parameters:
        name - name of the service
        id - ID of the instance
        Returns:
        the instance or null if not found
        Throws:
        java.lang.Exception - errors