Class NettyStatusProvider

java.lang.Object
com.github.jpmsilva.jsystemd.spring.NettyStatusProvider
All Implemented Interfaces:
StatusProvider, Function<reactor.netty.http.server.HttpServer,reactor.netty.http.server.HttpServer>, NettyServerCustomizer

public class NettyStatusProvider extends Object implements StatusProvider, NettyServerCustomizer
Implementation of StatusProvider that provides information regarding the embedded Reactor Netty servers of the application.

For each server, named after the port it listens on, it reports the open connections and the requests being handled, such as netty-8080: 12 connections, 3 requests. Reactor Netty handles requests on a few event loop threads, which never block, so there is no thread pool to report on. A server that is not listening is left out.

Reactor Netty does not count its connections and requests unless it records metrics with Micrometer, so this provider counts them itself: it is a NettyServerCustomizer, which Spring Boot applies to the servers it creates, the server of the application as well as the server of the management endpoints when they use a port of their own. Only the connections and requests of the servers created after it are counted.

Author:
Joao Silva
  • Constructor Details

    • NettyStatusProvider

      public NettyStatusProvider()
      Create a new NettyStatusProvider.
  • Method Details

    • apply

      public reactor.netty.http.server.HttpServer apply(reactor.netty.http.server.HttpServer server)
      Makes the server count its connections and requests, and report them once it listens.
      Specified by:
      apply in interface Function<reactor.netty.http.server.HttpServer,reactor.netty.http.server.HttpServer>
      Parameters:
      server - the server to count the connections and requests of
      Returns:
      the server that counts its connections and requests
    • status

      public String status()
      Description copied from interface: StatusProvider
      Exposes status information to send to systemd.
      Specified by:
      status in interface StatusProvider
      Returns:
      the string message to add to the service status