Skip to content

Commit

Permalink
gundeck: Try not to kill brig
Browse files Browse the repository at this point in the history
  • Loading branch information
akshaymankar committed Oct 9, 2024
1 parent 46f29ac commit 9c4421e
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions services/gundeck/src/Gundeck/Push.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import Network.HTTP.Types
import Network.Wai.Utilities
import System.Logger.Class (msg, val, (+++), (.=), (~~))
import System.Logger.Class qualified as Log
import UnliftIO (pooledMapConcurrentlyN)
import Util.Options
import Wire.API.Internal.Notification
import Wire.API.Notification (userNotificationExchangeName)
Expand Down Expand Up @@ -273,17 +274,20 @@ splitPush clientsFull p = do

getClients :: Set UserId -> Gundeck UserClientsFull
getClients uids = do
r <- do
Endpoint h p <- view $ options . brig
Bilge.post
( Bilge.host (toByteString' h)
. Bilge.port p
. Bilge.path "/i/clients/full"
. Bilge.json (UserSet uids)
)
when (Bilge.statusCode r /= 200) $ do
error "something went wrong"
Bilge.responseJsonError r
fmap mconcat . pooledMapConcurrentlyN 4 getBatch $ List.chunksOf 100 $ Set.toList uids
where
getBatch :: [UserId] -> Gundeck UserClientsFull
getBatch uidsChunk = do
r <- do
Endpoint h p <- view $ options . brig
Bilge.post
( Bilge.host (toByteString' h)
. Bilge.port p
. Bilge.path "/i/clients/full"
. Bilge.json (UserSet $ Set.fromList uidsChunk)
. Bilge.expect2xx
)
Bilge.responseJsonError r

-- TODO: Delete this comment
-- Old way:
Expand Down

0 comments on commit 9c4421e

Please sign in to comment.