Neodriver_eio.ConnA minimal Bolt connection (connect, authenticate, RUN/PULL/DISCARD, transactions).
Minimal Bolt connection: TCP connect (+ optional TLS) + handshake + HELLO/auth + state machine.
See conn.ml for the implementation.
Authentication token sent in HELLO (Bolt <= 5.0) or LOGON (Bolt >= 5.1). Only the basic scheme is supported so far.
type config = {host : string;port : int;scheme : Neodriver_core.Addressing.scheme;connection_timeout : float;user_agent : string;auth : auth;}Target connection settings. The scheme selects TLS: Bolt plain, Bolt_secure TLS with certificate validation, Bolt_self_signed TLS without validation. Routing schemes (Neo4j*) are rejected until routing is implemented.
An established, authenticated Bolt connection: the transport, the negotiated protocol version and the tracked server state.
val basic_auth : ?principal:string -> ?credentials:string -> unit -> authThe basic authentication token (scheme = "basic"), with the given principal (default neo4j) and credentials (default empty).
val connect :
?resolver:
(Neodriver_core.Addressing.t ->
(Neodriver_core.Addressing.t list, Neodriver_core.Errors.t) Stdlib.result) ->
[> `Network | `Platform of [> `Generic ] ] Eio.Resource.t ->
Mtime.t Eio.Time.clock_ty Eio.Resource.t ->
Eio.Switch.t ->
config ->
(t, Neodriver_core.Errors.t) Stdlib.resultEstablish a connection (over TLS when the scheme requires it), negotiate the Bolt protocol version and authenticate. resolver replaces the address lookup: the address built from config is passed to it and each returned address is tried in turn (first success wins, errors are aggregated). Without resolver, the single configured address is used. An IPv6 literal in config.host is treated as such (the address is built with brackets around the host). For Bolt >= 5.1 the authentication is sent via LOGON after HELLO; for older versions it is inline in HELLO. clock bounds the whole attempt and subsequent reads/writes by config.connection_timeout.
val address : t -> Neodriver_core.Addressing.tThe resolved address the connection is established with.
val version : t -> int * intThe negotiated protocol version (major, minor).
val reset : t -> (unit, Neodriver_core.Errors.t) Stdlib.resultSend a RESET and wait for the response; the server returns to Ready.
val logon : t -> auth -> (unit, Neodriver_core.Errors.t) Stdlib.resultRe-authenticate with auth via LOGON (Bolt >= 5.1 only). A RESET is sent first if the server is in the Failed state.
val logoff : t -> (unit, Neodriver_core.Errors.t) Stdlib.resultDe-authenticate via LOGOFF (Bolt >= 5.1 only). A RESET is sent first if the server is in the Failed state.
val close : t -> unitClose the connection.
val hydration : t -> Neodriver_core.Hydration.tA fresh hydration scope for the connection's protocol version.
Metadata of a RUN response: the result's field names, the query id (for multiple results), the bookmark reported for an auto-commit transaction (if any) and the t_first timing (result available-after, milliseconds).
val run :
?mode:Neodriver_core.Config.access_mode ->
?db:string ->
?bookmarks:string list ->
?timeout:float ->
?metadata:(string * Neodriver_core.Values.t) list ->
t ->
hydration:Neodriver_core.Hydration.t ->
query:string ->
parameters:(string * Neodriver_core.Values.t) list ->
(run_metadata, Neodriver_core.Errors.t) Stdlib.resultSend a RUN message for query. parameters are dehydrated with hydration. The optional mode, db, bookmarks, timeout (seconds) and metadata (tx_metadata) go into the request's extra map.
val begin_ :
t ->
extra:Neodriver_packstream.Packstream.value ->
(unit, Neodriver_core.Errors.t) Stdlib.resultSend a BEGIN message (start a transaction) with the given extra map (see build_extra). A RESET is sent first if the server is in the Failed state.
val build_extra :
?mode:Neodriver_core.Config.access_mode ->
?db:string ->
?imp_user:string ->
?bookmarks:string list ->
?timeout:float ->
?metadata:(string * Neodriver_packstream.Packstream.value) list ->
unit ->
Neodriver_packstream.Packstream.valueThe extra map for BEGIN (and auto-commit RUN): mode (Read -> "r"), db, imp_user, bookmarks, timeout (seconds, sent as tx_timeout milliseconds) and metadata (tx_metadata, already dehydrated).
val commit :
t ->
(Neodriver_packstream.Packstream.value, Neodriver_core.Errors.t)
Stdlib.resultSend a COMMIT message (end the transaction, applying its writes). Returns the full response metadata (its bookmark entry records the commit position).
val rollback : t -> (unit, Neodriver_core.Errors.t) Stdlib.resultSend a ROLLBACK message (end the transaction, discarding its writes). On a Failed connection the server already discarded the transaction implicitly, so a RESET is sent instead.
val pull :
?n:int ->
?qid:int ->
t ->
hydration:Neodriver_core.Hydration.t ->
(Neodriver_core.Values.t list list
* (Neodriver_packstream.Packstream.value, Neodriver_core.Errors.t)
Stdlib.result,
Neodriver_core.Errors.t)
Stdlib.resultSend a PULL message, fetching up to n records (all by default) of the result qid. Records are hydrated with hydration. Returns the records delivered and the terminal outcome: Ok _ with the PULL summary metadata (its has_more flag, readable via Bolt.metadata_has_more, says whether more records remain) on SUCCESS, or Error _ for a server FAILURE (the records delivered before the failure are kept). A server failure leaves the connection in the Failed state.
val discard :
?n:int ->
?qid:int ->
t ->
(unit, Neodriver_core.Errors.t) Stdlib.resultSend a DISCARD message, discarding up to n remaining records (all by default) of the result qid. A server failure is surfaced as Error _.
A lazily-streamed result on a connection: RUN is sent immediately, records are pulled in batches on demand. The terminal state is a summary (normal end) or an error (a server failure, surfaced after the buffered records are consumed).
val stream :
?on_complete:(Neodriver_packstream.Packstream.value -> unit) ->
t ->
hydration:Neodriver_core.Hydration.t ->
run_metadata:run_metadata ->
streamA fresh stream for the given connection, hydration scope and RUN metadata. on_complete fires with the final summary once the stream ends normally.
val buffered : stream -> Neodriver_core.Values.t list listThe records buffered so far, in order.
val has_more : stream -> boolWhether the stream still has records to pull.
val error : stream -> Neodriver_core.Errors.t optionA server failure that interrupted the stream.
val summary : stream -> Neodriver_packstream.Packstream.value optionThe final PULL summary metadata, once the stream has ended normally.
val run_metadata : stream -> run_metadataThe RUN metadata (field names, query id, timings, bookmark).
val pull_stream :
?n:int ->
stream ->
(Neodriver_core.Values.t list list, Neodriver_core.Errors.t) Stdlib.resultPull up to n more records (all by default), buffering them, and return the newly fetched records. A server failure mid-stream is stored on the stream (error) and the records delivered before it are kept. Once the stream ends normally, its summary is stored.
val server_agent : t -> string optionThe server agent string reported in the HELLO response, if any.
val capabilities : t -> Neodriver_core.Capabilities.tThe protocol capabilities of the connection's version.
The authentication token the connection is currently logged on with, if any.
val re_auth : t -> auth -> (bool, Neodriver_core.Errors.t) Stdlib.resultRe-authenticate when auth differs from the current token (LOGOFF then LOGON, Bolt >= 5.1). Returns whether the token changed (false when it is the same as the current one).
val mark_unauthenticated : t -> unitForget the current token (the next re_auth will log on again).