@@ -332,12 +332,7 @@ init(IsVirgin) ->
332332 " local Khepri-based " ? RA_FRIENDLY_NAME " member is caught "
333333 " up to the Raft cluster leader" , [],
334334 #{domain => ? RMQLOG_DOMAIN_DB }),
335- ok ?= case IsVirgin of
336- true ->
337- register_projections ();
338- false ->
339- register_4_2_0_projections ()
340- end ,
335+ ok ?= register_projections (),
341336 % % Delete transient queues on init.
342337 % % Note that we also do this in the
343338 % % `rabbit_amqqueue:on_node_down/1' callback. We must try this
@@ -1324,31 +1319,23 @@ register_projections() ->
13241319 fun register_rabbit_route_by_source_key_projection /0 ,
13251320 fun register_rabbit_route_by_source_projection /0 ,
13261321 fun register_rabbit_topic_graph_projection /0 ],
1327- rabbit_misc :for_each_while_ok (fun register_projection /1 , RegFuns ).
1328-
1329- % % This function registers projections introduced in 4.2.0. In a mixed version
1330- % % cluster, these new projections will appear but won't be used on older nodes.
1331- % % This function can be deleted after feature flag rabbitmq_4.2.0 becomes required.
1332- register_4_2_0_projections () ->
1333- RegFuns = [fun register_rabbit_route_by_source_key_projection /0 ,
1334- fun register_rabbit_route_by_source_projection /0 ],
1335- rabbit_misc :for_each_while_ok (fun register_projection /1 , RegFuns ).
1336-
1337- register_projection (RegisterFun ) ->
1338- case RegisterFun () of
1339- ok ->
1340- ok ;
1341- % % Before Khepri v0.13.0, `khepri:register_projection/1,2,3`
1342- % % would return `{error, exists}` for projections which
1343- % % already exist.
1344- {error , exists } ->
1345- ok ;
1346- % % In v0.13.0+, Khepri returns a `?khepri_error(..)` instead.
1347- {error , {khepri , projection_already_exists , _Info }} ->
1348- ok ;
1349- {error , _ } = Error ->
1350- Error
1351- end .
1322+ rabbit_misc :for_each_while_ok (
1323+ fun (RegisterFun ) ->
1324+ case RegisterFun () of
1325+ ok ->
1326+ ok ;
1327+ % % Before Khepri v0.13.0, `khepri:register_projection/1,2,3`
1328+ % % would return `{error, exists}` for projections which
1329+ % % already exist.
1330+ {error , exists } ->
1331+ ok ;
1332+ % % In v0.13.0+, Khepri returns a `?khepri_error(..)` instead.
1333+ {error , {khepri , projection_already_exists , _Info }} ->
1334+ ok ;
1335+ {error , _ } = Error ->
1336+ Error
1337+ end
1338+ end , RegFuns ).
13521339
13531340register_rabbit_exchange_projection () ->
13541341 Name = rabbit_khepri_exchange ,
0 commit comments