Module Neodriver_core.Config

Configuration records with validated constructors.

Configuration records for the Neo4j driver.

See config.ml for the implementation.

type access_mode =
  1. | Read
  2. | Write
    (*

    Access mode for a session: Read or Write.

    *)
type workspace_config = {
  1. max_transaction_retry_time : float;
  2. initial_retry_delay : float;
  3. retry_delay_multiplier : float;
  4. retry_delay_jitter_factor : float;
  5. fetch_size : int;
  6. database : string option;
  7. impersonated_user : string option;
  8. disable_auto_commit_retries : bool;
}

Session workspace settings: retry policy, fetch size and database selection.

type encryption =
  1. | Default
    (*

    The URI scheme decides: plain for bolt/neo4j, TLS for the +s/+ssc variants.

    *)
  2. | Enabled
    (*

    Force TLS (only valid with a plain scheme, otherwise a Configuration_error).

    *)
  3. | Disabled
    (*

    Force no TLS.

    *)

The explicit encryption setting (the deprecated alternative to the URI schemes).

type trusted_certificates =
  1. | System
  2. | Trust_all
  3. | Custom of string list

The explicit trusted_certificates configuration (the deprecated alternative to the URI schemes). Custom holds file paths; they are loaded when the driver is connected.

type client_certificate = {
  1. certfile : string;
    (*

    PEM certificate chain file to present to the server.

    *)
  2. keyfile : string;
    (*

    PEM private key file matching certfile.

    *)
  3. password : string option;
    (*

    Password of an encrypted keyfile, if any.

    *)
}

The client certificate (mTLS) to present to the server.

type pool_config = {
  1. max_connection_lifetime : float;
  2. liveness_check_timeout : float option;
  3. max_connection_pool_size : int;
  4. connection_acquisition_timeout : float;
  5. connection_timeout : float;
  6. connection_write_timeout : float;
  7. keep_alive : bool;
  8. encryption : encryption;
  9. trusted_certificates : trusted_certificates option;
  10. client_certificate : client_certificate option;
  11. telemetry_disabled : bool;
  12. notifications_min_severity : string option;
  13. notifications_disabled_categories : string list option;
  14. home_db_cache_ttl : float;
}

Connection pool settings. encryption overrides the URI scheme's TLS choice (Default keeps the scheme default: off for bolt/neo4j, on for the +s/+ssc variants); trusted_certificates overrides which certificates are trusted. The two are the deprecated explicit security config, only allowed with a plain scheme; conflicting values (explicit config with a secure scheme, or trust anchors without encryption) are rejected when the driver is connected. client_certificate is the mTLS certificate presented to the server (allowed with both secure and plain schemes; it requires encryption). home_db_cache_ttl is how long a routed driver remembers a resolved home database (default Float.infinity, i.e. the cache is on — a default-database session guesses the cached home database only when a server-side-routing capable connection has been seen); a TTL <= 0.0 disables the cache and every default-database session re-fetches the home database over ROUTE. connection_timeout bounds the TCP connect / TLS handshake and subsequent reads (default 30.0; Float.infinity disables it); connection_write_timeout bounds writes (default 30.0; Float.infinity disables it). keep_alive sets the SO_KEEPALIVE socket option on every TCP connection (default true; a failure to set it fails the connection). notifications_min_severity and notifications_disabled_categories are the driver-level notification filtering settings sent in HELLO (Bolt >= 5.2; None omits the field, Some [] sends an empty category list).

val default_access_mode : access_mode

Default access mode (Write).

val default_workspace_config : workspace_config

Default workspace configuration.

val default_pool_config : pool_config

Default pool configuration.

val make_workspace_config : ?max_transaction_retry_time:float -> ?initial_retry_delay:float -> ?retry_delay_multiplier:float -> ?retry_delay_jitter_factor:float -> ?fetch_size:int -> ?database:string option -> ?impersonated_user:string option -> ?disable_auto_commit_retries:bool -> unit -> (workspace_config, Errors.t) Stdlib.result

Build a workspace_config from the given overrides (defaults from default_workspace_config), validating the numeric settings.

  • returns

    Error (Errors.Configuration_error _) on out-of-range values.

val make_pool_config : ?max_connection_lifetime:float -> ?liveness_check_timeout:float option -> ?max_connection_pool_size:int -> ?connection_acquisition_timeout:float -> ?connection_timeout:float -> ?connection_write_timeout:float -> ?keep_alive:bool -> ?encryption:encryption -> ?trusted_certificates:trusted_certificates option -> ?client_certificate:client_certificate option -> ?telemetry_disabled:bool -> ?notifications_min_severity:string option -> ?notifications_disabled_categories:string list option -> ?home_db_cache_ttl:float -> unit -> (pool_config, Errors.t) Stdlib.result

Build a pool_config from the given overrides (defaults from default_pool_config), validating the numeric settings.

  • returns

    Error (Errors.Configuration_error _) on out-of-range values.