Interface ConnectionMetadata


public interface ConnectionMetadata
Connection-level metadata for logging e.g. addresses or ports.
Since:
4.6.0
Author:
Jonas Konrad
  • Method Details

    • localAddress

      Optional<SocketAddress> localAddress()
      The local address of this connection, if applicable.
      Returns:
      The local address
    • remoteAddress

      Optional<SocketAddress> remoteAddress()
      The remote address of this connection, if applicable.
      Returns:
      The remote address
    • getHostAddress

      static Optional<String> getHostAddress(SocketAddress a)
      Get the host address string of the given SocketAddress instance. This is usually the numeric IP, but for unix domain socket it is the file path.
      Parameters:
      a - The address
      Returns:
      The string representation, or Optional.empty() if this type of address is not supported
    • getHostName

      static Optional<String> getHostName(SocketAddress a)
      Get the host name of the given SocketAddress instance. This is usually the DNS name or IP, but for unix domain socket it is the file path.
      Parameters:
      a - The address
      Returns:
      The string representation, or Optional.empty() if this type of address is not supported
    • ofNettyChannel

      static ConnectionMetadata ofNettyChannel(io.netty.channel.Channel channel)
      Create a new ConnectionMetadata instance for the given netty channel.
      Parameters:
      channel - The channel
      Returns:
      The metadata, potentially empty()
    • empty

      static ConnectionMetadata empty()
      Placeholder metadata for unsupported channel types.
      Returns:
      An empty metadata instance