You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: Provide API to stop listener programatically
This change introduces possibility to stop listener thread programatically. It is a prerequisite for HSpec tests starting the listener as they have to be able to stop it when cleaning up.
--| Starts a LISTEN connection and handles notifications. It recovers with exponential backoff with a cap of 32 seconds, if the LISTEN connection is lost.
36
-
-- | This function never returns (but can throw) and return type enforces that.
37
-
retryingListen::AppState->Bool->IOVoid
42
+
-- | This function returns upon receiving of ListenerStopped async exception.
43
+
retryingListen::AppState->Bool->IO()
38
44
retryingListen appState hasDbListenerBug =do
39
45
cfg@AppConfig{..} <-AppState.getConfig appState
40
46
let
41
47
dbChannel = toS configDbChannel
42
48
onError err =do
43
49
AppState.putIsListenerOn appState False
44
-
observer $DBListenFail dbChannel (Righterr)
50
+
observer $DBListenFail dbChannel err
45
51
when (isDbListenerBug err) $
46
52
observer DBListenBugCallQueryFix
47
53
unless configDbPoolAutomaticRecovery $
@@ -54,24 +60,24 @@ retryingListen appState hasDbListenerBug = do
pure$"Listener connected to "<> fullName <>" on "<>show (fold $ host <>fmap (":"<>) port) <>" and listening for database notifications on the "<>show channel <>" channel"
186
185
DBListenFail channel listenErr ->
187
186
pure$"Failed listening for database notifications on the "<>show channel <>" channel. "<>
188
-
either showListenerConnError showListenerException listenErr
187
+
showListenerException listenErr
189
188
DBListenRetry delay ->
190
189
pure$"Retrying listening for database notifications in "<> (show delay::Text) <>" seconds..."
0 commit comments