Class ServiceInstance


  • public final class ServiceInstance
    extends Object
    Model containing information about a running service
    • Method Detail

      • fromServiceInfo

        public static ServiceInstance fromServiceInfo​(ServiceInfo serviceInfo)
        Returns a new ServiceInstanceBuilder built from a given ServiceInfo.

        Note that a copy of ServiceInfo.getMetadata() is made using Map.copyOf(Map), so the metadata is unmodifiable.

        Parameters:
        serviceInfo - The information about the service used to initialize the ServiceInstanceBuilder
        Returns:
        a ServiceInstanceBuilder with values copied from the given ServiceInfo
      • getUpSince

        public Instant getUpSince()
        Returns the Instant this service has been up since, or Instant.EPOCH if no value was provided when this instance was created.
        Returns:
        a non-null Instant representing the instant this service was started, or the epoch if no value provided
      • getUpSinceMillis

        public long getUpSinceMillis()
        Returns the time since the epoch this service has been up since, or zero (the epoch), if no value was provided when this instance was created.
        Returns:
        the number of milliseconds since the epoch that this service was started, or zero if no value provided
      • getInstanceId

        public String getInstanceId()
      • getServiceName

        public String getServiceName()
      • getHostName

        public String getHostName()
      • getIp

        public String getIp()
      • getPorts

        public List<Port> getPorts()
      • getCommitRef

        public String getCommitRef()
      • getDescription

        public String getDescription()
      • getVersion

        public String getVersion()
      • getMetadata

        public Map<String,​String> getMetadata()
        Used to store extra data in a discovery service for this instance
      • getNativeRegistryData

        public Map<String,​Object> getNativeRegistryData()
        Used to store native registry data that includes data mapped into ServiceInstance as well as any additional information that is not mapped. This will only be populated if the registry configuration specifies to include native data.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • withInstanceId

        public ServiceInstance withInstanceId​(String instanceId)
        Returns:
        a clone of this object, except with this updated property (returns this if an identical value is passed).
      • withStatus

        public ServiceInstance withStatus​(ServiceInstance.Status status)
        Returns:
        a clone of this object, except with this updated property (returns this if an identical value is passed).
      • withHostName

        public ServiceInstance withHostName​(String hostName)
        Returns:
        a clone of this object, except with this updated property (returns this if an identical value is passed).
      • withMetadata

        public ServiceInstance withMetadata​(Map<String,​String> metadata)
        Used to store extra data in a discovery service for this instance
        Returns:
        a clone of this object, except with this updated property (returns this if an identical value is passed).
      • withNativeRegistryData

        public ServiceInstance withNativeRegistryData​(Map<String,​Object> nativeRegistryData)
        Used to store native registry data that includes data mapped into ServiceInstance as well as any additional information that is not mapped. This will only be populated if the registry configuration specifies to include native data.
        Returns:
        a clone of this object, except with this updated property (returns this if an identical value is passed).