Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.

Commit aa9057a

Browse files
committed
Use ETS operations that are available in Erlang 19.3
ets:select_replace/2 is only available in Erlang 20 and above. RabbitMQ 3.7 needs to support Erlang 19.3 and above. We haven't noticed any difference in performance when using one approach over the other. To keep the code simple, we decided to not detect which approach to use. Partern-in-crime: @essen
1 parent ea2a4f5 commit aa9057a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/rabbit_core_metrics.erl

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,28 +265,34 @@ delete_queue_metrics(Queue) ->
265265
ok.
266266

267267
delete_channel_queue_exchange_metrics(MatchSpecCondition) ->
268-
ets:select_replace(
268+
ChannelQueueExchangeMetricsToUpdate = ets:select(
269269
channel_queue_exchange_metrics,
270270
[
271271
{
272-
{{'$2', {'$1', '$3'}}, '$4', '_'},
272+
{{'$2', {'$1', '$3'}}, '_', '_'},
273273
[MatchSpecCondition],
274-
[{{{{'$2', {{'$1', '$3'}}}}, '$4', 1}}]
274+
[{{'$2', {{'$1', '$3'}}}}]
275275
}
276276
]
277-
).
277+
),
278+
lists:foreach(fun(Key) ->
279+
ets:update_element(channel_queue_exchange_metrics, Key, {3, 1})
280+
end, ChannelQueueExchangeMetricsToUpdate).
278281

279282
delete_channel_queue_metrics(MatchSpecCondition) ->
280-
ets:select_replace(
283+
ChannelQueueMetricsToUpdate = ets:select(
281284
channel_queue_metrics,
282285
[
283286
{
284-
{{'$2', '$1'}, '$3', '$4', '$5', '$6', '$7', '$8', '_'},
287+
{{'$2', '$1'}, '_', '_', '_', '_', '_', '_', '_'},
285288
[MatchSpecCondition],
286-
[{{{{'$2', '$1'}}, '$3', '$4', '$5', '$6', '$7', '$8', 1}}]
289+
[{{'$2', '$1'}}]
287290
}
288291
]
289-
).
292+
),
293+
lists:foreach(fun(Key) ->
294+
ets:update_element(channel_queue_metrics, Key, {8, 1})
295+
end, ChannelQueueMetricsToUpdate).
290296

291297
% [{'orelse',
292298
% {'==', {Queue}, '$1'},

0 commit comments

Comments
 (0)