Safe Haskell | None |
---|---|
Language | Haskell2010 |
Internal module which implements starting a hipsql-server
from Haskell code.
Synopsis
- newtype Deps = Deps {}
- newtype Config = Config {}
- data QueryResponse = QueryResponse {
- columnNames :: [Maybe ByteString]
- resultRows :: [[Maybe ByteString]]
- newtype QueryError = QueryError ByteString
- newtype ServerState = ServerState {}
- data ServerEnv = ServerEnv {
- conn :: Connection
- killswitch :: MVar ()
- state :: IORef ServerState
- newServerEnv :: Connection -> IO ServerEnv
- toHandler :: IO a -> Handler a
- server :: ServerEnv -> Server HipsqlAPI
- renderQueryResult :: ServerEnv -> QueryResponse -> IO ByteString
- renderXTable :: [ByteString] -> [[ByteString]] -> ByteString
- renderTable :: Maybe [ByteString] -> [[ByteString]] -> ByteString
- safeInit :: [a] -> [a]
- rawQuery :: ServerEnv -> ByteString -> IO QueryResponse
- mkQueryResponse :: Result -> IO QueryResponse
- helpMessage :: ByteString
- application :: ServerEnv -> Application
- startHipsql :: Maybe SrcLoc -> Connection -> IO ()
- startHipsql' :: Maybe SrcLoc -> Config -> Deps -> Connection -> IO ()
- startHipsqlWith :: Maybe SrcLoc -> ((Connection -> IO ()) -> IO ()) -> IO ()
- startHipsqlWith' :: Maybe SrcLoc -> Config -> Deps -> ((Connection -> IO ()) -> IO ()) -> IO ()
- getDefaultConfig :: IO Config
- getDefaultDeps :: IO Deps
Disclaimer
Changes to this module will not be reflected in the library's version updates.
Internals
Dependencies required for starting a hipsql
server.
data QueryResponse Source #
A successful response from issuing a query.
QueryResponse | |
|
newtype QueryError Source #
An error response from issuing a query.
Instances
Show QueryError Source # | |
Defined in Hipsql.Server.Internal showsPrec :: Int -> QueryError -> ShowS # show :: QueryError -> String # showList :: [QueryError] -> ShowS # | |
Exception QueryError Source # | |
Defined in Hipsql.Server.Internal toException :: QueryError -> SomeException # fromException :: SomeException -> Maybe QueryError # displayException :: QueryError -> String # |
Runtime environment of the hipsql
server.
ServerEnv | |
|
newServerEnv :: Connection -> IO ServerEnv Source #
Create an initial ServerEnv
.
renderQueryResult :: ServerEnv -> QueryResponse -> IO ByteString Source #
Render a QueryResponse
received from issuing a query as human
readable. Respects the current extendedDisplay
state.
renderXTable :: [ByteString] -> [[ByteString]] -> ByteString Source #
Special case of renderTable
which renders the supplied header
and values via extendedDisplay
.
renderTable :: Maybe [ByteString] -> [[ByteString]] -> ByteString Source #
Render the supplied optional header and values as a table for printing in the console. Attempts to match closely to real psql output.
safeInit :: [a] -> [a] Source #
Same as init
except returns an empty list if the supplied list is empty.
rawQuery :: ServerEnv -> ByteString -> IO QueryResponse Source #
Execute the supplied query and return its response.
mkQueryResponse :: Result -> IO QueryResponse Source #
Construct a QueryResponse
from a Result
.
NOTE: This is dangerous as it does not validate that an
error did not occur. Prefer rawQuery
instead.
helpMessage :: ByteString Source #
Help message displayed when the user gives the ?
command.
application :: ServerEnv -> Application Source #
A servant
Application
of the HipsqlAPI
.
startHipsql :: Maybe SrcLoc -> Connection -> IO () Source #
Start a hipsql
session with the given Connection
.
startHipsql' :: Maybe SrcLoc -> Config -> Deps -> Connection -> IO () Source #
Same as startHipsql
but allows you to specify the Config
and Deps
directly.
startHipsqlWith :: Maybe SrcLoc -> ((Connection -> IO ()) -> IO ()) -> IO () Source #
Same as startHipsql
except uses a Connection
acquiring function.
Useful when integrating with libraries like postgresql-simple
which
give you exclusive access to the Connection
via such a function.
startHipsqlWith' :: Maybe SrcLoc -> Config -> Deps -> ((Connection -> IO ()) -> IO ()) -> IO () Source #
Same as startHipsqlWith
but allows you to specify the Config
and Deps
directly.