Class AbstractServiceEntry

java.lang.Object
io.micronaut.discovery.consul.client.v1.AbstractServiceEntry
Direct Known Subclasses:
NewServiceEntry

@Introspected public abstract class AbstractServiceEntry extends Object
Base class for a service entry in consul.
Since:
1.0
Author:
graemerocher
  • Field Details

    • name

      protected final String name
  • Constructor Details

    • AbstractServiceEntry

      public AbstractServiceEntry(String name)
      Parameters:
      name - The service name
  • Method Details

    • getID

      public Optional<String> getID()
      See https://www.consul.io/api/agent/service.html#id.
      Returns:
      The ID of the service
    • setID

      public void setID(String id)
      See https://www.consul.io/api/agent/service.html#id.
      Parameters:
      id - The ID of the service
    • getHostString

      public Optional<String> getHostString()
      See https://www.consul.io/api/agent/service.html#address.
      Returns:
      The address of the service, a host name or an IP literal. It is not resolved.
      Since:
      5.2.0
    • setHostString

      public void setHostString(String hostString)
      See https://www.consul.io/api/agent/service.html#address.
      Parameters:
      hostString - The address of the service, a host name or an IP literal
      Since:
      5.2.0
    • getAddress

      @Deprecated(since="5.2.0", forRemoval=true) public Optional<InetAddress> getAddress()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use getHostString() and resolve the address where it is needed.
      See https://www.consul.io/api/agent/service.html#address.

      The address is resolved on each call, which needs a DNS lookup when it is a host name.

      Returns:
      The resolved address of the service
      Throws:
      UncheckedIOException - if the host name cannot be resolved
    • setAddress

      public void setAddress(InetAddress address)
      See https://www.consul.io/api/agent/service.html#address.

      The address is stored as its host name, or as its IP literal when it has no host name.

      Parameters:
      address - The address of the service
    • getPort

      public OptionalInt getPort()
      See https://www.consul.io/api/agent/service.html#address.
      Returns:
      The port of the service
    • setPort

      public void setPort(Integer port)
      See https://www.consul.io/api/agent/service.html#address.
      Parameters:
      port - The port of the service
    • getTags

      public List<String> getTags()
      See https://www.consul.io/api/agent/service.html#tags.
      Returns:
      The service tags
    • setTags

      public void setTags(List<String> tags)
      See https://www.consul.io/api/agent/service.html#tags.
      Parameters:
      tags - The service tags
    • getMeta

      public Map<String,String> getMeta()
      See https://www.consul.io/api/agent/service.html#meta.
      Returns:
      The service metadata
    • setMeta

      public void setMeta(Map<String,String> meta)
      See https://www.consul.io/api/agent/service.html#meta.
      Parameters:
      meta - The service metadata
    • getName

      public String getName()
      See https://www.consul.io/api/agent/service.html#name.
      Returns:
      The name of the service
    • id

      public AbstractServiceEntry id(String id)
      Parameters:
      id - The id of the service
      Returns:
      The AbstractServiceEntry instance
    • address

      public AbstractServiceEntry address(InetAddress address)
      Parameters:
      address - The InetAddress of the service, stored as its host name, or as its IP literal when it has no host name
      Returns:
      The AbstractServiceEntry instance
    • address

      public AbstractServiceEntry address(String address)
      Sets the address as given. Since 5.2.0 it is no longer resolved, so a host name is sent to Consul unchanged.
      Parameters:
      address - The address of the service, a host name or an IP literal
      Returns:
      The AbstractServiceEntry instance
    • port

      public AbstractServiceEntry port(Integer port)
      Parameters:
      port - The port of the service
      Returns:
      The AbstractServiceEntry instance
    • tags

      public AbstractServiceEntry tags(List<String> tags)
      Parameters:
      tags - The service tags
      Returns:
      The AbstractServiceEntry instance
    • meta

      public AbstractServiceEntry meta(Map<String,String> meta)
      Parameters:
      meta - The service metadata
      Returns:
      The AbstractServiceEntry instance
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object