Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Neodriver_eio.SessionSourcePer-session connection: auto-commit queries, explicit and managed transactions.
Per-session connection with auto-commit queries, explicit and managed transactions.
A t owns the session's lazy connection, its bookmarks and its current explicit transaction. run sends an auto-commit query and returns a lazily streamed Neo4j_result.t (records are pulled on demand; the bookmark from the final PULL summary is recorded automatically once the result is consumed); begin_transaction opens an explicit transaction; execute runs a managed transaction (unit of work) with the retry loop described in the PLAN (budget, jittered backoff, decision via Errors.is_retryable). Between retry attempts the connection is recovered with a RESET rather than reconnected.
Modeled on the Python driver's AsyncSession (_async/work/session.py).
type failure = | Driver of Neodriver_core.Errors.t| ClientHow a unit of work failed: Driver e is a driver/server error (e may be retryable); Client is an application (frontend) error, which is never retried.
type config = {database : string option;access_mode : Neodriver_core.Config.access_mode;impersonated_user : string option;fetch_size : int option;bookmarks : string list;max_transaction_retry_time : float;initial_retry_delay : float;retry_delay_multiplier : float;retry_delay_jitter_factor : float;}Session settings. bookmarks seeds the session's bookmarks. The retry parameters mirror the Python driver defaults (max_transaction_retry_time is configurable via the TestKit driver request).
Session configuration with the driver defaults: write access, no database or impersonation, and the Python retry defaults (1s initial delay, x2 multiplier, 0.2 jitter, 30s budget).
A session: its lazy connection, bookmarks and current transaction.
val create :
config ->
clock:Mtime.t Eio.Time.clock_ty Eio.Resource.t ->
connect:(unit -> (Conn.t, Neodriver_core.Errors.t) result) ->
tCreate a session. connect establishes the session's connection on first use (the backend provides it from the Eio context). clock bounds the transaction retry budget and backoff.
The session's connection, connecting on first use.
val run :
?timeout:float ->
?metadata:(string * Neodriver_core.Values.t) list ->
t ->
query:string ->
parameters:(string * Neodriver_core.Values.t) list ->
(Neodriver_eio__.Neo4j_result.t, Neodriver_core.Errors.t) resultRun an auto-commit query: send RUN only (the result streams on demand via Result). The session's bookmarks, database and access mode go into the RUN extra. Any previously pending auto-commit result is drained first. Once the result ends normally, the session's bookmarks are updated from its final summary.
val begin_transaction :
?metadata:(string * Neodriver_core.Values.t) list ->
?timeout:float ->
t ->
(Tx.t, Neodriver_core.Errors.t) resultBegin an explicit transaction on the session's connection.
val execute :
t ->
mode:Neodriver_core.Config.access_mode ->
?metadata:(string * Neodriver_core.Values.t) list ->
?timeout:float ->
(Tx.t -> (unit, failure) result) ->
(unit, failure) resultRun the unit of work work in a managed transaction with retry. work is invoked on a fresh transaction each attempt. On Ok the transaction is committed and the session's bookmarks updated. On Error (Driver e) the transaction is rolled back; if Errors.is_retryable e and the max_transaction_retry_time budget remains, work is retried after a jittered backoff. On Error Client the transaction is rolled back without retrying.
The session's last known bookmarks (seeded from the config, updated on every successful commit).
Record the end of the session's current transaction: a successful commit's bookmark updates the session's bookmarks; None leaves them unchanged. The session is then free to begin a new transaction.