Class DbClientServiceBase.DbClientServiceBuilderBase<B extends DbClientServiceBase.DbClientServiceBuilderBase<B>>

java.lang.Object
io.helidon.dbclient.common.DbClientServiceBase.DbClientServiceBuilderBase<B>
Type Parameters:
B - type of the builder extending this class
Direct Known Subclasses:
DbClientMetricBuilder, DbClientTracing.Builder
Enclosing class:
DbClientServiceBase

public abstract static class DbClientServiceBase.DbClientServiceBuilderBase<B extends DbClientServiceBase.DbClientServiceBuilderBase<B>> extends Object
A base class for builders of DbClientServiceBase.
  • Constructor Details

    • DbClientServiceBuilderBase

      protected DbClientServiceBuilderBase()
      No-op constructor.
  • Method Details

    • config

      public B config(Config config)
      Configure this client service from config.

      Supported keys:

      DB Client Service configuration options
      key default value description
      statement-names   An array of statement name patterns to apply this service for. If undefined, service would be executed for all statements. See statementNames(String...) and Pattern
      statement-types   An array of statement types to apply this service for. If undefined, service would be executed for all statements. See statementTypes(io.helidon.dbclient.DbStatementType...).
      enabled true Whether this client service is enabled. See enabled(boolean)
      Parameters:
      config - configuration on the node of this service
      Returns:
      updated builder instance
    • statementPredicate

      public B statementPredicate(Predicate<DbClientServiceContext> predicate)
      Configure a predicate whose result will be used to decide whether to trigger this service or not.

      When a predicate is explicitly configured, statementNames(String...) and statementTypes(io.helidon.dbclient.DbStatementType...) is ignored.

      Parameters:
      predicate - predicate that should return true to enable this service, or false to disable it
      Returns:
      updated builder instance
    • statementTypes

      public B statementTypes(DbStatementType... types)
      Configure statement types this service will be triggered for. If an explicit statementPredicate(java.util.function.Predicate) is configured, this method is ignored.
      Parameters:
      types - types that trigger this service
      Returns:
      updated builder instance
    • statementNames

      public B statementNames(String... names)
      Configure statement name patterns this service will be triggered for. If an explicit statementPredicate(java.util.function.Predicate) is configured, this method is ignored.
      Parameters:
      names - name patterns (as in Pattern) that trigger this service
      Returns:
      updated builder instance
    • enabled

      public void enabled(boolean enabled)
      Configure whether this service is enabled or not.
      Parameters:
      enabled - whether to enable this service or disable it, true by default
    • statementTypes

      protected B statementTypes(List<DbStatementType> types)
      Configures statement types from configuration.
      Parameters:
      types - types to add for this service
      Returns:
      updated builder instance
    • statementNames

      protected B statementNames(List<String> names)
      Configures statement name patterns from configuration.
      Parameters:
      names - names to add for this service
      Returns:
      updated builder instance
    • statementNames

      protected Set<String> statementNames()
      Set of statement name patterns.
      Returns:
      configured statement names
    • statementTypes

      protected Set<DbStatementType> statementTypes()
      Set of statement types.
      Returns:
      configured statement types
    • predicate

      protected Predicate<DbClientServiceContext> predicate()
      Predicate used to build a client service.

      The predicate always returns false if service is disabled.

      The predicate is obtained from the configured predicate using statementPredicate(java.util.function.Predicate), if none is configured, it is created from configured statement types and statement names. If none are configured, the predicate just returns true.

      Returns:
      predicate to check whether this service should be invoked for current statement context