Class HttpClientSubmitter

java.lang.Object
io.github.projectunified.faststats.httpclient.HttpClientSubmitter
All Implemented Interfaces:
Submitter

public class HttpClientSubmitter extends Object implements Submitter
Implementation of Submitter that uses HttpClient to submit GZIP-compressed telemetry payloads.
  • Constructor Details

    • HttpClientSubmitter

      public HttpClientSubmitter(String token)
      Constructs a new HttpClientSubmitter with the default metrics URI (https://metrics.faststats.dev/v1/collect), standard HttpClient, and default user agent.
      Parameters:
      token - the authorization token (bearer)
    • HttpClientSubmitter

      public HttpClientSubmitter(URI uri, String token)
      Constructs a new HttpClientSubmitter with standard HttpClient and default user agent.
      Parameters:
      uri - the target metrics URI
      token - the authorization token (bearer)
    • HttpClientSubmitter

      public HttpClientSubmitter(java.net.http.HttpClient httpClient, URI uri, String token, String userAgent)
      Constructs a new HttpClientSubmitter.
      Parameters:
      httpClient - the HttpClient instance to use
      uri - the target metrics URI
      token - the authorization token (bearer)
      userAgent - the user agent header value
  • Method Details

    • execute

      public void execute(String json) throws Exception
      Description copied from interface: Submitter
      Executes the HTTP request carrying the serialized JSON payload.
      Specified by:
      execute in interface Submitter
      Parameters:
      json - the JSON payload to transmit
      Throws:
      Exception - if transmission fails