@@ -46,7 +46,7 @@ match(#resource{virtual_host = VHost, name = XName} = X, RoutingKey, Opts) ->
4646 []
4747 end ;
4848 _ ->
49- trie_match_in_khepri (X , Words , BKeys )
49+ trie_match_v3 (X , Words , BKeys )
5050 end .
5151
5252-spec split_topic_key_binary (RoutingKey ) -> Words when
@@ -170,69 +170,49 @@ format_dest_bkeys([{#resource{kind = queue} = Dest, BKey} | Rest], Acc) ->
170170format_dest_bkeys ([{Dest , _BKey } | Rest ], Acc ) ->
171171 format_dest_bkeys (Rest , [Dest | Acc ]).
172172
173- % % --------------------------------------------------------------
174- % % Internal
175- % % --------------------------------------------------------------
176-
177- -spec add_matched ([rabbit_types :binding_destination () |
178- {rabbit_types :binding_destination (), BindingArgs :: list ()}],
179- ReturnBindingKeys :: boolean (),
180- match_result ()) ->
181- match_result ().
182- add_matched (Destinations , false , Acc ) ->
183- Destinations ++ Acc ;
184- add_matched (DestinationsArgs , true , Acc ) ->
185- lists :foldl (
186- fun ({DestQ = # resource {kind = queue }, BindingArgs }, L ) ->
187- case rabbit_misc :table_lookup (BindingArgs , <<" x-binding-key" >>) of
188- {longstr , BKey } ->
189- [{DestQ , BKey } | L ];
190- _ ->
191- [DestQ | L ]
192- end ;
193- ({DestX , _BindingArgs }, L ) ->
194- [DestX | L ]
195- end , Acc , DestinationsArgs ).
196-
197- % % Khepri topic graph
173+ % % ==============================================================
174+ % % Old v3 Khepri topic graph.
175+ % % Delete these *_v3 functions when feature flag
176+ % % topic_binding_projection_v4 becomes required.
177+ % % ==============================================================
198178
199- trie_match_in_khepri (X , Words , BKeys ) ->
179+ trie_match_v3 (X , Words , BKeys ) ->
200180 try
201- trie_match_in_khepri (X , root , Words , BKeys , [])
181+ trie_match_v3 (X , root , Words , BKeys , [])
202182 catch
203183 error :badarg ->
204184 []
205185 end .
206186
207- trie_match_in_khepri (X , Node , [], BKeys , ResAcc0 ) ->
208- Destinations = trie_bindings_in_khepri (X , Node , BKeys ),
209- ResAcc = add_matched (Destinations , BKeys , ResAcc0 ),
210- trie_match_part_in_khepri (
187+ trie_match_v3 (X , Node , [], BKeys , ResAcc0 ) ->
188+ Destinations = trie_bindings_v3 (X , Node , BKeys ),
189+ ResAcc = add_matched_v3 (Destinations , BKeys , ResAcc0 ),
190+ trie_match_part_v3 (
211191 X , Node , <<" #" >>,
212- fun trie_match_skip_any_in_khepri /5 , [], BKeys , ResAcc );
213- trie_match_in_khepri (X , Node , [W | RestW ] = Words , BKeys , ResAcc ) ->
192+ fun trie_match_skip_any_v3 /5 , [], BKeys , ResAcc );
193+ trie_match_v3 (X , Node , [W | RestW ] = Words , BKeys , ResAcc ) ->
214194 lists :foldl (fun ({WArg , MatchFun , RestWArg }, Acc ) ->
215- trie_match_part_in_khepri (
195+ trie_match_part_v3 (
216196 X , Node , WArg , MatchFun , RestWArg , BKeys , Acc )
217- end , ResAcc , [{W , fun trie_match_in_khepri /5 , RestW },
218- {<<" *" >>, fun trie_match_in_khepri /5 , RestW },
197+ end , ResAcc , [{W , fun trie_match_v3 /5 , RestW },
198+ {<<" *" >>, fun trie_match_v3 /5 , RestW },
219199 {<<" #" >>,
220- fun trie_match_skip_any_in_khepri /5 , Words }]).
200+ fun trie_match_skip_any_v3 /5 , Words }]).
221201
222- trie_match_part_in_khepri (X , Node , Search , MatchFun , RestW , BKeys , ResAcc ) ->
223- case trie_child_in_khepri (X , Node , Search ) of
202+ trie_match_part_v3 (X , Node , Search , MatchFun , RestW , BKeys , ResAcc ) ->
203+ case trie_child_v3 (X , Node , Search ) of
224204 {ok , NextNode } -> MatchFun (X , NextNode , RestW , BKeys , ResAcc );
225205 error -> ResAcc
226206 end .
227207
228- trie_match_skip_any_in_khepri (X , Node , [], BKeys , ResAcc ) ->
229- trie_match_in_khepri (X , Node , [], BKeys , ResAcc );
230- trie_match_skip_any_in_khepri (X , Node , [_ | RestW ] = Words , BKeys , ResAcc ) ->
231- trie_match_skip_any_in_khepri (
208+ trie_match_skip_any_v3 (X , Node , [], BKeys , ResAcc ) ->
209+ trie_match_v3 (X , Node , [], BKeys , ResAcc );
210+ trie_match_skip_any_v3 (X , Node , [_ | RestW ] = Words , BKeys , ResAcc ) ->
211+ trie_match_skip_any_v3 (
232212 X , Node , RestW , BKeys ,
233- trie_match_in_khepri (X , Node , Words , BKeys , ResAcc )).
213+ trie_match_v3 (X , Node , Words , BKeys , ResAcc )).
234214
235- trie_child_in_khepri (X , Node , Word ) ->
215+ trie_child_v3 (X , Node , Word ) ->
236216 case ets :lookup (
237217 ? KHEPRI_PROJECTION_V3 ,
238218 # trie_edge {exchange_name = X ,
@@ -242,7 +222,7 @@ trie_child_in_khepri(X, Node, Word) ->
242222 [] -> error
243223 end .
244224
245- trie_bindings_in_khepri (X , Node , BKeys ) ->
225+ trie_bindings_v3 (X , Node , BKeys ) ->
246226 case ets :lookup (
247227 ? KHEPRI_PROJECTION_V3 ,
248228 # trie_edge {exchange_name = X ,
@@ -259,3 +239,18 @@ trie_bindings_in_khepri(X, Node, BKeys) ->
259239 [] ->
260240 []
261241 end .
242+
243+ add_matched_v3 (Destinations , false , Acc ) ->
244+ Destinations ++ Acc ;
245+ add_matched_v3 (DestinationsArgs , true , Acc ) ->
246+ lists :foldl (
247+ fun ({DestQ = # resource {kind = queue }, BindingArgs }, L ) ->
248+ case rabbit_misc :table_lookup (BindingArgs , <<" x-binding-key" >>) of
249+ {longstr , BKey } ->
250+ [{DestQ , BKey } | L ];
251+ _ ->
252+ [DestQ | L ]
253+ end ;
254+ ({DestX , _BindingArgs }, L ) ->
255+ [DestX | L ]
256+ end , Acc , DestinationsArgs ).
0 commit comments