postgres-websockets-0.4.2.1: Middleware to map LISTEN/NOTIFY messages to Websockets

Safe HaskellNone
LanguageHaskell2010

PostgresWebsockets.Database

Description

This module encapsulates knowledge about the SQL commands and the Hasql interface.

Synopsis

Documentation

notifyPool :: Pool -> ByteString -> ByteString -> IO (Either Error ()) Source #

Given a Hasql Pool, a channel and a message sends a notify command to the database

notify :: Connection -> PgIdentifier -> ByteString -> IO (Either Error ()) Source #

Given a Hasql Connection, a channel and a message sends a notify command to the database

listen :: Connection -> PgIdentifier -> IO () Source #

Given a Hasql Connection and a channel sends a listen command to the database

unlisten :: Connection -> PgIdentifier -> IO () Source #

Given a Hasql Connection and a channel sends a unlisten command to the database

waitForNotifications :: (ByteString -> ByteString -> IO ()) -> Connection -> IO () Source #

Given a function that handles notifications and a Hasql connection forks a thread that listens on the database connection and calls the handler everytime a message arrives.

The message handler passed as first argument needs two parameters channel and payload.

data PgIdentifier Source #

A wrapped bytestring that represents a properly escaped and quoted PostgreSQL identifier

toPgIdentifier :: ByteString -> PgIdentifier Source #

Given a bytestring returns a properly quoted and escaped PgIdentifier