hipsql-server-0.0.0.0
Safe HaskellNone
LanguageHaskell2010

Hipsql.Server.Internal

Description

Internal module which implements starting a hipsql-server from Haskell code.

Synopsis

Disclaimer

Changes to this module will not be reflected in the library's version updates.

Internals

newtype Deps Source #

Dependencies required for starting a hipsql server.

Constructors

Deps 

Fields

newtype Config Source #

Configuration required for starting a hipsql server.

Constructors

Config 

Fields

data QueryResponse Source #

A successful response from issuing a query.

newtype QueryError Source #

An error response from issuing a query.

Constructors

QueryError ByteString 

newtype ServerState Source #

Runtime state of the hipsql server.

Constructors

ServerState 

data ServerEnv Source #

Runtime environment of the hipsql server.

Constructors

ServerEnv 

toHandler :: IO a -> Handler a Source #

Lifts the IO action to a servant Handler, ensuring exceptions are handled accordingly.

server :: ServerEnv -> Server HipsqlAPI Source #

Create a servant Server of the HipsqlAPI.

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.

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.

getDefaultConfig :: IO Config Source #

Gets the default Config used by the hipsql server.

getDefaultDeps :: IO Deps Source #

Gets the default Deps used by the hipsql server.