Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5-internal/efficient-queue-listing
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
List queues for backend notifications more efficiently.
2 changes: 1 addition & 1 deletion integration/test/Testlib/ResourcePool.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ deleteAllRabbitMQQueues rc resource = do
tls = Just $ RabbitMqTlsOpts Nothing True
}
client <- mkRabbitMqAdminClientEnv opts
queues <- listQueuesByVHost client (T.pack resource.berVHost)
queues <- listQueuesByVHost client (T.pack resource.berVHost) Nothing Nothing
for_ queues $ \queue ->
deleteQueue client (T.pack resource.berVHost) queue.name

Expand Down
2 changes: 2 additions & 0 deletions libs/extended/src/Network/RabbitMqAdmin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ data AdminAPI route = AdminAPI
:- "api"
:> "queues"
:> Capture "vhost" VHost
:> QueryParam "name" Text
:> QueryParam "use_regex" Bool
:> Get '[JSON] [Queue],
deleteQueue ::
route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ getRemoteDomains adminClient = do
go :: AppT IO [Domain]
go = do
vhost <- asks rabbitmqVHost
queues <- liftIO $ listQueuesByVHost adminClient vhost
queues <- liftIO $ listQueuesByVHost adminClient vhost (Just "backend-notifications\\..*") (Just True)
let notifQueuesSuffixes = mapMaybe (\q -> Text.stripPrefix "backend-notifications." q.name) queues
catMaybes <$> traverse (\d -> either (\e -> logInvalidDomain d e >> pure Nothing) (pure . Just) $ mkDomain d) notifQueuesSuffixes
logInvalidDomain d e =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ mockApi mockAdmin =
deleteQueue = mockListDeleteQueue mockAdmin
}

mockListQueuesByVHost :: MockRabbitMqAdmin -> Text -> Servant.Handler [Queue]
mockListQueuesByVHost MockRabbitMqAdmin {..} vhost = do
mockListQueuesByVHost :: MockRabbitMqAdmin -> Text -> Maybe Text -> Maybe Bool -> Servant.Handler [Queue]
mockListQueuesByVHost MockRabbitMqAdmin {..} vhost _ _ = do
atomically $ modifyTVar listQueuesVHostCalls (<> [vhost])
readTVarIO broken >>= \case
True -> throwError $ Servant.err500
Expand Down