Interface ConnectionMetadata


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

    • localAddress

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

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

      static Optional<String> getHostAddress(@NonNull @NonNull 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(@NonNull @NonNull 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

      @NonNull static @NonNull ConnectionMetadata ofNettyChannel(@NonNull @NonNull 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

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