diff options
author | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-04-02 13:43:19 +0100 |
---|---|---|
committer | Francesco Mazzoli <francesco@rabbitmq.com> | 2012-04-02 13:43:19 +0100 |
commit | 074a70840e7a6e0b7377ca16293951930d5d5ec1 (patch) | |
tree | 2f15da9769292ecb8e87462c0a5d26de4a7b8b16 | |
parent | 007a84fdb711e9fe488cf33df9c5d9622cb58383 (diff) | |
parent | 61541af68cc6efb633d4e528cbc41bd0f4349588 (diff) | |
download | rabbitmq-server-074a70840e7a6e0b7377ca16293951930d5d5ec1.tar.gz |
Merged default.
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | include/rabbit_auth_backend_spec.hrl | 31 | ||||
-rw-r--r-- | include/rabbit_auth_mechanism_spec.hrl | 28 | ||||
-rw-r--r-- | include/rabbit_exchange_type_spec.hrl | 38 | ||||
-rw-r--r-- | src/gen_server2.erl | 61 | ||||
-rw-r--r-- | src/gm.erl | 103 | ||||
-rw-r--r-- | src/rabbit_auth_backend.erl | 83 | ||||
-rw-r--r-- | src/rabbit_auth_backend_internal.erl | 2 | ||||
-rw-r--r-- | src/rabbit_auth_mechanism.erl | 56 | ||||
-rw-r--r-- | src/rabbit_auth_mechanism_amqplain.erl | 2 | ||||
-rw-r--r-- | src/rabbit_auth_mechanism_cr_demo.erl | 2 | ||||
-rw-r--r-- | src/rabbit_auth_mechanism_plain.erl | 2 | ||||
-rw-r--r-- | src/rabbit_exchange_type.erl | 66 | ||||
-rw-r--r-- | src/rabbit_exchange_type_direct.erl | 1 | ||||
-rw-r--r-- | src/rabbit_exchange_type_fanout.erl | 1 | ||||
-rw-r--r-- | src/rabbit_exchange_type_headers.erl | 1 | ||||
-rw-r--r-- | src/rabbit_exchange_type_invalid.erl | 1 | ||||
-rw-r--r-- | src/rabbit_exchange_type_topic.erl | 1 |
18 files changed, 236 insertions, 249 deletions
@@ -42,9 +42,9 @@ BASIC_PLT=basic.plt RABBIT_PLT=rabbit.plt ifndef USE_SPECS -# our type specs rely on features and bug fixes in dialyzer that are -# only available in R14B03 upwards (R14B03 is erts 5.8.4) -USE_SPECS:=$(shell erl -noshell -eval 'io:format([list_to_integer(X) || X <- string:tokens(erlang:system_info(version), ".")] >= [5,8,4]), halt().') +# our type specs rely on callback specs, which are available in R15B +# upwards. +USE_SPECS:=$(shell erl -noshell -eval 'io:format([list_to_integer(X) || X <- string:tokens(erlang:system_info(version), ".")] >= [5,9]), halt().') endif ifndef USE_PROPER_QC diff --git a/include/rabbit_auth_backend_spec.hrl b/include/rabbit_auth_backend_spec.hrl deleted file mode 100644 index 61a2e22a..00000000 --- a/include/rabbit_auth_backend_spec.hrl +++ /dev/null @@ -1,31 +0,0 @@ -%% The contents of this file are subject to the Mozilla Public License -%% Version 1.1 (the "License"); you may not use this file except in -%% compliance with the License. You may obtain a copy of the License -%% at http://www.mozilla.org/MPL/ -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and -%% limitations under the License. -%% -%% The Original Code is RabbitMQ. -%% -%% The Initial Developer of the Original Code is VMware, Inc. -%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved. -%% - --ifdef(use_specs). - --spec(description/0 :: () -> [{atom(), any()}]). - --spec(check_user_login/2 :: (rabbit_types:username(), [term()]) -> - {'ok', rabbit_types:user()} | - {'refused', string(), [any()]} | - {'error', any()}). --spec(check_vhost_access/2 :: (rabbit_types:user(), rabbit_types:vhost()) -> - boolean() | {'error', any()}). --spec(check_resource_access/3 :: (rabbit_types:user(), - rabbit_types:r(atom()), - rabbit_access_control:permission_atom()) -> - boolean() | {'error', any()}). --endif. diff --git a/include/rabbit_auth_mechanism_spec.hrl b/include/rabbit_auth_mechanism_spec.hrl deleted file mode 100644 index 9a2f5e05..00000000 --- a/include/rabbit_auth_mechanism_spec.hrl +++ /dev/null @@ -1,28 +0,0 @@ -%% The contents of this file are subject to the Mozilla Public License -%% Version 1.1 (the "License"); you may not use this file except in -%% compliance with the License. You may obtain a copy of the License -%% at http://www.mozilla.org/MPL/ -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and -%% limitations under the License. -%% -%% The Original Code is RabbitMQ. -%% -%% The Initial Developer of the Original Code is VMware, Inc. -%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved. -%% - --ifdef(use_specs). - --spec(description/0 :: () -> [{atom(), any()}]). --spec(should_offer/1 :: (rabbit_net:socket()) -> boolean()). --spec(init/1 :: (rabbit_net:socket()) -> any()). --spec(handle_response/2 :: (binary(), any()) -> - {'ok', rabbit_types:user()} | - {'challenge', binary(), any()} | - {'protocol_error', string(), [any()]} | - {'refused', string(), [any()]}). - --endif. diff --git a/include/rabbit_exchange_type_spec.hrl b/include/rabbit_exchange_type_spec.hrl deleted file mode 100644 index 8f7e22d3..00000000 --- a/include/rabbit_exchange_type_spec.hrl +++ /dev/null @@ -1,38 +0,0 @@ -%% The contents of this file are subject to the Mozilla Public License -%% Version 1.1 (the "License"); you may not use this file except in -%% compliance with the License. You may obtain a copy of the License -%% at http://www.mozilla.org/MPL/ -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and -%% limitations under the License. -%% -%% The Original Code is RabbitMQ. -%% -%% The Initial Developer of the Original Code is VMware, Inc. -%% Copyright (c) 2007-2012 VMware, Inc. All rights reserved. -%% - --ifdef(use_specs). - --type(tx() :: 'transaction' | 'none'). --type(serial() :: pos_integer() | tx()). - --spec(description/0 :: () -> [{atom(), any()}]). --spec(serialise_events/0 :: () -> boolean()). --spec(route/2 :: (rabbit_types:exchange(), rabbit_types:delivery()) - -> rabbit_router:match_result()). --spec(validate/1 :: (rabbit_types:exchange()) -> 'ok'). --spec(create/2 :: (tx(), rabbit_types:exchange()) -> 'ok'). --spec(delete/3 :: (tx(), rabbit_types:exchange(), - [rabbit_types:binding()]) -> 'ok'). --spec(add_binding/3 :: (serial(), rabbit_types:exchange(), - rabbit_types:binding()) -> 'ok'). --spec(remove_bindings/3 :: (serial(), rabbit_types:exchange(), - [rabbit_types:binding()]) -> 'ok'). --spec(assert_args_equivalence/2 :: - (rabbit_types:exchange(), rabbit_framing:amqp_table()) - -> 'ok' | rabbit_types:connection_exit()). - --endif. diff --git a/src/gen_server2.erl b/src/gen_server2.erl index f8537487..50476392 100644 --- a/src/gen_server2.erl +++ b/src/gen_server2.erl @@ -31,13 +31,13 @@ %% handle_pre_hibernate/1 then the default action is to hibernate. %% %% 6) init can return a 4th arg, {backoff, InitialTimeout, -%% MinimumTimeout, DesiredHibernatePeriod} (all in -%% milliseconds). Then, on all callbacks which can return a timeout -%% (including init), timeout can be 'hibernate'. When this is the -%% case, the current timeout value will be used (initially, the -%% InitialTimeout supplied from init). After this timeout has -%% occurred, hibernation will occur as normal. Upon awaking, a new -%% current timeout value will be calculated. +%% MinimumTimeout, DesiredHibernatePeriod} (all in milliseconds, +%% 'infinity' does not make sense here). Then, on all callbacks which +%% can return a timeout (including init), timeout can be +%% 'hibernate'. When this is the case, the current timeout value will +%% be used (initially, the InitialTimeout supplied from init). After +%% this timeout has occurred, hibernation will occur as normal. Upon +%% awaking, a new current timeout value will be calculated. %% %% The purpose is that the gen_server2 takes care of adjusting the %% current timeout value such that the process will increase the @@ -135,9 +135,10 @@ %%% Reason = normal | shutdown | Term, terminate(State) is called %%% %%% terminate(Reason, State) Let the user module clean up +%%% Reason = normal | shutdown | {shutdown, Term} | Term %%% always called when server terminates %%% -%%% ==> ok +%%% ==> ok | Term %%% %%% handle_pre_hibernate(State) %%% @@ -182,7 +183,9 @@ multi_call/2, multi_call/3, multi_call/4, enter_loop/3, enter_loop/4, enter_loop/5, enter_loop/6, wake_hib/1]). +-ifndef(use_specs). -export([behaviour_info/1]). +-endif. %% System exports -export([system_continue/3, @@ -220,12 +223,54 @@ %%% API %%%========================================================================= +-ifdef(use_specs). + +-type(millis() :: non_neg_integer()). + +-callback init(Args :: term()) -> + {ok, State :: term()} | + {ok, State :: term(), timeout() | hibernate} | + {ok, State :: term(), timeout() | hibernate, + {backoff, millis(), millis(), millis()}} | + ignore | + {stop, Reason :: term()}. +-callback handle_call(Request :: term(), From :: {pid(), Tag :: term()}, + State :: term()) -> + {reply, Reply :: term(), NewState :: term()} | + {reply, Reply :: term(), NewState :: term(), timeout() | hibernate} | + {noreply, NewState :: term()} | + {noreply, NewState :: term(), timeout() | hibernate} | + {stop, Reason :: term(), + Reply :: term(), NewState :: term()}. +-callback handle_cast(Request :: term(), State :: term()) -> + {noreply, NewState :: term()} | + {noreply, NewState :: term(), timeout() | hibernate} | + {stop, Reason :: term(), NewState :: term()}. +-callback handle_info(Info :: term(), State :: term()) -> + {noreply, NewState :: term()} | + {noreply, NewState :: term(), timeout() | hibernate} | + {stop, Reason :: term(), NewState :: term()}. +-callback terminate(Reason :: (normal | shutdown | {shutdown, term()} | term()), + State :: term()) -> + ok | term(). +-callback code_change(OldVsn :: (term() | {down, term()}), State :: term(), + Extra :: term()) -> + {ok, NewState :: term()} | {error, Reason :: term()}. + +%% It's not possible to define "optional" -callbacks, so putting specs +%% for handle_pre_hibernate/1 and handle_post_hibernate/1 will result +%% in warnings (the same applied for the behaviour_info before). + +-else. + behaviour_info(callbacks) -> [{init,1},{handle_call,3},{handle_cast,2},{handle_info,2}, {terminate,2},{code_change,3}]; behaviour_info(_Other) -> undefined. +-endif. + %%% ----------------------------------------------------------------- %%% Starts a generic server. %%% start(Mod, Args, Options) @@ -57,8 +57,8 @@ %% you wish to be passed into the callback module's functions. The %% joined/2 function will be called when we have joined the group, %% with the arguments passed to start_link and a list of the current -%% members of the group. See the comments in behaviour_info/1 below -%% for further details of the callback functions. +%% members of the group. See the callbacks specs and the comments +%% below for further details of the callback functions. %% %% leave/1 %% Provide the Pid. Removes the Pid from the group. The callback @@ -378,7 +378,9 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3, prioritise_info/2]). +-ifndef(use_specs). -export([behaviour_info/1]). +-endif. -export([table_definitions/0]). @@ -431,56 +433,63 @@ -spec(confirmed_broadcast/2 :: (pid(), any()) -> 'ok'). -spec(group_members/1 :: (pid()) -> [pid()]). --endif. +%% The joined, members_changed and handle_msg callbacks can all +%% return any of the following terms: +%% +%% 'ok' - the callback function returns normally +%% +%% {'stop', Reason} - the callback indicates the member should +%% stop with reason Reason and should leave the group. +%% +%% {'become', Module, Args} - the callback indicates that the +%% callback module should be changed to Module and that the +%% callback functions should now be passed the arguments +%% Args. This allows the callback module to be dynamically +%% changed. + +%% Called when we've successfully joined the group. Supplied with +%% Args provided in start_link, plus current group members. +-callback joined(Args :: term(), Members :: [pid()]) -> + ok | {stop, Reason :: term()} | {become, Module :: atom(), Args :: any()}. + +%% Supplied with Args provided in start_link, the list of new +%% members and the list of members previously known to us that +%% have since died. Note that if a member joins and dies very +%% quickly, it's possible that we will never see that member +%% appear in either births or deaths. However we are guaranteed +%% that (1) we will see a member joining either in the births +%% here, or in the members passed to joined/2 before receiving +%% any messages from it; and (2) we will not see members die that +%% we have not seen born (or supplied in the members to +%% joined/2). +-callback members_changed(Args :: term(), Births :: [pid()], + Deaths :: [pid()]) -> + ok | {stop, Reason :: term()} | {become, Module :: atom(), Args :: any()}. + +%% Supplied with Args provided in start_link, the sender, and the +%% message. This does get called for messages injected by this +%% member, however, in such cases, there is no special +%% significance of this invocation: it does not indicate that the +%% message has made it to any other members, let alone all other +%% members. +-callback handle_msg(Args :: term(), From :: pid(), Message :: term()) -> + ok | {stop, Reason :: term()} | {become, Module :: atom(), Args :: any()}. + +%% Called on gm member termination as per rules in gen_server, +%% with the Args provided in start_link plus the termination +%% Reason. +-callback terminate(Args :: term(), Reason :: term()) -> + ok | term(). + +-else. behaviour_info(callbacks) -> - [ - %% The joined, members_changed and handle_msg callbacks can all - %% return any of the following terms: - %% - %% 'ok' - the callback function returns normally - %% - %% {'stop', Reason} - the callback indicates the member should - %% stop with reason Reason and should leave the group. - %% - %% {'become', Module, Args} - the callback indicates that the - %% callback module should be changed to Module and that the - %% callback functions should now be passed the arguments - %% Args. This allows the callback module to be dynamically - %% changed. - - %% Called when we've successfully joined the group. Supplied with - %% Args provided in start_link, plus current group members. - {joined, 2}, - - %% Supplied with Args provided in start_link, the list of new - %% members and the list of members previously known to us that - %% have since died. Note that if a member joins and dies very - %% quickly, it's possible that we will never see that member - %% appear in either births or deaths. However we are guaranteed - %% that (1) we will see a member joining either in the births - %% here, or in the members passed to joined/2 before receiving - %% any messages from it; and (2) we will not see members die that - %% we have not seen born (or supplied in the members to - %% joined/2). - {members_changed, 3}, - - %% Supplied with Args provided in start_link, the sender, and the - %% message. This does get called for messages injected by this - %% member, however, in such cases, there is no special - %% significance of this invocation: it does not indicate that the - %% message has made it to any other members, let alone all other - %% members. - {handle_msg, 3}, - - %% Called on gm member termination as per rules in gen_server, - %% with the Args provided in start_link plus the termination - %% Reason. - {terminate, 2} - ]; + [{joined, 2}, {members_changed, 3}, {handle_msg, 3}, {terminate, 2}]; behaviour_info(_Other) -> undefined. +-endif. + create_tables() -> create_tables([?TABLE]). diff --git a/src/rabbit_auth_backend.erl b/src/rabbit_auth_backend.erl index e0e252b8..e89951e7 100644 --- a/src/rabbit_auth_backend.erl +++ b/src/rabbit_auth_backend.erl @@ -16,42 +16,57 @@ -module(rabbit_auth_backend). +-ifdef(use_specs). + +%% A description proplist as with auth mechanisms, +%% exchanges. Currently unused. +-callback description() -> [proplist:property()]. + +%% Check a user can log in, given a username and a proplist of +%% authentication information (e.g. [{password, Password}]). +%% +%% Possible responses: +%% {ok, User} +%% Authentication succeeded, and here's the user record. +%% {error, Error} +%% Something went wrong. Log and die. +%% {refused, Msg, Args} +%% Client failed authentication. Log and die. +-callback check_user_login(rabbit_types:username(), [term()]) -> + {'ok', rabbit_types:user()} | + {'refused', string(), [any()]} | + {'error', any()}. + +%% Given #user and vhost, can a user log in to a vhost? +%% Possible responses: +%% true +%% false +%% {error, Error} +%% Something went wrong. Log and die. +-callback check_vhost_access(rabbit_types:user(), rabbit_types:vhost()) -> + boolean() | {'error', any()}. + + +%% Given #user, resource and permission, can a user access a resource? +%% +%% Possible responses: +%% true +%% false +%% {error, Error} +%% Something went wrong. Log and die. +-callback check_resource_access(rabbit_types:user(), + rabbit_types:r(atom()), + rabbit_access_control:permission_atom()) -> + boolean() | {'error', any()}. + +-else. + -export([behaviour_info/1]). behaviour_info(callbacks) -> - [ - %% A description proplist as with auth mechanisms, - %% exchanges. Currently unused. - {description, 0}, - - %% Check a user can log in, given a username and a proplist of - %% authentication information (e.g. [{password, Password}]). - %% - %% Possible responses: - %% {ok, User} - %% Authentication succeeded, and here's the user record. - %% {error, Error} - %% Something went wrong. Log and die. - %% {refused, Msg, Args} - %% Client failed authentication. Log and die. - {check_user_login, 2}, - - %% Given #user and vhost, can a user log in to a vhost? - %% Possible responses: - %% true - %% false - %% {error, Error} - %% Something went wrong. Log and die. - {check_vhost_access, 2}, - - %% Given #user, resource and permission, can a user access a resource? - %% - %% Possible responses: - %% true - %% false - %% {error, Error} - %% Something went wrong. Log and die. - {check_resource_access, 3} - ]; + [{description, 0}, {check_user_login, 2}, {check_vhost_access, 2}, + {check_resource_access, 3}]; behaviour_info(_Other) -> undefined. + +-endif. diff --git a/src/rabbit_auth_backend_internal.erl b/src/rabbit_auth_backend_internal.erl index 3ef81d32..7b9df81e 100644 --- a/src/rabbit_auth_backend_internal.erl +++ b/src/rabbit_auth_backend_internal.erl @@ -32,8 +32,6 @@ vhost_perms_info_keys/0, user_perms_info_keys/0, user_vhost_perms_info_keys/0]). --include("rabbit_auth_backend_spec.hrl"). - -ifdef(use_specs). -type(regexp() :: binary()). diff --git a/src/rabbit_auth_mechanism.erl b/src/rabbit_auth_mechanism.erl index 0c8251b8..eda6a743 100644 --- a/src/rabbit_auth_mechanism.erl +++ b/src/rabbit_auth_mechanism.erl @@ -16,31 +16,41 @@ -module(rabbit_auth_mechanism). +-ifdef(use_specs). + +%% A description. +-callback description() -> [proplist:property()]. + +%% If this mechanism is enabled, should it be offered for a given socket? +%% (primarily so EXTERNAL can be SSL-only) +-callback should_offer(rabbit_net:socket()) -> boolean(). + +%% Called before authentication starts. Should create a state +%% object to be passed through all the stages of authentication. +-callback init(rabbit_net:socket()) -> any(). + +%% Handle a stage of authentication. Possible responses: +%% {ok, User} +%% Authentication succeeded, and here's the user record. +%% {challenge, Challenge, NextState} +%% Another round is needed. Here's the state I want next time. +%% {protocol_error, Msg, Args} +%% Client got the protocol wrong. Log and die. +%% {refused, Msg, Args} +%% Client failed authentication. Log and die. +-callback handle_response(binary(), any()) -> + {'ok', rabbit_types:user()} | + {'challenge', binary(), any()} | + {'protocol_error', string(), [any()]} | + {'refused', string(), [any()]}. + +-else. + -export([behaviour_info/1]). behaviour_info(callbacks) -> - [ - %% A description. - {description, 0}, - - %% If this mechanism is enabled, should it be offered for a given socket? - %% (primarily so EXTERNAL can be SSL-only) - {should_offer, 1}, - - %% Called before authentication starts. Should create a state - %% object to be passed through all the stages of authentication. - {init, 1}, - - %% Handle a stage of authentication. Possible responses: - %% {ok, User} - %% Authentication succeeded, and here's the user record. - %% {challenge, Challenge, NextState} - %% Another round is needed. Here's the state I want next time. - %% {protocol_error, Msg, Args} - %% Client got the protocol wrong. Log and die. - %% {refused, Msg, Args} - %% Client failed authentication. Log and die. - {handle_response, 2} - ]; + [{description, 0}, {should_offer, 1}, {init, 1}, {handle_response, 2}]; behaviour_info(_Other) -> undefined. + +-endif. diff --git a/src/rabbit_auth_mechanism_amqplain.erl b/src/rabbit_auth_mechanism_amqplain.erl index 3de6e7a6..c0d86cd1 100644 --- a/src/rabbit_auth_mechanism_amqplain.erl +++ b/src/rabbit_auth_mechanism_amqplain.erl @@ -21,8 +21,6 @@ -export([description/0, should_offer/1, init/1, handle_response/2]). --include("rabbit_auth_mechanism_spec.hrl"). - -rabbit_boot_step({?MODULE, [{description, "auth mechanism amqplain"}, {mfa, {rabbit_registry, register, diff --git a/src/rabbit_auth_mechanism_cr_demo.erl b/src/rabbit_auth_mechanism_cr_demo.erl index 64b01d8e..5df1d5d7 100644 --- a/src/rabbit_auth_mechanism_cr_demo.erl +++ b/src/rabbit_auth_mechanism_cr_demo.erl @@ -21,8 +21,6 @@ -export([description/0, should_offer/1, init/1, handle_response/2]). --include("rabbit_auth_mechanism_spec.hrl"). - -rabbit_boot_step({?MODULE, [{description, "auth mechanism cr-demo"}, {mfa, {rabbit_registry, register, diff --git a/src/rabbit_auth_mechanism_plain.erl b/src/rabbit_auth_mechanism_plain.erl index 19fb5875..423170e1 100644 --- a/src/rabbit_auth_mechanism_plain.erl +++ b/src/rabbit_auth_mechanism_plain.erl @@ -21,8 +21,6 @@ -export([description/0, should_offer/1, init/1, handle_response/2]). --include("rabbit_auth_mechanism_spec.hrl"). - -rabbit_boot_step({?MODULE, [{description, "auth mechanism plain"}, {mfa, {rabbit_registry, register, diff --git a/src/rabbit_exchange_type.erl b/src/rabbit_exchange_type.erl index 44a08e24..1027570c 100644 --- a/src/rabbit_exchange_type.erl +++ b/src/rabbit_exchange_type.erl @@ -16,39 +16,57 @@ -module(rabbit_exchange_type). --export([behaviour_info/1]). +-ifdef(use_specs). -behaviour_info(callbacks) -> - [ - {description, 0}, +-type(tx() :: 'transaction' | 'none'). +-type(serial() :: pos_integer() | tx()). + +-callback description() -> [proplist:property()]. + +%% Should Rabbit ensure that all binding events that are +%% delivered to an individual exchange can be serialised? (they +%% might still be delivered out of order, but there'll be a +%% serial number). +-callback serialise_events() -> boolean(). - %% Should Rabbit ensure that all binding events that are - %% delivered to an individual exchange can be serialised? (they - %% might still be delivered out of order, but there'll be a - %% serial number). - {serialise_events, 0}, +%% The no_return is there so that we can have an "invalid" exchange +%% type (see rabbit_exchange_type_invalid). +-callback route(rabbit_types:exchange(), rabbit_types:delivery()) -> + rabbit_router:match_result(). - {route, 2}, +%% called BEFORE declaration, to check args etc; may exit with #amqp_error{} +-callback validate(rabbit_types:exchange()) -> 'ok'. - %% called BEFORE declaration, to check args etc; may exit with #amqp_error{} - {validate, 1}, +%% called after declaration and recovery +-callback create(tx(), rabbit_types:exchange()) -> 'ok'. - %% called after declaration and recovery - {create, 2}, +%% called after exchange (auto)deletion. +-callback delete(tx(), rabbit_types:exchange(), [rabbit_types:binding()]) -> + 'ok'. - %% called after exchange (auto)deletion. - {delete, 3}, +%% called after a binding has been added or recovered +-callback add_binding(serial(), rabbit_types:exchange(), + rabbit_types:binding()) -> 'ok'. - %% called after a binding has been added or recovered - {add_binding, 3}, +%% called after bindings have been deleted. +-callback remove_bindings(serial(), rabbit_types:exchange(), + [rabbit_types:binding()]) -> 'ok'. - %% called after bindings have been deleted. - {remove_bindings, 3}, +%% called when comparing exchanges for equivalence - should return ok or +%% exit with #amqp_error{} +-callback assert_args_equivalence (rabbit_types:exchange(), + rabbit_framing:amqp_table()) -> + 'ok' | rabbit_types:connection_exit(). - %% called when comparing exchanges for equivalence - should return ok or - %% exit with #amqp_error{} - {assert_args_equivalence, 2} +-else. - ]; +-export([behaviour_info/1]). + +behaviour_info(callbacks) -> + [{description, 0}, {serialise_events, 0}, {route, 2}, {validate, 1}, + {create, 2}, {delete, 3}, {add_binding, 3}, {remove_bindings, 3}, + {assert_args_equivalence, 2}]; behaviour_info(_Other) -> undefined. + +-endif. diff --git a/src/rabbit_exchange_type_direct.erl b/src/rabbit_exchange_type_direct.erl index 4bce42d4..cdec1cb9 100644 --- a/src/rabbit_exchange_type_direct.erl +++ b/src/rabbit_exchange_type_direct.erl @@ -22,7 +22,6 @@ -export([description/0, serialise_events/0, route/2]). -export([validate/1, create/2, delete/3, add_binding/3, remove_bindings/3, assert_args_equivalence/2]). --include("rabbit_exchange_type_spec.hrl"). -rabbit_boot_step({?MODULE, [{description, "exchange type direct"}, diff --git a/src/rabbit_exchange_type_fanout.erl b/src/rabbit_exchange_type_fanout.erl index cc3fb87c..a64f2c29 100644 --- a/src/rabbit_exchange_type_fanout.erl +++ b/src/rabbit_exchange_type_fanout.erl @@ -22,7 +22,6 @@ -export([description/0, serialise_events/0, route/2]). -export([validate/1, create/2, delete/3, add_binding/3, remove_bindings/3, assert_args_equivalence/2]). --include("rabbit_exchange_type_spec.hrl"). -rabbit_boot_step({?MODULE, [{description, "exchange type fanout"}, diff --git a/src/rabbit_exchange_type_headers.erl b/src/rabbit_exchange_type_headers.erl index de9979b4..61917d8f 100644 --- a/src/rabbit_exchange_type_headers.erl +++ b/src/rabbit_exchange_type_headers.erl @@ -23,7 +23,6 @@ -export([description/0, serialise_events/0, route/2]). -export([validate/1, create/2, delete/3, add_binding/3, remove_bindings/3, assert_args_equivalence/2]). --include("rabbit_exchange_type_spec.hrl"). -rabbit_boot_step({?MODULE, [{description, "exchange type headers"}, diff --git a/src/rabbit_exchange_type_invalid.erl b/src/rabbit_exchange_type_invalid.erl index 8f60f7d8..82d27960 100644 --- a/src/rabbit_exchange_type_invalid.erl +++ b/src/rabbit_exchange_type_invalid.erl @@ -22,7 +22,6 @@ -export([description/0, serialise_events/0, route/2]). -export([validate/1, create/2, delete/3, add_binding/3, remove_bindings/3, assert_args_equivalence/2]). --include("rabbit_exchange_type_spec.hrl"). description() -> [{name, <<"invalid">>}, diff --git a/src/rabbit_exchange_type_topic.erl b/src/rabbit_exchange_type_topic.erl index 84f4f8a9..3160fdf4 100644 --- a/src/rabbit_exchange_type_topic.erl +++ b/src/rabbit_exchange_type_topic.erl @@ -23,7 +23,6 @@ -export([description/0, serialise_events/0, route/2]). -export([validate/1, create/2, delete/3, add_binding/3, remove_bindings/3, assert_args_equivalence/2]). --include("rabbit_exchange_type_spec.hrl"). -rabbit_boot_step({?MODULE, [{description, "exchange type topic"}, |