Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Uses Broadcast module adding database as a source producer.
This module provides a function to produce a Multiplexer
from a Hasql Connection
.
The producer issues a LISTEN command upon Open commands and UNLISTEN upon Close.
Synopsis
- newHasqlBroadcaster :: IO () -> Text -> Int -> Maybe Int -> ByteString -> IO Multiplexer
- newHasqlBroadcasterOrError :: IO () -> Text -> ByteString -> IO (Either ByteString Multiplexer)
- acquire :: Settings -> IO (Either ConnectionError Connection)
- relayMessages :: Multiplexer -> IO ()
- relayMessagesForever :: Multiplexer -> IO ThreadId
Documentation
newHasqlBroadcaster :: IO () -> Text -> Int -> Maybe Int -> ByteString -> IO Multiplexer Source #
Returns a multiplexer from a connection URI, keeps trying to connect in case there is any error. This function also spawns a thread that keeps relaying the messages from the database to the multiplexer's listeners
newHasqlBroadcasterOrError :: IO () -> Text -> ByteString -> IO (Either ByteString Multiplexer) Source #
Returns a multiplexer from a connection URI or an error message on the left case This function also spawns a thread that keeps relaying the messages from the database to the multiplexer's listeners
acquire :: Settings -> IO (Either ConnectionError Connection) #
Acquire a connection using the provided settings encoded according to the PostgreSQL format.
relayMessages :: Multiplexer -> IO () Source #
Reads the messages from the producer and relays them to the active listeners in their respective channels.
relayMessagesForever :: Multiplexer -> IO ThreadId Source #
Opens a thread that relays messages from the producer thread to the channels forever