Liking cljdoc? Tell your friends :D

wagoe.platform.shell.adapters.database.config-factory

Configuration-driven database adapter factory.

This namespace provides factory functions that only load database adapters that are marked as :active in the configuration files. This enables optimized deployments where only necessary JDBC drivers are loaded and initialized.

Key Features:

  • Only loads adapters marked as :active in config.edn
  • Graceful error handling for inactive adapters
  • Environment-aware adapter loading
  • Automatic configuration validation
  • JDBC driver optimization

Usage: (require '[wagoe.platform.shell.adapters.database.config-factory :as cf])

;; Load only active adapters for current environment (cf/create-active-contexts)

;; Create specific adapter context from config (cf/create-config-context "dev" :wagoe/sqlite)

Configuration-driven database adapter factory.

This namespace provides factory functions that only load database adapters
that are marked as :active in the configuration files. This enables optimized
deployments where only necessary JDBC drivers are loaded and initialized.

Key Features:
- Only loads adapters marked as :active in config.edn
- Graceful error handling for inactive adapters
- Environment-aware adapter loading
- Automatic configuration validation
- JDBC driver optimization

Usage:
  (require '[wagoe.platform.shell.adapters.database.config-factory :as cf])
  
  ;; Load only active adapters for current environment
  (cf/create-active-contexts)
  
  ;; Create specific adapter context from config
  (cf/create-config-context "dev" :wagoe/sqlite)
raw docstring

adapter-available?clj

(adapter-available? adapter-type env)

Check if an adapter type is available (active) in current environment

Check if an adapter type is available (active) in current environment
sourceraw docstring

adapter-supported?clj

(adapter-supported? adapter-key)

Check if adapter type is supported

Check if adapter type is supported
sourceraw docstring

create-active-adaptersclj

(create-active-adapters config)

Create all active adapters from configuration (test compatibility)

Create all active adapters from configuration (test compatibility)
sourceraw docstring

create-active-contextsclj

(create-active-contexts)
(create-active-contexts env)

Create database contexts for all active configurations in environment.

Args: env: Environment string (optional, defaults to detected environment)

Returns: Map of config-key -> database context

Example: (create-active-contexts "dev") ;; => {:wagoe/sqlite {:adapter ... :datasource ...}}

Create database contexts for all active configurations in environment.

Args:
  env: Environment string (optional, defaults to detected environment)
  
Returns:
  Map of config-key -> database context
  
Example:
  (create-active-contexts "dev")
  ;; => {:wagoe/sqlite {:adapter ... :datasource ...}}
sourceraw docstring

create-adapterclj

(create-adapter adapter-key config)

Create adapter instance (test compatibility function)

Create adapter instance (test compatibility function)
sourceraw docstring

create-config-adapterclj

(create-config-adapter adapter-type env)

Create database adapter from configuration if it's active.

Args: adapter-type: Keyword adapter type (:sqlite, :postgresql, :mysql, :h2) env: Environment string (e.g. 'dev', 'prod')

Returns: Database adapter implementing DBAdapter protocol

Throws: IllegalStateException if adapter is not active RuntimeException if adapter loading fails

Create database adapter from configuration if it's active.

Args:
  adapter-type: Keyword adapter type (:sqlite, :postgresql, :mysql, :h2)
  env: Environment string (e.g. 'dev', 'prod')
  
Returns:
  Database adapter implementing DBAdapter protocol
  
Throws:
  IllegalStateException if adapter is not active
  RuntimeException if adapter loading fails
sourceraw docstring

create-config-contextclj

(create-config-context env config-key)

Create database context from configuration key.

Args: env: Environment string config-key: Configuration key (e.g. :wagoe/sqlite)

Returns: Database context map {:adapter adapter :datasource datasource}

Example: (create-config-context "dev" :wagoe/sqlite)

Create database context from configuration key.

Args:
  env: Environment string
  config-key: Configuration key (e.g. :wagoe/sqlite)
  
Returns:
  Database context map {:adapter adapter :datasource datasource}
  
Example:
  (create-config-context "dev" :wagoe/sqlite)
sourceraw docstring

ensure-adapter-available!clj

(ensure-adapter-available! adapter-type env)

Ensure adapter is available, throw helpful error if not

Ensure adapter is available, throw helpful error if not
sourceraw docstring

get-active-adapter-typesclj

(get-active-adapter-types env)

Get list of active adapter types for environment

Get list of active adapter types for environment
sourceraw docstring

get-default-contextclj

(get-default-context)
(get-default-context env)

Get default database context for environment.

Tries to find contexts in this order:

  1. SQLite (most common for development)
  2. First available active adapter

Args: env: Environment string (optional)

Returns: Database context or throws if no active adapters found

Get default database context for environment.

Tries to find contexts in this order:
1. SQLite (most common for development)
2. First available active adapter

Args:
  env: Environment string (optional)
  
Returns:
  Database context or throws if no active adapters found
sourceraw docstring

health-checkclj

(health-check env)

Perform health check on all active database connections.

Args: env: Environment string

Returns: Map with health check results for each active adapter

Perform health check on all active database connections.

Args:
  env: Environment string
  
Returns:
  Map with health check results for each active adapter
sourceraw docstring

list-available-adaptersclj

(list-available-adapters)

List all available adapter types

List all available adapter types
sourceraw docstring

(print-environment-summary env)

Print comprehensive summary of database configuration for environment

Print comprehensive summary of database configuration for environment
sourceraw docstring

valid-adapter-config?clj

(valid-adapter-config? adapter-key config)

Validate adapter configuration (test compatibility)

Validate adapter configuration (test compatibility)
sourceraw docstring

validate-environment-configclj

(validate-environment-config env)

Validate database configuration for environment

Validate database configuration for environment
sourceraw docstring

with-config-contextclj

(with-config-context env config-key f)

Execute function with database context from configuration.

Args: env: Environment string config-key: Configuration key (e.g. :wagoe/sqlite) f: Function that takes database context

Returns: Result of function execution

Execute function with database context from configuration.

Args:
  env: Environment string
  config-key: Configuration key (e.g. :wagoe/sqlite)
  f: Function that takes database context
  
Returns:
  Result of function execution
sourceraw docstring

with-default-contextclj

(with-default-context f)
(with-default-context env f)

Execute function with default database context for environment.

Args: env: Environment string (optional) f: Function that takes database context

Returns: Result of function execution

Execute function with default database context for environment.

Args:
  env: Environment string (optional)
  f: Function that takes database context
  
Returns:
  Result of function execution
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close