packages feed

mattermost-api 40800.0.1 → 40800.0.2

raw patch · 4 files changed

+24/−10 lines, 4 files

Files

CHANGELOG.md view
@@ -1,4 +1,10 @@ +40800.0.2+=========++ * The websocket connection now uses the V4 API endpoint.+ * submitRequest now also retries on "resource vanished" exceptions.+ 40800.0.1 ========= 
mattermost-api.cabal view
@@ -1,5 +1,5 @@ name:                mattermost-api-version:             40800.0.1+version:             40800.0.2 synopsis:            Client API for Mattermost chat system description:         Client API for Mattermost chat system license:             BSD3
src/Network/Mattermost/Connection.hs view
@@ -130,17 +130,17 @@                   return $ Right response    rawResponse <- do-      -- Try to submit the request. If we got an EOF exception, that-      -- means that the connection pool contained a connection that-      -- had been severed since it was last used. That means it's-      -- very likely that the pool has other stale connections in it,-      -- so we destroy all idle connections in the pool and try the-      -- request one more time. All other errors and exceptions are just-      -- propagated.+      -- Try to submit the request. If we got an exception that we think+      -- indicates a network problem, we assume that to mean that the+      -- connection pool contained a connection that had been severed+      -- since it was last used. That means it's very likely that the+      -- pool has other stale connections in it, so we destroy all idle+      -- connections in the pool and try the request one more time. All+      -- other errors and exceptions are just propagated.       resp :: Either IOException (Either HTTP.ConnError HTTP.Response_String)            <- try go       case resp of-          Left e | isEOFError e -> do+          Left e | isConnectionError e -> do               destroyAllResources (cdConnectionPool cd)               go           Left e -> throwIO e@@ -155,6 +155,14 @@           throwIO (err :: MattermostError)         Left _ ->           throwIO (HTTPResponseException ("Server returned unexpected " ++ show code ++ " response"))++isConnectionError :: IOException -> Bool+isConnectionError e =+    or [ isEOFError e+       -- There is not a specific predicate for "resource vanished"+       -- exceptions so "show" is as good as it gets.+       , "resource vanished" `List.isInfixOf` show e+       ]  shouldClose :: HTTP.Response_String -> Bool shouldClose r =
src/Network/Mattermost/WebSocket.hs view
@@ -133,7 +133,7 @@         body (MMWS c health) `catch` propagate [mId, pId]   WS.runClientWithStream stream                       (T.unpack $ cdHostname cd)-                      "/api/v3/users/websocket"+                      "/api/v4/websocket"                       WS.defaultConnectionOptions { WS.connectionOnPong = onPong }                       [ ("Authorization", "Bearer " <> B.pack tk) ]                       action