Class ServiceInstance

java.lang.Object
org.kiwiproject.registry.model.ServiceInstance

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

    • 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
    • getApplicationPort

      public Port getApplicationPort()
      Returns the application port of this instance, preferring the secure port (if both secure and insecure exist).
      Returns:
      the application port
      See Also:
    • getAdminPort

      public Port getAdminPort()
      Returns the admin port of this instance, preferring the secure port (if both secure and insecure exist).
      Returns:
      the admin port
      See Also:
    • builder

      public static ServiceInstance.ServiceInstanceBuilder builder()
    • toBuilder

    • getInstanceId

      public String getInstanceId()
    • getStatus

      public ServiceInstance.Status getStatus()
    • getServiceName

      public String getServiceName()
    • getHostName

      public String getHostName()
    • getIp

      public String getIp()
    • getPorts

      public List<Port> getPorts()
    • getPaths

      public ServicePaths getPaths()
    • 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.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public String toString()
      Overrides:
      toString 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).