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

Database.Bolty.Connection.Pipe

Description

Internal module. Not part of the public API.

Synopsis

Documentation

connect :: (MonadIO m, HasCallStack) => ValidatedConfig -> m Connection Source #

Connect to a Neo4j server, perform the BOLT handshake and authentication.

close :: (MonadIO m, HasCallStack) => Connection -> m () Source #

Send GOODBYE (if supported) and close the connection.

reset :: (MonadIO m, HasCallStack) => Connection -> m () Source #

Send RESET and transition the connection back to the Ready state.

ping :: MonadIO m => Connection -> m Bool Source #

Check if a Pipe is alive by sending RESET and expecting SUCCESS. Returns True if healthy, False otherwise. Catches all exceptions.

flush :: MonadPipe m => Connection -> Request -> m () Source #

Send a request through a Connection.

fetch :: MonadPipe m => Connection -> m Response Source #

Receive the next response from a Connection.

sendRequest :: MonadPipe m => Connection -> Int -> Request -> m () Source #

Serialize and send a BOLT request as chunked data on the wire.

receiveResponse :: MonadPipe m => Connection -> Int -> m Response Source #

Receive and decode a chunked BOLT response from the wire.

requireState :: MonadPipe m => Connection -> [ServerState] -> Text -> m () Source #

Check that the connection is in one of the allowed states, or throw InvalidState

setState :: MonadIO m => Connection -> ServerState -> m () Source #

Update the server state

getState :: MonadIO m => Connection -> m ServerState Source #

Get the current server state

logon :: (MonadIO m, HasCallStack) => Connection -> Scheme -> m () Source #

Send LOGON with credentials, expect SUCCESS, transition to Ready state. Only valid on Bolt 5.1+ connections in Authentication state.

logoff :: (MonadIO m, HasCallStack) => Connection -> m () Source #

Send LOGOFF, expect SUCCESS, transition to Authentication state. Only valid on Bolt 5.1+ connections in Ready state.

sendTelemetry :: (MonadIO m, HasCallStack) => Connection -> TelemetryApi -> m () Source #

Send a TELEMETRY message if the server supports it. No-op if telemetry is not enabled or version < 5.4.

type MonadPipe (m :: Type -> Type) = (HasCallStack, MonadIO m, MonadError Error m) Source #

Constraint alias for monads that can perform BOLT pipe operations.

Connection accessors

connectionVersion :: Connection -> Word32 Source #

Get the negotiated BOLT protocol version.

connectionAgent :: Connection -> Text Source #

Get the server agent string.

connectionId :: Connection -> Text Source #

Get the server-assigned connection ID.

connectionTelemetryEnabled :: Connection -> Bool Source #

Check whether the server supports telemetry.

connectionServerIdleTimeout :: Connection -> Maybe Int Source #

Get the server-advertised idle timeout in seconds, if any.

touchConnection :: MonadIO m => Connection -> m () Source #

Update the connection's last-activity timestamp to now.

connectionLastActivity :: MonadIO m => Connection -> m Word64 Source #

Get the monotonic timestamp (in nanoseconds) of the last connection activity.

Transaction primitives (plain IO)

beginTx :: HasCallStack => Connection -> Begin -> IO () Source #

Begin an explicit transaction with bookmarks and access mode.

commitTx :: HasCallStack => Connection -> IO (Maybe Text) Source #

Commit the current transaction and return the bookmark (if any).

rollbackTx :: HasCallStack => Connection -> IO () Source #

Rollback the current transaction.

tryRollback :: Connection -> IO () Source #

Try to rollback the current transaction, ignoring errors. Used as cleanup in onException handlers.

Plain IO wire helpers

requireStateIO :: HasCallStack => Connection -> [ServerState] -> Text -> IO () Source #

Check the connection state, throw InvalidState if wrong.

flushIO :: HasCallStack => Connection -> Request -> IO () Source #

Send a request, throwing on wire error.

fetchIO :: HasCallStack => Connection -> IO Response Source #

Receive a response, throwing on wire error.