bolty-0.1.0.2: Haskell driver for Neo4j (BOLT protocol 4.4-5.4)
Safe HaskellNone
LanguageGHC2021

Database.Bolty.Session

Description

 
Synopsis

Bookmark management

data BookmarkManager Source #

Mutable bookmark holder for causal consistency across transactions. Within a session, each committed transaction produces a bookmark that supersedes all previous bookmarks. The manager tracks the latest bookmark(s) so they can be passed to the next transaction's BEGIN.

newBookmarkManager :: [Text] -> IO BookmarkManager Source #

Create a bookmark manager with optional initial bookmarks.

getBookmarks :: BookmarkManager -> IO [Text] Source #

Get the current bookmarks.

updateBookmark :: BookmarkManager -> Text -> IO () Source #

Replace the current bookmarks with the new one from a COMMIT response.

Session

data Session Source #

A session bundles a connection pool with bookmark management and configuration. Sessions track bookmarks automatically across managed transactions (readTransaction, writeTransaction) to ensure causal consistency.

data SessionPool Source #

Which pool type the session uses (internal).

data SessionConfig Source #

Session configuration.

Constructors

SessionConfig 

Fields

defaultSessionConfig :: SessionConfig Source #

Default session configuration: default database, write access, no initial bookmarks.

createSession :: BoltPool -> SessionConfig -> IO Session Source #

Create a session using a direct (non-routing) connection pool.

createRoutingSession :: RoutingPool -> SessionConfig -> IO Session Source #

Create a session using a routing-aware connection pool.

Managed transactions

readTransaction :: HasCallStack => Session -> (Connection -> IO a) -> IO a Source #

Run a read transaction. Uses ReadAccess for routing (directs to read replicas in a cluster). Automatically handles BEGIN, COMMIT, ROLLBACK, bookmark propagation, and retries on transient failures.

writeTransaction :: HasCallStack => Session -> (Connection -> IO a) -> IO a Source #

Run a write transaction. Uses WriteAccess for routing (directs to the leader in a cluster). Automatically handles BEGIN, COMMIT, ROLLBACK, bookmark propagation, and retries on transient failures.

Querying

getLastBookmarks :: Session -> IO [Text] Source #

Get the last bookmarks from the session. Pass these to a new session's SessionConfig to ensure the new session sees all committed writes.