diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2011-06-27 17:32:57 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2011-06-27 17:32:57 +0100 |
| commit | ab53bfb04b08bffafe243ed4dbfcf4a42c32fbd6 (patch) | |
| tree | 9a19ea5cea88bf0de41796253a37bbac3434ee57 /src | |
| parent | 3b5b393f060f3758e5c7802767b20fb6f46e0d9c (diff) | |
| download | rabbitmq-server-git-ab53bfb04b08bffafe243ed4dbfcf4a42c32fbd6.tar.gz | |
Scratch space for exchanges, and rabbit_exchange:update/2.
Diffstat (limited to 'src')
| -rw-r--r-- | src/rabbit_exchange.erl | 23 | ||||
| -rw-r--r-- | src/rabbit_upgrade_functions.erl | 14 |
2 files changed, 36 insertions, 1 deletions
diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl index cab1b99f6f..0c3354639c 100644 --- a/src/rabbit_exchange.erl +++ b/src/rabbit_exchange.erl @@ -20,7 +20,7 @@ -export([recover/0, callback/3, declare/6, assert_equivalence/6, assert_args_equivalence/2, check_type/1, - lookup/1, lookup_or_die/1, list/1, + lookup/1, lookup_or_die/1, list/1, update/2, info_keys/0, info/1, info/2, info_all/1, info_all/2, publish/2, delete/2]). %% these must be run inside a mnesia tx @@ -199,6 +199,27 @@ list(VHostPath) -> rabbit_exchange, #exchange{name = rabbit_misc:r(VHostPath, exchange), _ = '_'}). +update(Name, Fun) -> + case mnesia:transaction( + fun() -> + case mnesia:read(rabbit_exchange, Name, write) of + [X = #exchange{durable = Durable}] -> + ok = mnesia:write(rabbit_exchange, Fun(X), write), + case Durable of + true -> + ok = mnesia:write(rabbit_durable_exchange, + Fun(X), write); + _ -> + ok + end; + [] -> + ok + end + end) of + {atomic, ok} -> ok; + {aborted, Reason} -> {error, Reason} + end. + info_keys() -> ?INFO_KEYS. map(VHostPath, F) -> diff --git a/src/rabbit_upgrade_functions.erl b/src/rabbit_upgrade_functions.erl index 0f7a781043..acf45bf3e3 100644 --- a/src/rabbit_upgrade_functions.erl +++ b/src/rabbit_upgrade_functions.erl @@ -32,6 +32,7 @@ -rabbit_upgrade({user_admin_to_tags, mnesia, [user_to_internal_user]}). -rabbit_upgrade({ha_mirrors, mnesia, []}). -rabbit_upgrade({gm, mnesia, []}). +-rabbit_upgrade({exchange_scratch, mnesia, [trace_exchanges]}). %% ------------------------------------------------------------------- @@ -49,6 +50,7 @@ -spec(user_admin_to_tags/0 :: () -> 'ok'). -spec(ha_mirrors/0 :: () -> 'ok'). -spec(gm/0 :: () -> 'ok'). +-spec(exchange_scratch/0 :: () -> 'ok'). -endif. @@ -155,6 +157,18 @@ gm() -> create(gm_group, [{record_name, gm_group}, {attributes, [name, version, members]}]). +exchange_scratch() -> + ok = exchange_scratch(rabbit_exchange), + ok = exchange_scratch(rabbit_durable_exchange). + +exchange_scratch(Table) -> + transform( + Table, + fun ({exchange, Name, Type, Dur, AutoDel, Int, Args}) -> + {exchange, Name, Type, Dur, AutoDel, Int, Args, undefined} + end, + [name, type, durable, auto_delete, internal, arguments, scratch]). + %%-------------------------------------------------------------------- transform(TableName, Fun, FieldList) -> |
