Skip to content

Commit 7c5ecdc

Browse files
committed
Fix regression with Khepri binding args
Fix #14533
1 parent 481e765 commit 7c5ecdc

File tree

1 file changed

+14
-20
lines changed

1 file changed

+14
-20
lines changed

deps/rabbit/src/rabbit_khepri.erl

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
%% executed. If the migration runs concurrently, whether it started before or
6161
%% during the execution of the Mnesia-specific anonymous function, {@link
6262
%% handle_fallback/1} will watch for "no exists" table exceptions from Mnesia
63-
%% and will retry the Mnesia functino or run the Khepri function accordingly.
63+
%% and will retry the Mnesia function or run the Khepri function accordingly.
6464
%% The Mnesia function must be idempotent because it can be executed multiple
6565
%% times.
6666
%%
@@ -1415,34 +1415,28 @@ register_rabbit_bindings_projection() ->
14151415
khepri:register_projection(?STORE_ID, PathPattern, Projection).
14161416

14171417
register_rabbit_index_route_projection() ->
1418-
MapFun = fun(Path, _) ->
1419-
{
1420-
VHost,
1421-
ExchangeName,
1422-
Kind,
1423-
DstName,
1424-
RoutingKey
1425-
} = rabbit_db_binding:khepri_route_path_to_args(Path),
1426-
Exchange = rabbit_misc:r(VHost, exchange, ExchangeName),
1427-
Destination = rabbit_misc:r(VHost, Kind, DstName),
1428-
SourceKey = {Exchange, RoutingKey},
1429-
#index_route{source_key = SourceKey,
1430-
destination = Destination}
1418+
MapFun = fun(_Path, #binding{source = Source,
1419+
key = Key,
1420+
destination = Destination,
1421+
args = Args}) ->
1422+
#index_route{source_key = {Source, Key},
1423+
destination = Destination,
1424+
args = Args}
14311425
end,
14321426
ProjectionFun = projection_fun_for_sets(MapFun),
14331427
Options = #{type => bag,
14341428
keypos => #index_route.source_key,
14351429
read_concurrency => true},
14361430
Projection = khepri_projection:new(
14371431
rabbit_khepri_index_route, ProjectionFun, Options),
1438-
DirectOrFanout = #if_data_matches{
1439-
pattern = #exchange{type = '$1', _ = '_'},
1440-
conditions = [{'andalso',
1441-
{'=/=', '$1', headers},
1442-
{'=/=', '$1', topic}}]},
1432+
IgnoreHeadersAndTopic = #if_data_matches{
1433+
pattern = #exchange{type = '$1', _ = '_'},
1434+
conditions = [{'andalso',
1435+
{'=/=', '$1', headers},
1436+
{'=/=', '$1', topic}}]},
14431437
PathPattern = rabbit_db_binding:khepri_route_path(
14441438
_VHost = ?KHEPRI_WILDCARD_STAR,
1445-
_Exchange = DirectOrFanout,
1439+
_Exchange = IgnoreHeadersAndTopic,
14461440
_Kind = ?KHEPRI_WILDCARD_STAR,
14471441
_DstName = ?KHEPRI_WILDCARD_STAR,
14481442
_RoutingKey = ?KHEPRI_WILDCARD_STAR),

0 commit comments

Comments
 (0)