Skip to content

Commit 25918f4

Browse files
committed
Support for hasql-1.9
1 parent 581f341 commit 25918f4

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

postgres-websockets.cabal

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ library
4444
, bytestring >= 0.11.5 && < 0.13
4545
, either >= 5.0.1.1 && < 5.1
4646
, envparse >= 0.5.0 && < 0.7
47-
, hasql >= 1.7 && < 1.9
48-
, hasql-notifications >= 0.2.3.0 && < 0.3
49-
, hasql-pool ^>= 1.2
47+
, hasql >= 1.9 && < 1.10
48+
, hasql-notifications >= 0.2.4.0 && < 0.3
49+
, hasql-pool ^>= 1.3
5050
, http-types >= 0.12.3 && < 0.13
5151
, jose >= 0.11 && < 0.12
5252
, lens >= 5.2.3 && < 5.4
@@ -94,9 +94,9 @@ test-suite postgres-websockets-test
9494
, postgres-websockets
9595
, hspec >= 2.7.1 && < 2.12
9696
, aeson >= 2.0 && < 2.3
97-
, hasql >= 1.7 && < 1.9
98-
, hasql-pool ^>= 1.2
99-
, hasql-notifications >= 0.2.3.0 && < 0.3
97+
, hasql >= 1.9 && < 1.10
98+
, hasql-pool ^>= 1.3
99+
, hasql-notifications >= 0.2.4.0 && < 0.3
100100
, http-types >= 0.9
101101
, time >= 1.8.0.2 && < 1.13
102102
, unordered-containers >= 0.2

src/PostgresWebsockets/Context.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import Control.AutoUpdate
1616
import Data.Time.Clock (UTCTime, getCurrentTime)
1717
import qualified Hasql.Pool as P
1818
import qualified Hasql.Pool.Config as P
19+
import qualified Hasql.Connection.Setting as C
20+
import qualified Hasql.Connection.Setting.Connection as C
1921
import PostgresWebsockets.Broadcast (Multiplexer)
2022
import PostgresWebsockets.Config (AppConfig (..))
2123
import PostgresWebsockets.HasqlBroadcast (newHasqlBroadcaster)
@@ -35,7 +37,7 @@ mkContext conf@AppConfig {..} shutdownServer = do
3537
<*> newHasqlBroadcaster shutdown configListenChannel configRetries configReconnectInterval pgSettings
3638
<*> mkGetTime
3739
where
38-
config = P.settings [P.staticConnectionSettings pgSettings]
40+
config = P.settings [P.staticConnectionSettings [C.connection $ C.string $ decodeUtf8 pgSettings]]
3941
shutdown =
4042
maybe
4143
shutdownServer

src/PostgresWebsockets/HasqlBroadcast.hs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,19 @@ import Data.Aeson (Value (..), decode)
2121
import qualified Data.Aeson.Key as Key
2222
import qualified Data.Aeson.KeyMap as JSON
2323
import Data.Either.Combinators (mapBoth)
24-
import Hasql.Connection
24+
import Hasql.Connection (Connection, ConnectionError)
25+
import qualified Hasql.Connection as HC
26+
import qualified Hasql.Connection.Setting as HC
27+
import qualified Hasql.Connection.Setting.Connection as HC
2528
import qualified Hasql.Decoders as HD
2629
import qualified Hasql.Encoders as HE
2730
import Hasql.Notifications
2831
import qualified Hasql.Session as H
2932
import qualified Hasql.Statement as H
3033
import PostgresWebsockets.Broadcast
3134

35+
acquire :: ByteString -> IO (Either ConnectionError Connection)
36+
acquire settings = HC.acquire [HC.connection $ HC.string $ decodeUtf8 settings]
3237
-- | Returns a multiplexer from a connection URI, keeps trying to connect in case there is any error.
3338
-- This function also spawns a thread that keeps relaying the messages from the database to the multiplexer's listeners
3439
newHasqlBroadcaster :: IO () -> Text -> Int -> Maybe Int -> ByteString -> IO Multiplexer

0 commit comments

Comments
 (0)