Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions postgres-websockets.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ library
, bytestring >= 0.11.5 && < 0.13
, either >= 5.0.1.1 && < 5.1
, envparse >= 0.5.0 && < 0.7
, hasql >= 1.7 && < 1.9
, hasql-notifications >= 0.2.3.0 && < 0.3
, hasql-pool ^>= 1.2
, hasql >= 1.9 && < 1.10
, hasql-notifications >= 0.2.4.0 && < 0.3
, hasql-pool ^>= 1.3
, http-types >= 0.12.3 && < 0.13
, jose >= 0.11 && < 0.12
, lens >= 5.2.3 && < 5.4
Expand Down Expand Up @@ -94,11 +94,11 @@ test-suite postgres-websockets-test
, postgres-websockets
, hspec >= 2.7.1 && < 2.12
, aeson >= 2.0 && < 2.3
, hasql >= 1.7 && < 1.9
, hasql-pool ^>= 1.2
, hasql-notifications >= 0.2.3.0 && < 0.3
, hasql >= 1.9 && < 1.10
, hasql-pool ^>= 1.3
, hasql-notifications >= 0.2.4.0 && < 0.3
, http-types >= 0.9
, time >= 1.8.0.2 && < 1.13
, time >= 1.8.0.2 && < 2
, unordered-containers >= 0.2
, wai-extra >= 3.0.29 && < 3.2
, stm >= 2.5.0.0 && < 2.6
Expand Down
4 changes: 3 additions & 1 deletion src/PostgresWebsockets/Context.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import Control.AutoUpdate
import Data.Time.Clock (UTCTime, getCurrentTime)
import qualified Hasql.Pool as P
import qualified Hasql.Pool.Config as P
import qualified Hasql.Connection.Setting as C
import qualified Hasql.Connection.Setting.Connection as C
import PostgresWebsockets.Broadcast (Multiplexer)
import PostgresWebsockets.Config (AppConfig (..))
import PostgresWebsockets.HasqlBroadcast (newHasqlBroadcaster)
Expand All @@ -35,7 +37,7 @@ mkContext conf@AppConfig {..} shutdownServer = do
<*> newHasqlBroadcaster shutdown configListenChannel configRetries configReconnectInterval pgSettings
<*> mkGetTime
where
config = P.settings [P.staticConnectionSettings pgSettings]
config = P.settings [P.staticConnectionSettings [C.connection $ C.string $ decodeUtf8 pgSettings]]
shutdown =
maybe
shutdownServer
Expand Down
7 changes: 6 additions & 1 deletion src/PostgresWebsockets/HasqlBroadcast.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ import Data.Aeson (Value (..), decode)
import qualified Data.Aeson.Key as Key
import qualified Data.Aeson.KeyMap as JSON
import Data.Either.Combinators (mapBoth)
import Hasql.Connection
import Hasql.Connection (Connection, ConnectionError)
import qualified Hasql.Connection as HC
import qualified Hasql.Connection.Setting as HC
import qualified Hasql.Connection.Setting.Connection as HC
import qualified Hasql.Decoders as HD
import qualified Hasql.Encoders as HE
import Hasql.Notifications
import qualified Hasql.Session as H
import qualified Hasql.Statement as H
import PostgresWebsockets.Broadcast

acquire :: ByteString -> IO (Either ConnectionError Connection)
acquire settings = HC.acquire [HC.connection $ HC.string $ decodeUtf8 settings]
-- | 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
newHasqlBroadcaster :: IO () -> Text -> Int -> Maybe Int -> ByteString -> IO Multiplexer
Expand Down