| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Database.Bolty.Session
Description
Synopsis
- data BookmarkManager
- newBookmarkManager :: [Text] -> IO BookmarkManager
- getBookmarks :: BookmarkManager -> IO [Text]
- updateBookmark :: BookmarkManager -> Text -> IO ()
- data Session = Session {
- sPool :: !SessionPool
- sBookmarks :: !BookmarkManager
- sConfig :: !SessionConfig
- sRetry :: !RetryConfig
- sTelemetrySent :: !(IORef Bool)
- data SessionPool
- data SessionConfig = SessionConfig {
- database :: !(Maybe Text)
- accessMode :: !AccessMode
- sessionBookmarks :: ![Text]
- defaultSessionConfig :: SessionConfig
- createSession :: BoltPool -> SessionConfig -> IO Session
- createRoutingSession :: RoutingPool -> SessionConfig -> IO Session
- readTransaction :: HasCallStack => Session -> (Connection -> IO a) -> IO a
- writeTransaction :: HasCallStack => Session -> (Connection -> IO a) -> IO a
- getLastBookmarks :: Session -> IO [Text]
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
A session bundles a connection pool with bookmark management and configuration.
Sessions track bookmarks automatically across managed transactions
(readTransaction, writeTransaction) to ensure causal consistency.
Constructors
| Session | |
Fields
| |
data SessionPool Source #
Which pool type the session uses (internal).
Constructors
| DirectPool !BoltPool | |
| RoutedPool !RoutingPool |
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.