Skip to content

Commit 1ba08e7

Browse files
committed
Use IO instead of parameterised monad for running an action
- This is to work around the issue of an otherwise imposed constraint of `Typeable effs`
1 parent 651ca90 commit 1ba08e7

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

services/brig/src/Brig/Data/Client.hs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import Brig.Types.User.Auth (CookieLabel)
5353
import Brig.User.Auth.DB.Instances ()
5454
import Cassandra as C hiding (Client)
5555
import Control.Error
56+
import qualified Control.Exception.Lens as EL
5657
import Control.Lens
5758
import Control.Monad.Catch
5859
import Control.Monad.Random (randomRIO)
@@ -386,20 +387,20 @@ withOptLock u c ma = go (10 :: Int)
386387
cmd <- mkCmd <$> view (awsEnv . prekeyTable)
387388
e <- view (awsEnv . amazonkaEnv)
388389
m <- view metrics
389-
execDyn' e m cnv cmd
390+
liftIO $ execDyn' e m cnv cmd
390391
where
391392
execDyn' ::
392-
forall y p m.
393-
(AWS.AWSRequest p, MonadUnliftIO m, MonadMask m, MonadIO m) =>
393+
forall y p.
394+
AWS.AWSRequest p =>
394395
AWS.Env ->
395396
Metrics.Metrics ->
396397
(AWS.Rs p -> Maybe y) ->
397398
p ->
398-
m (Maybe y)
399+
IO (Maybe y)
399400
execDyn' e m conv cmd = recovering policy handlers (const run)
400401
where
401402
run = execCatch e cmd >>= either handleErr (return . conv)
402-
handlers = httpHandlers ++ [const $ Handler $ pure . const True . preview (AWS._ConditionalCheckFailedException @SomeException)]
403+
handlers = httpHandlers ++ [const $ EL.handler_ AWS._ConditionalCheckFailedException (pure True)]
403404
policy = limitRetries 3 <> exponentialBackoff 100000
404405
handleErr (AWS.ServiceError se) | se ^. AWS.serviceCode == AWS.ErrorCode "ProvisionedThroughputExceeded" = do
405406
Metrics.counterIncr (Metrics.path "client.opt_lock.provisioned_throughput_exceeded") m

0 commit comments

Comments
 (0)