Package com.jsgalactic.axiom.jdbc
Class Jdbc.Builder
java.lang.Object
com.jsgalactic.axiom.jdbc.Jdbc.Builder
- Enclosing class:
Jdbc
Collects bounds and hooks before
build(). Not thread-safe.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the gate and registers its lifecycle actions with the application.Opts the application into owning the wrapped connections it leaves open: closing the gate or the application then closes those connections.maxConnections(int maxConnections) Sets the largest number of concurrent permits.Replaces the metrics destination.Sets the bounded tag value of the wrapper's connection series.probeQuery(String probeQuery) Sets the read-only statement used byJdbc.healthCheck().probeTimeout(Duration probeTimeout) Sets the statement timeout of one health probe.readiness(Health.Builder builder) Adds a readiness check nameddatabaseto a health builder that has not been built yet.register()Builds the gate and registers its middleware globally.routeLimit(Route route, int maxConnections) Caps one route independently of the aggregate.Sets how long a request waits for a permit before answering 503.
-
Method Details
-
name
Sets the bounded tag value of the wrapper's connection series. Defaults todatabase.- Parameters:
name- 1 to 64 lowercase letters, digits,_,.or-- Returns:
- this builder
-
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
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
Sets the read-only statement used byJdbc.healthCheck(). It must be one shortSELECTwith no semicolon; the default isSELECT 1.- Parameters:
probeQuery- statement run on each health probe- Returns:
- this builder
-
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
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 identitymaxConnections- route cap from 1 to the aggregate cap- Returns:
- this builder
-
closeConnectionsOnShutdown
Opts the application into owning the wrapped connections it leaves open: closing the gate or the application then closes those connections. The delegateDataSourceis never closed either way, and the default is to touch nothing on close.- Returns:
- this builder
-
metrics
Replaces the metrics destination. By default the gate and wrapper record throughApplication.metrics().- Parameters:
metrics- thread-safe metrics implementation- Returns:
- this builder
-
readiness
Adds a readiness check nameddatabaseto a health builder that has not been built yet. The check usesJdbc.healthCheck()and is bounded by its own statement timeout.- Parameters:
builder- health builder- Returns:
- this builder
-
build
Builds the gate and registers its lifecycle actions with the application. No middleware is registered untilJdbc.register()or an explicitapp.use(jdbc.middleware()).- Returns:
- the configured gate
- Throws:
IllegalArgumentException- if a bound is invalidIllegalStateException- if the application is closed
-
register
Builds the gate and registers its middleware globally.- Returns:
- the configured gate
- Throws:
IllegalArgumentException- if a bound is invalidIllegalStateException- if the application is closed
-