|
11 | 11 |
|
12 | 12 | -export([recover/0, recover/2, exists/1, add/2, add/3, remove/1, remove/2, remove/3, remove/4]). |
13 | 13 | -export([list/1, list_for_source/1, list_for_destination/1, |
14 | | - list_for_source_and_destination/2, list_explicit/0, |
15 | | - list_between/2, has_any_between/2]). |
| 14 | + list_for_source_and_destination/2, list_for_source_and_destination/3, |
| 15 | + list_explicit/0, list_between/2, has_any_between/2]). |
16 | 16 | -export([new_deletions/0, combine_deletions/2, add_deletion/3, |
17 | 17 | process_deletions/2, binding_action/3]). |
18 | 18 | -export([info_keys/0, info/1, info/2, info_all/1, info_all/2, info_all/4]). |
@@ -253,26 +253,18 @@ list(VHostPath) -> |
253 | 253 | list_for_source(?DEFAULT_EXCHANGE(VHostPath)) -> |
254 | 254 | implicit_bindings(VHostPath); |
255 | 255 | list_for_source(SrcName) -> |
256 | | - mnesia:async_dirty( |
257 | | - fun() -> |
258 | | - Route = #route{binding = #binding{source = SrcName, _ = '_'}}, |
259 | | - [B || #route{binding = B} |
260 | | - <- mnesia:match_object(rabbit_route, Route, read)] |
261 | | - end). |
| 256 | + Route = #route{binding = #binding{source = SrcName, _ = '_'}}, |
| 257 | + Fun = list_for_route(Route, false), |
| 258 | + mnesia:async_dirty(Fun). |
262 | 259 |
|
263 | 260 | -spec list_for_destination |
264 | 261 | (rabbit_types:binding_destination()) -> bindings(). |
265 | 262 |
|
266 | 263 | list_for_destination(DstName = #resource{}) -> |
267 | | - ExplicitBindings = mnesia:async_dirty( |
268 | | - fun() -> |
269 | | - Route = #route{binding = #binding{destination = DstName, |
270 | | - _ = '_'}}, |
271 | | - [reverse_binding(B) || |
272 | | - #reverse_route{reverse_binding = B} <- |
273 | | - mnesia:match_object(rabbit_reverse_route, |
274 | | - reverse_route(Route), read)] |
275 | | - end), |
| 264 | + Route = #route{binding = #binding{destination = DstName, |
| 265 | + _ = '_'}}, |
| 266 | + Fun = list_for_route(Route, true), |
| 267 | + ExplicitBindings = mnesia:async_dirty(Fun), |
276 | 268 | implicit_for_destination(DstName) ++ ExplicitBindings. |
277 | 269 |
|
278 | 270 | -spec list_between( |
@@ -316,27 +308,40 @@ implicit_for_destination(DstQueue = #resource{kind = queue, |
316 | 308 | implicit_for_destination(_) -> |
317 | 309 | []. |
318 | 310 |
|
319 | | --spec list_for_source_and_destination |
320 | | - (rabbit_types:binding_source(), rabbit_types:binding_destination()) -> |
321 | | - bindings(). |
| 311 | +-spec list_for_source_and_destination(rabbit_types:binding_source(), rabbit_types:binding_destination()) -> |
| 312 | + bindings(). |
| 313 | +list_for_source_and_destination(SrcName, DstName) -> |
| 314 | + list_for_source_and_destination(SrcName, DstName, false). |
322 | 315 |
|
| 316 | +-spec list_for_source_and_destination(rabbit_types:binding_source(), rabbit_types:binding_destination(), boolean()) -> |
| 317 | + bindings(). |
323 | 318 | list_for_source_and_destination(?DEFAULT_EXCHANGE(VHostPath), |
324 | 319 | #resource{kind = queue, |
325 | 320 | virtual_host = VHostPath, |
326 | | - name = QName} = DstQueue) -> |
| 321 | + name = QName} = DstQueue, |
| 322 | + _Reverse) -> |
327 | 323 | [#binding{source = ?DEFAULT_EXCHANGE(VHostPath), |
328 | 324 | destination = DstQueue, |
329 | 325 | key = QName, |
330 | 326 | args = []}]; |
331 | | -list_for_source_and_destination(SrcName, DstName) -> |
332 | | - mnesia:async_dirty( |
333 | | - fun() -> |
334 | | - Route = #route{binding = #binding{source = SrcName, |
335 | | - destination = DstName, |
336 | | - _ = '_'}}, |
337 | | - [B || #route{binding = B} <- mnesia:match_object(rabbit_route, |
338 | | - Route, read)] |
339 | | - end). |
| 327 | +list_for_source_and_destination(SrcName, DstName, Reverse) -> |
| 328 | + Route = #route{binding = #binding{source = SrcName, |
| 329 | + destination = DstName, |
| 330 | + _ = '_'}}, |
| 331 | + Fun = list_for_route(Route, Reverse), |
| 332 | + mnesia:async_dirty(Fun). |
| 333 | + |
| 334 | +list_for_route(Route, false) -> |
| 335 | + fun() -> |
| 336 | + [B || #route{binding = B} <- mnesia:match_object(rabbit_route, Route, read)] |
| 337 | + end; |
| 338 | +list_for_route(Route, true) -> |
| 339 | + fun() -> |
| 340 | + [reverse_binding(B) || |
| 341 | + #reverse_route{reverse_binding = B} <- |
| 342 | + mnesia:match_object(rabbit_reverse_route, |
| 343 | + reverse_route(Route), read)] |
| 344 | + end. |
340 | 345 |
|
341 | 346 | -spec info_keys() -> rabbit_types:info_keys(). |
342 | 347 |
|
|
0 commit comments