Skip to content

Commit

Permalink
Use the new -spec format
Browse files Browse the repository at this point in the history
The old format is removed in Erlang 19.0, leading to build errors.

Also, get rid of the `use_specs` macro and thus always define -spec() &
friends.

While here, unnify the style of -type and -spec.

References rabbitmq/rabbitmq-server#860.
[#118562897]
[#122335241]
  • Loading branch information
dumbbell authored and erszcz committed Sep 6, 2018
1 parent c41c705 commit d0bfc78
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 41 deletions.
19 changes: 8 additions & 11 deletions src/credit_flow.erl
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,19 @@

%%----------------------------------------------------------------------------

-ifdef(use_specs).

-export_type([bump_msg/0]).

-opaque(bump_msg() :: {pid(), non_neg_integer()}).
-type(credit_spec() :: {non_neg_integer(), non_neg_integer()}).

-spec(send/1 :: (pid()) -> 'ok').
-spec(send/2 :: (pid(), credit_spec()) -> 'ok').
-spec(ack/1 :: (pid()) -> 'ok').
-spec(ack/2 :: (pid(), credit_spec()) -> 'ok').
-spec(handle_bump_msg/1 :: (bump_msg()) -> 'ok').
-spec(blocked/0 :: () -> boolean()).
-spec(peer_down/1 :: (pid()) -> 'ok').

-endif.
-spec send
(pid()) -> 'ok';
(credit_spec()) -> 'ok'.
-spec ack(pid()) -> 'ok'.
-spec ack(pid(), credit_spec()) -> 'ok'.
-spec handle_bump_msg(bump_msg()) -> 'ok'.
-spec blocked() -> boolean().
-spec peer_down(pid()) -> 'ok'.

%%----------------------------------------------------------------------------

Expand Down
55 changes: 25 additions & 30 deletions src/rabbit_event.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,36 @@

%%----------------------------------------------------------------------------

-ifdef(use_specs).

-export_type([event_type/0, event_props/0, event_timestamp/0, event/0]).

-type(event_type() :: atom()).
-type(event_props() :: term()).
-type(event_timestamp() :: non_neg_integer()).
-type event_type() :: atom().
-type event_props() :: term().
-type event_timestamp() :: non_neg_integer().

-type(event() :: #event { type :: event_type(),
-type event() :: #event { type :: event_type(),
props :: event_props(),
reference :: 'none' | reference(),
timestamp :: event_timestamp() }).

-type(level() :: 'none' | 'coarse' | 'fine').

-type(timer_fun() :: fun (() -> 'ok')).
-type(container() :: tuple()).
-type(pos() :: non_neg_integer()).

-spec(start_link/0 :: () -> rabbit_types:ok_pid_or_error()).
-spec(init_stats_timer/2 :: (container(), pos()) -> container()).
-spec(init_disabled_stats_timer/2 :: (container(), pos()) -> container()).
-spec(ensure_stats_timer/3 :: (container(), pos(), term()) -> container()).
-spec(stop_stats_timer/2 :: (container(), pos()) -> container()).
-spec(reset_stats_timer/2 :: (container(), pos()) -> container()).
-spec(stats_level/2 :: (container(), pos()) -> level()).
-spec(if_enabled/3 :: (container(), pos(), timer_fun()) -> 'ok').
-spec(notify/2 :: (event_type(), event_props()) -> 'ok').
-spec(notify/3 :: (event_type(), event_props(), reference() | 'none') -> 'ok').
-spec(notify_if/3 :: (boolean(), event_type(), event_props()) -> 'ok').
-spec(sync_notify/2 :: (event_type(), event_props()) -> 'ok').
-spec(sync_notify/3 :: (event_type(), event_props(),
reference() | 'none') -> 'ok').

-endif.
timestamp :: event_timestamp() }.

-type level() :: 'none' | 'coarse' | 'fine'.

-type timer_fun() :: fun (() -> 'ok').
-type container() :: tuple().
-type pos() :: non_neg_integer().

-spec start_link() -> rabbit_types:ok_pid_or_error().
-spec init_stats_timer(container(), pos()) -> container().
-spec init_disabled_stats_timer(container(), pos()) -> container().
-spec ensure_stats_timer(container(), pos(), term()) -> container().
-spec stop_stats_timer(container(), pos()) -> container().
-spec reset_stats_timer(container(), pos()) -> container().
-spec stats_level(container(), pos()) -> level().
-spec if_enabled(container(), pos(), timer_fun()) -> 'ok'.
-spec notify(event_type(), event_props()) -> 'ok'.
-spec notify(event_type(), event_props(), reference() | 'none') -> 'ok'.
-spec notify_if(boolean(), event_type(), event_props()) -> 'ok'.
-spec sync_notify(event_type(), event_props()) -> 'ok'.
-spec sync_notify(event_type(), event_props(), reference() | 'none') -> 'ok'.

%%----------------------------------------------------------------------------

Expand Down

0 comments on commit d0bfc78

Please sign in to comment.