summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Scvortov <alexandru@rabbitmq.com>2010-07-02 12:25:30 +0100
committerAlexandru Scvortov <alexandru@rabbitmq.com>2010-07-02 12:25:30 +0100
commitd81c817d65ceba84c8095b0df866e068779c92f2 (patch)
treeab03c262b49adf6f0cd9067e3fb38afba1a96455
parenta7fe204b13b1f46d53d25ce87215b04ffdb50129 (diff)
downloadrabbitmq-server-d81c817d65ceba84c8095b0df866e068779c92f2.tar.gz
moved most hard-coded types from rabbit_framing
-rw-r--r--codegen.py8
-rw-r--r--src/rabbit.erl4
-rw-r--r--src/rabbit_access_control.erl22
-rw-r--r--src/rabbit_amqqueue.erl21
-rw-r--r--src/rabbit_basic.erl13
-rw-r--r--src/rabbit_channel.erl5
-rw-r--r--src/rabbit_exchange.erl8
-rw-r--r--src/rabbit_misc.erl18
8 files changed, 45 insertions, 54 deletions
diff --git a/codegen.py b/codegen.py
index 5c235e35..d0008cf3 100644
--- a/codegen.py
+++ b/codegen.py
@@ -333,8 +333,7 @@ def genErl(spec):
-export([amqp_exception/1]).
-export_type([amqp_table/0, amqp_property_type/0, amqp_method_record/0,
- amqp_method_name/0, amqp_method/0, vhost/0, ctag/0,
- resource_name/0, amqp_properties/0, amqp_class_id/0]).
+ amqp_method_name/0, amqp_method/0, amqp_class_id/0]).
bitvalue(true) -> 1;
bitvalue(false) -> 0;
@@ -367,12 +366,7 @@ bitvalue(undefined) -> 0.
%% we could make this more precise but ultimately are limited by
%% dialyzer's lack of support for recursive types
-type(amqp_table() :: [{binary(), amqp_field_type(), any()}]).
-%% TODO: make this more precise
-type(amqp_properties() :: tuple()).
--type(resource_name() :: binary()).
--type(vhost() :: binary()).
--type(ctag() :: binary()).
-
-endif. % use_specs
"""
print "-ifdef(use_specs)."
diff --git a/src/rabbit.erl b/src/rabbit.erl
index 86e00b7f..e276cd03 100644
--- a/src/rabbit.erl
+++ b/src/rabbit.erl
@@ -42,7 +42,7 @@
-export_type([regexp/0, txn/0, thunk/1,maybe/1, info/0, info_key/0,
msg_id/0, erlang_node/0, message/0, basic_message/0,
delivery/0, content/0, decoded_content/0, encoded_content/0,
- unencoded_content/0]).
+ unencoded_content/0, vhost/0, ctag/0]).
%%---------------------------------------------------------------------------
%% Boot steps.
@@ -192,6 +192,8 @@
-type(erlang_node() :: atom()).
-type(thunk(T) :: fun(() -> T)).
-type(regexp() :: binary()).
+-type(vhost() :: binary()).
+-type(ctag() :: binary()).
%% TODO: make this more precise by tying specific class_ids to
%% specific properties
diff --git a/src/rabbit_access_control.erl b/src/rabbit_access_control.erl
index 08f00ab2..082b0ac2 100644
--- a/src/rabbit_access_control.erl
+++ b/src/rabbit_access_control.erl
@@ -55,26 +55,24 @@
-spec(check_login/2 :: (binary(), binary()) -> user()).
-spec(user_pass_login/2 :: (username(), password()) -> user()).
--spec(check_vhost_access/2 :: (user(), rabbit_framing:vhost()) -> 'ok').
+-spec(check_vhost_access/2 :: (user(), rabbit:vhost()) -> 'ok').
-spec(check_resource_access/3 ::
- (username(), rabbit_misc:r(atom()), permission_atom()) -> 'ok').
+ (username(), rabbit_misc:r(atom()), permission_atom()) -> 'ok').
-spec(add_user/2 :: (username(), password()) -> 'ok').
-spec(delete_user/1 :: (username()) -> 'ok').
-spec(change_password/2 :: (username(), password()) -> 'ok').
-spec(list_users/0 :: () -> [username()]).
-spec(lookup_user/1 :: (username()) ->
{'ok', user()} | rabbit_misc:not_found()).
--spec(add_vhost/1 :: (rabbit_framing:vhost()) -> 'ok').
--spec(delete_vhost/1 :: (rabbit_framing:vhost()) -> 'ok').
--spec(list_vhosts/0 :: () -> [rabbit_framing:vhost()]).
--spec(set_permissions/5 ::
- (username(), rabbit_framing:vhost(), rabbit:regexp(),
- rabbit:regexp(), rabbit:regexp()
- ) -> 'ok').
--spec(clear_permissions/2 :: (username(), rabbit_framing:vhost()) -> 'ok').
+-spec(add_vhost/1 :: (rabbit:vhost()) -> 'ok').
+-spec(delete_vhost/1 :: (rabbit:vhost()) -> 'ok').
+-spec(list_vhosts/0 :: () -> [rabbit:vhost()]).
+-spec(set_permissions/5 ::(username(), rabbit:vhost(), rabbit:regexp(),
+ rabbit:regexp(), rabbit:regexp()) -> 'ok').
+-spec(clear_permissions/2 :: (username(), rabbit:vhost()) -> 'ok').
-spec(list_vhost_permissions/1 ::
- (rabbit_framing:vhost()) -> [{username(), rabbit:regexp(),
- rabbit:regexp(), rabbit:regexp()}]).
+ (rabbit:vhost()) -> [{username(), rabbit:regexp(),
+ rabbit:regexp(), rabbit:regexp()}]).
-spec(list_user_permissions/1 ::
(username()) -> [{rabbit_framing:vhost(), rabbit:regexp(),
rabbit:regexp(), rabbit:regexp()}]).
diff --git a/src/rabbit_amqqueue.erl b/src/rabbit_amqqueue.erl
index af8e1a0d..c65913cf 100644
--- a/src/rabbit_amqqueue.erl
+++ b/src/rabbit_amqqueue.erl
@@ -80,17 +80,16 @@
-spec(lookup/1 :: (name()) -> {'ok', amqqueue()} | rabbit_misc:not_found()).
-spec(with/2 :: (name(), qfun(A)) -> A | rabbit_misc:not_found()).
-spec(with_or_die/2 :: (name(), qfun(A)) -> A).
--spec(list/1 :: (rabbit_framing:vhost()) -> [amqqueue()]).
+-spec(list/1 :: (rabbit:vhost()) -> [amqqueue()]).
-spec(info_keys/0 :: () -> [rabbit:info_key()]).
-spec(info/1 :: (amqqueue()) -> [rabbit:info()]).
-spec(info/2 :: (amqqueue(), [rabbit:info_key()]) -> [rabbit:info()]).
--spec(info_all/1 :: (rabbit_framing:vhost()) -> [[rabbit:info()]]).
--spec(info_all/2 :: (rabbit_framing:vhost(), [rabbit:info_key()])
+-spec(info_all/1 :: (rabbit:vhost()) -> [[rabbit:info()]]).
+-spec(info_all/2 :: (rabbit:vhost(), [rabbit:info_key()])
-> [[rabbit:info()]]).
--spec(consumers/1 ::
- (amqqueue()) -> [{pid(), rabbit_framing:ctag(), boolean()}]).
--spec(consumers_all/1 :: (rabbit_framing:vhost())
- -> [{name(), pid(), rabbit_framing:ctag(), boolean()}]).
+-spec(consumers/1 :: (amqqueue()) -> [{pid(), rabbit:ctag(), boolean()}]).
+-spec(consumers_all/1 :: (rabbit:vhost())
+ -> [{name(), pid(), rabbit:ctag(), boolean()}]).
-spec(stat/1 :: (amqqueue()) -> qstats()).
-spec(stat_all/0 :: () -> [qstats()]).
-spec(delete/3 ::
@@ -112,10 +111,10 @@
-spec(basic_get/3 :: (amqqueue(), pid(), boolean()) ->
{'ok', non_neg_integer(), qmsg()} | 'empty').
-spec(basic_consume/7 ::
- (amqqueue(), boolean(), pid(), pid() | 'undefined', rabbit_framing:ctag(),
- boolean(), any()) ->
- 'ok' | {'error', 'exclusive_consume_unavailable'}).
--spec(basic_cancel/4 :: (amqqueue(), pid(), rabbit_framing:ctag(), any()) -> 'ok').
+ (amqqueue(), boolean(), pid(), pid() | 'undefined',
+ rabbit:ctag(), boolean(), any())
+ -> 'ok' | {'error', 'exclusive_consume_unavailable'}).
+-spec(basic_cancel/4 :: (amqqueue(), pid(), rabbit:ctag(), any()) -> 'ok').
-spec(notify_sent/2 :: (pid(), pid()) -> 'ok').
-spec(unblock/2 :: (pid(), pid()) -> 'ok').
-spec(flush_all/2 :: ([pid()], pid()) -> 'ok').
diff --git a/src/rabbit_basic.erl b/src/rabbit_basic.erl
index 8979b83b..e2c861d6 100644
--- a/src/rabbit_basic.erl
+++ b/src/rabbit_basic.erl
@@ -42,8 +42,7 @@
-ifdef(use_specs).
--type(properties_input() ::
- (rabbit_framing:amqp_properties() | [{atom(), any()}])).
+-type(properties_input() :: (rabbit_framing:amqp_properties() | [{atom(), any()}])).
-type(publish_result() :: ({ok, rabbit_router:routing_result(), [pid()]}
| rabbit_misc:not_found())).
@@ -53,16 +52,16 @@
-spec(message/4 :: (rabbit_exchange:name(), rabbit_router:routing_key(),
properties_input(), binary())
-> (rabbit:message() | {'error', any()})).
--spec(properties/1 ::
- (properties_input()) -> rabbit_framing:amqp_properties()).
+-spec(properties/1 :: (properties_input()) -> rabbit_framing:amqp_properties()).
-spec(publish/4 :: (rabbit_exchange:name(), rabbit_router:routing_key(),
properties_input(), binary()) -> publish_result()).
-spec(publish/7 :: (rabbit_exchange:name(), rabbit_router:routing_key(), boolean(), boolean(),
rabbit:maybe(rabbit:txn()), properties_input(), binary()) ->
publish_result()).
--spec(build_content/2 :: (rabbit_framing:amqp_properties(), binary())
- -> rabbit:content()).
--spec(from_content/1 :: (rabbit:content()) -> {rabbit_framing:amqp_properties(), binary()}).
+-spec(build_content/2 ::
+ (rabbit_framing:amqp_properties(), binary()) -> rabbit:content()).
+-spec(from_content/1 :: (rabbit:content())
+ -> {rabbit_framing:amqp_properties(), binary()}).
-spec(is_message_persistent/1 ::
(rabbit:decoded_content()) -> (boolean() | {'invalid', non_neg_integer()})).
diff --git a/src/rabbit_channel.erl b/src/rabbit_channel.erl
index 080c4c99..ca2e428e 100644
--- a/src/rabbit_channel.erl
+++ b/src/rabbit_channel.erl
@@ -78,14 +78,13 @@
-spec(start_link/6 ::
(channel_number(), pid(), pid(), rabbit_access_control:username(),
- rabbit_framing:vhost(), pid()) -> pid()).
+ rabbit:vhost(), pid()) -> pid()).
-spec(do/2 :: (pid(), rabbit_framing:amqp_method_record()) -> 'ok').
-spec(do/3 :: (pid(), rabbit_framing:amqp_method_record(),
rabbit:maybe(rabbit:content())) -> 'ok').
-spec(shutdown/1 :: (pid()) -> 'ok').
-spec(send_command/2 :: (pid(), rabbit_framing:amqp_method()) -> 'ok').
--spec(deliver/4 ::
- (pid(), rabbit_framing:ctag(), boolean(), rabbit_queue:qmsg()) -> 'ok').
+-spec(deliver/4 ::(pid(), rabbit:ctag(), boolean(), rabbit_queue:qmsg()) -> 'ok').
-spec(conserve_memory/2 :: (pid(), boolean()) -> 'ok').
-spec(flushed/2 :: (pid(), pid()) -> 'ok').
-spec(flow_timeout/2 :: (pid(), ref()) -> 'ok').
diff --git a/src/rabbit_exchange.erl b/src/rabbit_exchange.erl
index e109158b..4db5a933 100644
--- a/src/rabbit_exchange.erl
+++ b/src/rabbit_exchange.erl
@@ -90,12 +90,12 @@
-spec(lookup/1 :: (name())
-> {'ok', exchange()} | rabbit_misc:not_found()).
-spec(lookup_or_die/1 :: (name()) -> exchange()).
--spec(list/1 :: (rabbit_framing:vhost()) -> [exchange()]).
+-spec(list/1 :: (rabbit:vhost()) -> [exchange()]).
-spec(info_keys/0 :: () -> [rabbit:info_key()]).
-spec(info/1 :: (exchange()) -> [rabbit:info()]).
-spec(info/2 :: (exchange(), [rabbit:info_key()]) -> [rabbit:info()]).
--spec(info_all/1 :: (rabbit_framing:vhost()) -> [[rabbit:info()]]).
--spec(info_all/2 :: (rabbit_framing:vhost(), [rabbit:info_key()])
+-spec(info_all/1 :: (rabbit:vhost()) -> [[rabbit:info()]]).
+-spec(info_all/2 :: (rabbit:vhost(), [rabbit:info_key()])
-> [[rabbit:info()]]).
-spec(publish/2 :: (exchange(), rabbit:delivery())
-> {rabbit_router:routing_result(), [pid()]}).
@@ -106,7 +106,7 @@
(name(), rabbit_amqqueue:name(), rabbit_router:routing_key(),
rabbit_framing:amqp_table(), inner_fun())
-> bind_res() | {'error', 'binding_not_found'}).
--spec(list_bindings/1 :: (rabbit_framing:vhost()) ->
+-spec(list_bindings/1 :: (rabbit:vhost()) ->
[{name(), rabbit_amqqueue:name(),
rabbit_router:routing_key(), rabbit_framing:amqp_table()}]).
-spec(delete_queue_bindings/1 ::
diff --git a/src/rabbit_misc.erl b/src/rabbit_misc.erl
index cd6dbdd9..33c7d82e 100644
--- a/src/rabbit_misc.erl
+++ b/src/rabbit_misc.erl
@@ -80,10 +80,11 @@
explanation :: string(),
method :: atom()}).
-type(not_found() :: {'error', 'not_found'}).
+-type(resource_name() :: binary()).
-type(r(Kind) ::
#resource{virtual_host :: rabbit_framing:vhost(),
kind :: Kind,
- name :: rabbit_framing:resource_name()}).
+ name :: resource_name()}).
-spec(method_record_type/1 :: (tuple()) -> atom()).
-spec(polite_pause/0 :: () -> 'done').
@@ -99,15 +100,14 @@
-spec(get_config/2 :: (atom(), A) -> A).
-spec(set_config/2 :: (atom(), any()) -> 'ok').
-spec(dirty_read/1 :: ({atom(), any()}) -> {'ok', any()} | not_found()).
--spec(r/3 :: (rabbit_framing:vhost() | r(atom()), K,
- rabbit_framing:resource_name()) ->
- r(K) when is_subtype(K, atom())).
--spec(r/2 :: (rabbit_framing:vhost(), K)
- -> #resource{virtual_host :: rabbit_framing:vhost(),
+-spec(r/3 :: (rabbit:vhost() | r(atom()), K, resource_name())
+ -> r(K) when is_subtype(K, atom())).
+-spec(r/2 :: (rabbit:vhost(), K)
+ -> #resource{virtual_host :: rabbit:vhost(),
kind :: K,
name :: '_'}
when is_subtype(K, atom())).
--spec(r_arg/4 :: (rabbit_framing:vhost() | r(atom()), K,
+-spec(r_arg/4 :: (rabbit:vhost() | r(atom()), K,
rabbit_framing:amqp_table(), binary())
-> undefined | r(K) when is_subtype(K, atom())).
-spec(rs/1 :: (r(atom())) -> string()).
@@ -121,9 +121,9 @@
-spec(with_exit_handler/2 :: (rabbit:thunk(A), rabbit:thunk(A)) -> A).
-spec(filter_exit_map/2 :: (fun ((A) -> B), [A]) -> [B]).
-spec(with_user/2 :: (rabbit_access_control:username(), rabbit:thunk(A)) -> A).
--spec(with_vhost/2 :: (rabbit_framing:vhost(), rabbit:thunk(A)) -> A).
+-spec(with_vhost/2 :: (rabbit:vhost(), rabbit:thunk(A)) -> A).
-spec(with_user_and_vhost/3 :: (rabbit_access_control:username(),
- rabbit_framing:vhost(), rabbit:thunk(A)) -> A).
+ rabbit:vhost(), rabbit:thunk(A)) -> A).
-spec(execute_mnesia_transaction/1 :: (rabbit:thunk(A)) -> A).
-spec(ensure_ok/2 :: (ok_or_error(), atom()) -> 'ok').
-spec(makenode/1 :: ({string(), string()} | string()) -> rabbit:erlang_node()).