|
18 | 18 |
|
19 | 19 | -export([description/0, serialise_events/0, route/2]).
|
20 | 20 | -export([validate/1, validate_binding/2,
|
21 |
| - create/2, delete/3, policy_changed/2, add_binding/3, |
| 21 | + create/2, delete/2, policy_changed/2, add_binding/3, |
22 | 22 | remove_bindings/3, assert_args_equivalence/2]).
|
23 | 23 | -export([init/0]).
|
24 | 24 | -export([info/1, info/2]).
|
@@ -67,41 +67,50 @@ route(#exchange{name = X},
|
67 | 67 |
|
68 | 68 | validate(_X) -> ok.
|
69 | 69 | validate_binding(_X, _B) -> ok.
|
70 |
| -create(_Tx, _X) -> ok. |
71 |
| - |
72 |
| -delete(transaction, #exchange{name = X}, _Bs) -> |
73 |
| - trie_remove_all_nodes(X), |
74 |
| - trie_remove_all_edges(X), |
75 |
| - trie_remove_all_bindings(X), |
| 70 | +create(_Serial, _X) -> ok. |
| 71 | + |
| 72 | +delete(none, #exchange{name = X}) -> |
| 73 | + rabbit_mnesia:execute_mnesia_transaction( |
| 74 | + fun() -> |
| 75 | + trie_remove_all_nodes(X), |
| 76 | + trie_remove_all_edges(X), |
| 77 | + trie_remove_all_bindings(X) |
| 78 | + end), |
76 | 79 | ok;
|
77 |
| -delete(none, _Exchange, _Bs) -> |
| 80 | +delete(_Serial, _X) -> |
78 | 81 | ok.
|
79 | 82 |
|
80 | 83 | policy_changed(_X1, _X2) -> ok.
|
81 | 84 |
|
82 |
| -add_binding(transaction, _Exchange, Binding) -> |
83 |
| - internal_add_binding(Binding); |
84 |
| -add_binding(none, _Exchange, _Binding) -> |
| 85 | +add_binding(none, _Exchange, Binding) -> |
| 86 | + rabbit_mnesia:execute_mnesia_transaction( |
| 87 | + fun() -> |
| 88 | + internal_add_binding(Binding) |
| 89 | + end); |
| 90 | +add_binding(_Serial, _Exchange, _Binding) -> |
85 | 91 | ok.
|
86 | 92 |
|
87 |
| -remove_bindings(transaction, _X, Bs) -> |
88 |
| - %% See rabbit_binding:lock_route_tables for the rationale for |
89 |
| - %% taking table locks. |
90 |
| - _ = case Bs of |
91 |
| - [_] -> ok; |
92 |
| - _ -> [mnesia:lock({table, T}, write) || |
93 |
| - T <- [rabbit_rtopic_trie_node, |
94 |
| - rabbit_rtopic_trie_edge, |
95 |
| - rabbit_rtopic_trie_binding]] |
96 |
| - end, |
97 |
| - [begin |
98 |
| - Path = [{FinalNode, _} | _] = |
99 |
| - follow_down_get_path(X, split_topic_key(K)), |
100 |
| - trie_remove_binding(X, FinalNode, D), |
101 |
| - remove_path_if_empty(X, Path) |
102 |
| - end || #binding{source = X, key = K, destination = D} <- Bs], |
| 93 | +remove_bindings(none, _X, Bs) -> |
| 94 | + rabbit_mnesia:execute_mnesia_transaction( |
| 95 | + fun() -> |
| 96 | + %% See rabbit_binding:lock_route_tables for the rationale for |
| 97 | + %% taking table locks. |
| 98 | + _ = case Bs of |
| 99 | + [_] -> ok; |
| 100 | + _ -> [mnesia:lock({table, T}, write) || |
| 101 | + T <- [rabbit_rtopic_trie_node, |
| 102 | + rabbit_rtopic_trie_edge, |
| 103 | + rabbit_rtopic_trie_binding]] |
| 104 | + end, |
| 105 | + [begin |
| 106 | + Path = [{FinalNode, _} | _] = |
| 107 | + follow_down_get_path(X, split_topic_key(K)), |
| 108 | + trie_remove_binding(X, FinalNode, D), |
| 109 | + remove_path_if_empty(X, Path) |
| 110 | + end || #binding{source = X, key = K, destination = D} <- Bs] |
| 111 | + end), |
103 | 112 | ok;
|
104 |
| -remove_bindings(none, _X, _Bs) -> |
| 113 | +remove_bindings(_Serial, _X, _Bs) -> |
105 | 114 | ok.
|
106 | 115 |
|
107 | 116 | assert_args_equivalence(X, Args) ->
|
|
0 commit comments