Class Jdbc.Builder

java.lang.Object
com.jsgalactic.axiom.jdbc.Jdbc.Builder
Enclosing class:
Jdbc

public static final class Jdbc.Builder extends Object
Collects bounds and hooks before build(). Not thread-safe.
  • Method Details

    • name

      public Jdbc.Builder name(String name)
      Sets the bounded tag value of the wrapper's connection series. Defaults to database.
      Parameters:
      name - 1 to 64 lowercase letters, digits, _, . or -
      Returns:
      this builder
    • maxConnections

      public Jdbc.Builder maxConnections(int maxConnections)
      Sets the largest number of concurrent permits. Defaults to 16; valid values are 1 to 1024.
      Parameters:
      maxConnections - aggregate cap
      Returns:
      this builder
    • wait

      public Jdbc.Builder wait(Duration wait)
      Sets how long a request waits for a permit before answering 503. Defaults to two seconds; valid values are zero to 30 seconds, where zero refuses immediately when full.
      Parameters:
      wait - bounded wait
      Returns:
      this builder
    • probeQuery

      public Jdbc.Builder probeQuery(String probeQuery)
      Sets the read-only statement used by Jdbc.healthCheck(). It must be one short SELECT with no semicolon; the default is SELECT 1.
      Parameters:
      probeQuery - statement run on each health probe
      Returns:
      this builder
    • probeTimeout

      public Jdbc.Builder probeTimeout(Duration probeTimeout)
      Sets the statement timeout of one health probe. Defaults to one second; valid values are one to 30 seconds. The health builder's own probe timeout bounds the whole check as well.
      Parameters:
      probeTimeout - statement timeout
      Returns:
      this builder
    • routeLimit

      public Jdbc.Builder routeLimit(Route route, int maxConnections)
      Caps one route independently of the aggregate. Both caps must have room; a route cap above the aggregate is rejected at build time. A later call for the same route replaces the cap.
      Parameters:
      route - registered route identity
      maxConnections - route cap from 1 to the aggregate cap
      Returns:
      this builder
    • closeConnectionsOnShutdown

      public Jdbc.Builder closeConnectionsOnShutdown()
      Opts the application into owning the wrapped connections it leaves open: closing the gate or the application then closes those connections. The delegate DataSource is never closed either way, and the default is to touch nothing on close.
      Returns:
      this builder
    • metrics

      public Jdbc.Builder metrics(Metrics metrics)
      Replaces the metrics destination. By default the gate and wrapper record through Application.metrics().
      Parameters:
      metrics - thread-safe metrics implementation
      Returns:
      this builder
    • readiness

      public Jdbc.Builder readiness(Health.Builder builder)
      Adds a readiness check named database to a health builder that has not been built yet. The check uses Jdbc.healthCheck() and is bounded by its own statement timeout.
      Parameters:
      builder - health builder
      Returns:
      this builder
    • build

      public Jdbc build()
      Builds the gate and registers its lifecycle actions with the application. No middleware is registered until Jdbc.register() or an explicit app.use(jdbc.middleware()).
      Returns:
      the configured gate
      Throws:
      IllegalArgumentException - if a bound is invalid
      IllegalStateException - if the application is closed
    • register

      public Jdbc register()
      Builds the gate and registers its middleware globally.
      Returns:
      the configured gate
      Throws:
      IllegalArgumentException - if a bound is invalid
      IllegalStateException - if the application is closed