| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Database.Bolty.Routing
Description
Cluster-aware routing: automatic server discovery and failover for Neo4j causal clusters.
Synopsis
- getRoutingTable :: HasCallStack => Connection -> Maybe Text -> IO RoutingTable
- data RoutingTable = RoutingTable {}
- data AccessMode
- data RoutingPool = RoutingPool {
- rpConfig :: !ValidatedConfig
- rpPoolConfig :: !PoolConfig
- rpRoutingDb :: !(Maybe Text)
- rpRefreshBuf :: !Int
- rpCacheRef :: !(IORef (Maybe CachedRoutingTable))
- rpPoolsRef :: !(IORef (HashMap Text BoltPool))
- rpRefreshLock :: !(MVar ())
- rpCounter :: !(IORef Int)
- data RoutingPoolConfig = RoutingPoolConfig {}
- defaultRoutingPoolConfig :: RoutingPoolConfig
- createRoutingPool :: ValidatedConfig -> RoutingPoolConfig -> IO RoutingPool
- destroyRoutingPool :: RoutingPool -> IO ()
- withRoutingConnection :: HasCallStack => RoutingPool -> AccessMode -> (Connection -> IO a) -> IO a
- acquireRoutingConnection :: HasCallStack => RoutingPool -> AccessMode -> IO CheckedOutConnection
- withRoutingTransaction :: HasCallStack => RoutingPool -> AccessMode -> (Connection -> IO a) -> IO a
- invalidateRoutingTable :: RoutingPool -> IO ()
- parseAddress :: Text -> (Text, Word16)
Routing table
getRoutingTable :: HasCallStack => Connection -> Maybe Text -> IO RoutingTable Source #
Fetch a routing table from the server. The connection must be in Ready state.
data RoutingTable Source #
A parsed routing table returned by the ROUTE message.
Constructors
| RoutingTable | |
Instances
| Show RoutingTable Source # | |
Defined in Database.Bolty.Message.Response Methods showsPrec :: Int -> RoutingTable -> ShowS # show :: RoutingTable -> String # showList :: [RoutingTable] -> ShowS # | |
| Eq RoutingTable Source # | |
Defined in Database.Bolty.Message.Response | |
Access mode
data AccessMode Source #
Access mode for routing: determines whether to use reader or writer servers.
Constructors
| ReadAccess | |
| WriteAccess |
Instances
| Show AccessMode Source # | |
Defined in Database.Bolty.Routing Methods showsPrec :: Int -> AccessMode -> ShowS # show :: AccessMode -> String # showList :: [AccessMode] -> ShowS # | |
| Eq AccessMode Source # | |
Defined in Database.Bolty.Routing | |
Routing pool
data RoutingPool Source #
A routing-aware connection pool that directs connections based on access mode.
Constructors
| RoutingPool | |
Fields
| |
data RoutingPoolConfig Source #
Configuration for a routing-aware connection pool.
Constructors
| RoutingPoolConfig | |
Fields
| |
defaultRoutingPoolConfig :: RoutingPoolConfig Source #
Default routing pool configuration.
createRoutingPool :: ValidatedConfig -> RoutingPoolConfig -> IO RoutingPool Source #
Create a routing-aware connection pool. Connects to the seed address, fetches the initial routing table, and sets up per-address pools.
destroyRoutingPool :: RoutingPool -> IO () Source #
Destroy all per-address pools in the routing pool.
withRoutingConnection :: HasCallStack => RoutingPool -> AccessMode -> (Connection -> IO a) -> IO a Source #
Acquire a connection routed by access mode, run an action, then release. On connection failure, tries the next address in round-robin order until all addresses are exhausted.
acquireRoutingConnection :: HasCallStack => RoutingPool -> AccessMode -> IO CheckedOutConnection Source #
Acquire a routed connection by access mode. Returns a
CheckedOutConnection that must be released by the caller.
Tries addresses in round-robin order, failing over on unavailable servers.
withRoutingTransaction :: HasCallStack => RoutingPool -> AccessMode -> (Connection -> IO a) -> IO a Source #
Run a retrying transaction routed by access mode. Re-acquires routing table and connection on each retry attempt, so that routing errors (NotALeader) and transient errors trigger fresh routing.
invalidateRoutingTable :: RoutingPool -> IO () Source #
Invalidate the cached routing table, forcing a refresh on the next operation. Use this when a routing error (e.g. NotALeader) indicates the table is stale.