summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthew Sackman <matthew@rabbitmq.com>2010-08-03 14:55:06 +0100
committerMatthew Sackman <matthew@rabbitmq.com>2010-08-03 14:55:06 +0100
commit65ab6f24a5441aa17b73d43912c6973a31592bf0 (patch)
treefc9038a98bc98e11bef0ff2bb14d65832ca3141e /src
parent98831545b0205444b69de77bb617434714b3212e (diff)
parent28762641b3702e8b1901fd9f42d0f1563a4903ae (diff)
downloadrabbitmq-server-git-65ab6f24a5441aa17b73d43912c6973a31592bf0.tar.gz
Merging bug 23048 onto default
Diffstat (limited to 'src')
-rw-r--r--src/rabbit_access_control.erl8
-rw-r--r--src/rabbit_amqqueue.erl5
-rw-r--r--src/rabbit_basic.erl10
-rw-r--r--src/rabbit_exchange.erl38
-rw-r--r--src/rabbit_misc.erl15
-rw-r--r--src/vm_memory_monitor.erl2
6 files changed, 35 insertions, 43 deletions
diff --git a/src/rabbit_access_control.erl b/src/rabbit_access_control.erl
index 55d738ffd7..1dbda8058e 100644
--- a/src/rabbit_access_control.erl
+++ b/src/rabbit_access_control.erl
@@ -55,7 +55,9 @@
-spec(check_login/2 ::
(binary(), binary()) -> rabbit_types:user() |
rabbit_types:channel_exit()).
--spec(user_pass_login/2 :: (username(), password()) -> rabbit_types:user()).
+-spec(user_pass_login/2 ::
+ (username(), password())
+ -> rabbit_types:user() | rabbit_types:channel_exit()).
-spec(check_vhost_access/2 ::
(rabbit_types:user(), rabbit_types:vhost())
-> 'ok' | rabbit_types:channel_exit()).
@@ -70,9 +72,9 @@
(username()) -> rabbit_types:ok(rabbit_types:user())
| rabbit_types:error('not_found')).
-spec(add_vhost/1 ::
- (rabbit_types:vhost()) -> 'ok' | rabbit_types:connection_exit()).
+ (rabbit_types:vhost()) -> 'ok').
-spec(delete_vhost/1 ::
- (rabbit_types:vhost()) -> 'ok' | rabbit_types:connection_exit()).
+ (rabbit_types:vhost()) -> 'ok').
-spec(list_vhosts/0 :: () -> [rabbit_types:vhost()]).
-spec(set_permissions/5 ::(username(), rabbit_types:vhost(), regexp(),
regexp(), regexp()) -> 'ok').
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index f9f8e2ecef..d4226331c3 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -150,8 +150,7 @@
-spec(flush_all/2 :: ([pid()], pid()) -> 'ok').
-spec(internal_declare/2 ::
(rabbit_types:amqqueue(), boolean())
- -> rabbit_types:amqqueue() | 'not_found' |
- rabbit_types:connection_exit()).
+ -> rabbit_types:amqqueue() | 'not_found').
-spec(internal_delete/1 ::
(name()) -> rabbit_types:ok_or_error('not_found') |
rabbit_types:connection_exit()).
@@ -161,7 +160,7 @@
-spec(set_ram_duration_target/2 :: (pid(), number() | 'infinity') -> 'ok').
-spec(set_maximum_since_use/2 :: (pid(), non_neg_integer()) -> 'ok').
-spec(maybe_expire/1 :: (pid()) -> 'ok').
--spec(on_node_down/1 :: (node()) -> 'ok' | rabbit_types:connection_exit()).
+-spec(on_node_down/1 :: (node()) -> 'ok').
-spec(pseudo_queue/2 :: (binary(), pid()) -> rabbit_types:amqqueue()).
-endif.
diff --git a/src/rabbit_basic.erl b/src/rabbit_basic.erl
index b536fa79ed..c1445a0c69 100644
--- a/src/rabbit_basic.erl
+++ b/src/rabbit_basic.erl
@@ -49,12 +49,10 @@
| rabbit_types:error('not_found'))).
-spec(publish/1 ::
- (rabbit_types:delivery()) -> publish_result() |
- rabbit_types:connection_exit()).
+ (rabbit_types:delivery()) -> publish_result()).
-spec(delivery/4 ::
(boolean(), boolean(), rabbit_types:maybe(rabbit_types:txn()),
- rabbit_types:message())
- -> rabbit_types:delivery()).
+ rabbit_types:message()) -> rabbit_types:delivery()).
-spec(message/4 ::
(rabbit_exchange:name(), rabbit_router:routing_key(),
properties_input(), binary())
@@ -64,12 +62,12 @@
-spec(publish/4 ::
(rabbit_exchange:name(), rabbit_router:routing_key(),
properties_input(), binary())
- -> publish_result() | rabbit_types:connection_exit()).
+ -> publish_result()).
-spec(publish/7 ::
(rabbit_exchange:name(), rabbit_router:routing_key(),
boolean(), boolean(), rabbit_types:maybe(rabbit_types:txn()),
properties_input(), binary())
- -> publish_result() | rabbit_types:connection_exit()).
+ -> publish_result()).
-spec(build_content/2 ::
(rabbit_framing:amqp_property_record(), binary())
-> rabbit_types:content()).
diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl
index 75154388a7..4fb5d32913 100644
--- a/src/rabbit_exchange.erl
+++ b/src/rabbit_exchange.erl
@@ -67,10 +67,10 @@
fun((rabbit_types:exchange(), queue()) ->
rabbit_types:ok_or_error(rabbit_types:amqp_error()))).
--spec(recover/0 :: () -> 'ok' | rabbit_types:connection_exit()).
+-spec(recover/0 :: () -> 'ok').
-spec(declare/5 ::
(name(), type(), boolean(), boolean(), rabbit_framing:amqp_table())
- -> rabbit_types:exchange() | rabbit_types:connection_exit()).
+ -> rabbit_types:exchange()).
-spec(check_type/1 ::
(binary()) -> atom() | rabbit_types:connection_exit()).
-spec(assert_equivalence/5 ::
@@ -96,32 +96,26 @@
-spec(info_all/2 ::(rabbit_types:vhost(), [rabbit_types:info_key()])
-> [[rabbit_types:info()]]).
-spec(publish/2 :: (rabbit_types:exchange(), rabbit_types:delivery())
- -> {rabbit_router:routing_result(), [pid()]} |
- rabbit_types:connection_exit()).
+ -> {rabbit_router:routing_result(), [pid()]}).
-spec(add_binding/5 ::
(name(), rabbit_amqqueue:name(), rabbit_router:routing_key(),
- rabbit_framing:amqp_table(), inner_fun())
- -> bind_res() | rabbit_types:connection_exit()).
+ rabbit_framing:amqp_table(), inner_fun()) -> bind_res()).
-spec(delete_binding/5 ::
(name(), rabbit_amqqueue:name(), rabbit_router:routing_key(),
rabbit_framing:amqp_table(), inner_fun())
- -> bind_res() | rabbit_types:error('binding_not_found') |
- rabbit_types:connection_exit()).
+ -> bind_res() | rabbit_types:error('binding_not_found')).
-spec(list_bindings/1 ::
(rabbit_types:vhost())
-> [{name(), rabbit_amqqueue:name(), rabbit_router:routing_key(),
rabbit_framing:amqp_table()}]).
-spec(delete_queue_bindings/1 ::
- (rabbit_amqqueue:name())
- -> fun (() -> none()) | rabbit_types:connection_exit()).
+ (rabbit_amqqueue:name()) -> fun (() -> none())).
-spec(delete_transient_queue_bindings/1 ::
- (rabbit_amqqueue:name())
- -> fun (() -> none()) | rabbit_types:connection_exit()).
+ (rabbit_amqqueue:name()) -> fun (() -> none())).
-spec(delete/2 ::
(name(), boolean())-> 'ok' |
rabbit_types:error('not_found') |
- rabbit_types:error('in_use') |
- rabbit_types:connection_exit()).
+ rabbit_types:error('in_use')).
-spec(list_queue_bindings/1 ::
(rabbit_amqqueue:name())
-> [{name(), rabbit_router:routing_key(),
@@ -208,12 +202,8 @@ declare(ExchangeName, Type, Durable, AutoDelete, Args) ->
%% Used with atoms from records; e.g., the type is expected to exist.
type_to_module(T) ->
- case rabbit_exchange_type_registry:lookup_module(T) of
- {ok, Module} -> Module;
- {error, not_found} -> rabbit_misc:protocol_error(
- command_invalid,
- "invalid exchange type '~s'", [T])
- end.
+ {ok, Module} = rabbit_exchange_type_registry:lookup_module(T),
+ Module.
%% Used with binaries sent over the wire; the type may not exist.
check_type(TypeBin) ->
@@ -222,8 +212,12 @@ check_type(TypeBin) ->
rabbit_misc:protocol_error(
command_invalid, "unknown exchange type '~s'", [TypeBin]);
T ->
- _Module = type_to_module(T),
- T
+ case rabbit_exchange_type_registry:lookup_module(T) of
+ {error, not_found} -> rabbit_misc:protocol_error(
+ command_invalid,
+ "invalid exchange type '~s'", [T]);
+ {ok, Module} -> T
+ end
end.
assert_equivalence(X = #exchange{ durable = Durable,
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index 7543ae5b29..3b665d387e 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -79,14 +79,15 @@
-type(ok_or_error() :: rabbit_types:ok_or_error(any())).
-type(thunk(T) :: fun(() -> T)).
-type(resource_name() :: binary()).
+-type(channel_or_connection_exit()
+ :: rabbit_types:channel_exit() | rabbit_types:connection_exit()).
-spec(method_record_type/1 :: (rabbit_framing:amqp_method_record())
-> rabbit_framing:amqp_method_name()).
-spec(polite_pause/0 :: () -> 'done').
-spec(polite_pause/1 :: (non_neg_integer()) -> 'done').
-spec(die/1 ::
- (rabbit_framing:amqp_exception())
- -> rabbit_types:channel_exit() | rabbit_types:connection_exit()).
+ (rabbit_framing:amqp_exception()) -> channel_or_connection_exit()).
-spec(frame_error/2 :: (rabbit_framing:amqp_method_name(), binary())
-> rabbit_types:connection_exit()).
-spec(amqp_error/4 ::
@@ -94,14 +95,12 @@
rabbit_framing:amqp_method_name())
-> rabbit_types:amqp_error()).
-spec(protocol_error/3 :: (rabbit_framing:amqp_exception(), string(), [any()])
- -> rabbit_types:channel_exit() |
- rabbit_types:connection_exit()).
+ -> channel_or_connection_exit()).
-spec(protocol_error/4 ::
(rabbit_framing:amqp_exception(), string(), [any()],
- rabbit_framing:amqp_method_name())
- -> rabbit_types:channel_exit() |
- rabbit_types:connection_exit()).
--spec(protocol_error/1 :: (rabbit_types:amqp_error()) -> no_return()).
+ rabbit_framing:amqp_method_name()) -> channel_or_connection_exit()).
+-spec(protocol_error/1 ::
+ (rabbit_types:amqp_error()) -> channel_or_connection_exit()).
-spec(not_found/1 :: (rabbit_types:r(atom())) -> rabbit_types:channel_exit()).
-spec(assert_args_equivalence/4 :: (rabbit_framing:amqp_table(),
rabbit_framing:amqp_table(),
diff --git a/src/vm_memory_monitor.erl b/src/vm_memory_monitor.erl
index bbc3a8c017..3cbc80f819 100644
--- a/src/vm_memory_monitor.erl
+++ b/src/vm_memory_monitor.erl
@@ -78,7 +78,7 @@
rabbit_types:ok(pid())).
-spec(update/0 :: () -> 'ok').
-spec(get_total_memory/0 :: () -> (non_neg_integer() | 'unknown')).
--spec(get_vm_limit/0 :: () -> (non_neg_integer() | 'unknown')).
+-spec(get_vm_limit/0 :: () -> non_neg_integer()).
-spec(get_memory_limit/0 :: () -> (non_neg_integer() | 'undefined')).
-spec(get_check_interval/0 :: () -> non_neg_integer()).
-spec(set_check_interval/1 :: (non_neg_integer()) -> 'ok').