Skip to content

Commit

Permalink
KAZOO-4394: more updated specs/types/deprecated functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesaimonetti authored and fenollp committed Jan 20, 2016
1 parent 26a6219 commit 71175a1
Show file tree
Hide file tree
Showing 20 changed files with 73 additions and 47 deletions.
2 changes: 1 addition & 1 deletion core/whistle-1.0.0/src/wh_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ now_s(_) -> erlang:system_time('seconds').
now_ms(_) -> erlang:system_time('milli_seconds').
now_us(_) -> erlang:system_time('micro_seconds').
-else.
now() -> erlang:now().
now() -> erlang:timestamp().
-spec now_s(wh_now()) -> gregorian_seconds().
-spec now_ms(wh_now()) -> pos_integer().
-spec now_us(wh_now()) -> pos_integer().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ terminate(_Reason, _Req, _State) ->
ok.

id() ->
{Mega, Sec, Micro} = erlang:now(),
{Mega, Sec, Micro} = erlang:timestamp(),
Id = (Mega * 1000000 + Sec) * 1000000 + Micro,
integer_to_list(Id, 16).
2 changes: 1 addition & 1 deletion deps/exmpp-0.9.9/src/core/exmpp_jid.erl
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ as_binary(V) when is_list(V) ->
-spec(generate_resource/0 :: () -> string()).

generate_resource() ->
{A, B, C} = erlang:now(),
{A, B, C} = erlang:timestamp(),
lists:flatten(["exmpp#",
integer_to_list(A),
integer_to_list(B),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ handle_DATA(_From, _To, <<>>, State) ->
{error, "552 Message too small", State};
handle_DATA(From, To, Data, State) ->
% some kind of unique id
Reference = lists:flatten([io_lib:format("~2.16.0b", [X]) || <<X>> <= erlang:md5(term_to_binary(erlang:now()))]),
Reference = lists:flatten([io_lib:format("~2.16.0b", [X]) || <<X>> <= erlang:md5(term_to_binary(erlang:timestamp()))]),
% if RELAY is true, then relay email to email address, else send email data to console
case proplists:get_value(relay, State#state.options, false) of
true -> relay(From, To, Data);
Expand Down
2 changes: 1 addition & 1 deletion deps/gproc-0.2.12/patches/stdlib/supervisor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ add_restart(State) ->
I = State#state.intensity,
P = State#state.period,
R = State#state.restarts,
Now = erlang:now(),
Now = erlang:timestamp(),
R1 = add_restart([Now|R], Now, P),
State1 = State#state{restarts = R1},
case length(R1) of
Expand Down
4 changes: 2 additions & 2 deletions deps/mustache-d0246fe/benchmarks/bench.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ run() ->
Ctx1 = dict:store(item, [A, B, C], Ctx0),
% Ctx1 = dict:new(),
CT = mustache:compile(complex, "../examples/complex.mustache"),
T0 = erlang:now(),
T0 = erlang:timestamp(),
render(CT, Ctx1, ?COUNT),
T1 = erlang:now(),
T1 = erlang:timestamp(),
Diff = timer:now_diff(T1, T0),
Mean = Diff / ?COUNT,
io:format("~nTotal time: ~.2fs~n", [Diff / 1000000]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ t30() -> t30([]).
t30(Heading) ->
F = fun() ->
sleep(),
{_,_,Tno} = erlang:now(),
{_,_,Tno} = erlang:timestamp(),
Stno = integer_to_list(Tno),
Desc = "LDAP hacker " ++ Stno,
line(),
Expand All @@ -252,7 +252,7 @@ t31() -> t31([]).
t31(Heading) ->
F = fun() ->
sleep(),
{_,_,Tno} = erlang:now(),
{_,_,Tno} = erlang:timestamp(),
line(),
heading(Heading,
"=== TEST 31 (delete 'description' attribute)~n"),
Expand All @@ -273,7 +273,7 @@ t40() -> t40([]).
t40(Heading) ->
F = fun() ->
sleep(),
{_,_,Tno} = erlang:now(),
{_,_,Tno} = erlang:timestamp(),
line(),
heading(Heading,
"=== TEST 40 (add entry 'Bill Valentine')~n"),
Expand All @@ -297,7 +297,7 @@ t41() -> t41([]).
t41(Heading) ->
F = fun() ->
sleep(),
{_,_,Tno} = erlang:now(),
{_,_,Tno} = erlang:timestamp(),
line(),
heading(Heading,
"=== TEST 41 (delete entry 'Bill Valentine')~n"),
Expand All @@ -317,7 +317,7 @@ t50() -> t50([]).
t50(Heading) ->
F = fun() ->
sleep(),
{_,_,Tno} = erlang:now(),
{_,_,Tno} = erlang:timestamp(),
line(),
heading(Heading,
"=== TEST 50 (modify DN to: 'Torbjorn M.Tornkvist')~n"),
Expand All @@ -341,7 +341,7 @@ t51() -> t51([]).
t51(Heading) ->
F = fun() ->
sleep(),
{_,_,Tno} = erlang:now(),
{_,_,Tno} = erlang:timestamp(),
line(),
heading(Heading,
"=== TEST 51 (modify DN, remove the RDN attribute)~n"),
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbitmq_server-3.5.5/src/credit_flow.erl
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ state() -> case blocked() of
true -> flow;
false -> case get(credit_blocked_at) of
undefined -> running;
B -> Diff = timer:now_diff(erlang:now(), B),
B -> Diff = timer:now_diff(erlang:timestamp(), B),
case Diff < ?STATE_CHANGE_INTERVAL of
true -> flow;
false -> running
Expand Down Expand Up @@ -161,7 +161,7 @@ grant(To, Quantity) ->

block(From) ->
case blocked() of
false -> put(credit_blocked_at, erlang:now());
false -> put(credit_blocked_at, erlang:timestamp());
true -> ok
end,
?UPDATE(credit_blocked, [], Blocks, [From | Blocks]).
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbitmq_server-3.5.5/src/pg2_fixed.erl
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,14 @@ get_closest_pid(Name) ->
[Pid] ->
Pid;
[] ->
{_,_,X} = erlang:now(),
{_,_,X} = erlang:timestamp(),
case get_members(Name) of
[] -> {error, {no_process, Name}};
Members ->
lists:nth((X rem length(Members))+1, Members)
end;
Members when is_list(Members) ->
{_,_,X} = erlang:now(),
{_,_,X} = erlang:timestamp(),
lists:nth((X rem length(Members))+1, Members);
Else ->
Else
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbitmq_server-3.5.5/src/rabbit.erl
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ hipe_compile() ->
Count = length(HipeModules),
io:format("~nHiPE compiling: |~s|~n |",
[string:copies("-", Count)]),
T1 = erlang:now(),
T1 = erlang:timestamp(),
PidMRefs = [spawn_monitor(fun () -> [begin
{ok, M} = hipe:c(M, [o3]),
io:format("#")
Expand All @@ -291,7 +291,7 @@ hipe_compile() ->
{'DOWN', MRef, process, _, normal} -> ok;
{'DOWN', MRef, process, _, Reason} -> exit(Reason)
end || {_Pid, MRef} <- PidMRefs],
T2 = erlang:now(),
T2 = erlang:timestamp(),
Duration = timer:now_diff(T2, T1) div 1000000,
io:format("|~n~nCompiled ~B modules in ~Bs~n", [Count, Duration]),
{ok, Count, Duration}.
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_server-3.5.5/src/rabbit_guid.erl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ update_disk_serial() ->

%% Generate an un-hashed guid.
fresh() ->
%% We don't use erlang:now() here because a) it may return
%% We don't use erlang:timestamp() here because a) it may return
%% duplicates when the system clock has been rewound prior to a
%% restart, or ids were generated at a high rate (which causes
%% now() to move ahead of the system time), and b) it is really
Expand Down
6 changes: 3 additions & 3 deletions deps/rabbitmq_server-3.5.5/src/rabbit_mirror_queue_sync.erl
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,18 @@ master_go(Syncer, Ref, Log, HandleInfo, EmitStats, BQ, BQS) ->
master_go0(Args, BQ, BQS) ->
case BQ:fold(fun (Msg, MsgProps, Unacked, Acc) ->
master_send(Msg, MsgProps, Unacked, Args, Acc)
end, {0, erlang:now()}, BQS) of
end, {0, erlang:timestamp()}, BQS) of
{{shutdown, Reason}, BQS1} -> {shutdown, Reason, BQS1};
{{sync_died, Reason}, BQS1} -> {sync_died, Reason, BQS1};
{_, BQS1} -> master_done(Args, BQS1)
end.

master_send(Msg, MsgProps, Unacked,
{Syncer, Ref, Log, HandleInfo, EmitStats, Parent}, {I, Last}) ->
T = case timer:now_diff(erlang:now(), Last) > ?SYNC_PROGRESS_INTERVAL of
T = case timer:now_diff(erlang:timestamp(), Last) > ?SYNC_PROGRESS_INTERVAL of
true -> EmitStats({syncing, I}),
Log("~p messages", [I]),
erlang:now();
erlang:timestamp();
false -> Last
end,
HandleInfo({syncing, I}),
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_server-3.5.5/src/rabbit_node_monitor.erl
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ find_blocked_global_peers() ->
find_blocked_global_peers1(Dict).

find_blocked_global_peers1([{{sync_tag_his, Peer}, Timestamp} | Rest]) ->
Diff = timer:now_diff(erlang:now(), Timestamp),
Diff = timer:now_diff(erlang:timestamp(), Timestamp),
if
Diff >= 10000 -> unblock_global_peer(Peer);
true -> ok
Expand Down
4 changes: 2 additions & 2 deletions deps/rabbitmq_server-3.5.5/src/rabbit_reader.erl
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ maybe_block(State = #v1{connection_state = blocking,
State1 = State#v1{connection_state = blocked,
throttle = update_last_blocked_by(
Throttle#throttle{
last_blocked_at = erlang:now()})},
last_blocked_at = erlang:timestamp()})},
case {blocked_by_alarm(State), blocked_by_alarm(State1)} of
{false, true} -> ok = send_blocked(State1);
{_, _} -> ok
Expand Down Expand Up @@ -1201,7 +1201,7 @@ i(state, #v1{connection_state = ConnectionState,
(credit_flow:blocked() %% throttled by flow now
orelse %% throttled by flow recently
(WasBlockedBy =:= flow andalso T =/= never andalso
timer:now_diff(erlang:now(), T) < 5000000)) of
timer:now_diff(erlang:timestamp(), T) < 5000000)) of
true -> flow;
false -> ConnectionState
end;
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_server-3.5.5/src/rabbit_variable_queue.erl
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ update_rates(State = #vqstate{ in_counter = InCount,
ack_in = AckInRate,
ack_out = AckOutRate,
timestamp = TS }}) ->
Now = erlang:now(),
Now = erlang:timestamp(),

Rates = #rates { in = update_rate(Now, TS, InCount, InRate),
out = update_rate(Now, TS, OutCount, OutRate),
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_server-3.5.5/src/ssl_compat.erl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

-module(ssl_compat).

%% We don't want warnings about the use of erlang:now/0 in
%% We don't want warnings about the use of erlang:timestamp/0 in
%% this module.
-compile(nowarn_deprecated_function).

Expand Down
6 changes: 3 additions & 3 deletions deps/rabbitmq_server-3.5.5/src/supervisor2.erl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
-record(state, {name,
strategy :: strategy(),
children = [] :: [child_rec()],
dynamics :: ?DICT:?DICT() | ?SETS:?SET(),
dynamics :: ?DICT:dict:dict() | ?SETS:sets:set(),
intensity :: non_neg_integer(),
period :: pos_integer(),
restarts = [],
Expand Down Expand Up @@ -1123,7 +1123,7 @@ monitor_child(Pid) ->
%%-----------------------------------------------------------------
%% Func: terminate_dynamic_children/3
%% Args: Child = child_rec()
%% Dynamics = ?DICT() | ?SET()
%% Dynamics = dict:dict() | sets:set()
%% SupName = {local, atom()} | {global, atom()} | {pid(),Mod}
%% Returns: ok
%%
Expand Down Expand Up @@ -1492,7 +1492,7 @@ add_restart(State) ->
I = State#state.intensity,
P = State#state.period,
R = State#state.restarts,
Now = erlang:now(),
Now = erlang:timestamp(),
R1 = add_restart([Now|R], Now, P),
State1 = State#state{restarts = R1},
case length(R1) of
Expand Down
10 changes: 5 additions & 5 deletions deps/rabbitmq_server-3.5.5/src/time_compat.erl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

-module(time_compat).

%% We don't want warnings about the use of erlang:now/0 in
%% We don't want warnings about the use of erlang:timestamp/0 in
%% this module.
-compile(nowarn_deprecated_function).
%%
Expand Down Expand Up @@ -177,15 +177,15 @@ timestamp() ->
erlang:timestamp()
catch
error:undef ->
erlang:now()
erlang:timestamp()
end.

unique_integer() ->
try
erlang:unique_integer()
catch
error:undef ->
{MS, S, US} = erlang:now(),
{MS, S, US} = erlang:timestamp(),
(MS*1000000+S)*1000000+US
end.

Expand All @@ -202,7 +202,7 @@ unique_integer(Modifiers) ->
%% fullfill the requirements of
%% all modifiers: unique, positive,
%% and monotonic...
{MS, S, US} = erlang:now(),
{MS, S, US} = erlang:timestamp(),
(MS*1000000+S)*1000000+US;
false ->
erlang:error(badarg, [Modifiers])
Expand Down Expand Up @@ -280,7 +280,7 @@ integer_time_unit(I) when is_integer(I), I > 0 -> I;
integer_time_unit(BadRes) -> erlang:error(bad_time_unit, [BadRes]).

erlang_system_time_fallback() ->
{MS, S, US} = erlang:now(),
{MS, S, US} = erlang:timestamp(),
(MS*1000000+S)*1000000+US.

os_system_time_fallback() ->
Expand Down
6 changes: 3 additions & 3 deletions deps/socketio-0.1.0/stress/src/stress_client.erl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ get_sid(go, State = #state{url = Url}) ->

ready(poll, State = #state{transport_url = TransportUrl}) ->
%% TODO Run request timeout == session timeout because we cannot detect async request termination
StartPollTS = erlang:now(),
StartPollTS = erlang:timestamp(),
case ibrowse:send_req(TransportUrl, [], get, [], [{stream_to, self()}]) of
{ibrowse_req_id, _ReqId} ->
{next_state, wait_polling_result, State#state{start_poll_ts = StartPollTS}};
Expand All @@ -88,11 +88,11 @@ wait_polling_result(Event, State) ->
{next_state, Event, State}.

polling_result_ready(go, State = #state{sid = Sid, body = "1::", connected = false, start_poll_ts = StartPollTS}) ->
log_polling_req(Sid, StartPollTS, erlang:now()),
log_polling_req(Sid, StartPollTS, erlang:timestamp()),
send_test_packets(State#state{connected = true});

polling_result_ready(go, State = #state{sid = Sid, body = Body, send_packets = PrevPackets, connected = true, start_poll_ts = StartPollTS}) ->
log_polling_req(Sid, StartPollTS, erlang:now()),
log_polling_req(Sid, StartPollTS, erlang:timestamp()),
Packets = socketio_data_protocol:decode(list_to_binary(Body)),
case Packets of
PrevPackets ->
Expand Down
42 changes: 34 additions & 8 deletions scripts/update-the-types.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,31 @@ pushd `dirname $0` > /dev/null

ROOT=`pwd -P`/..

EXCLUDES="merl.erl"

echo "Looking at $ROOT"

function SaRF {
SEARCH=$1
REPLACE=$2
FILE=$3
PREFIX=$4

case ${FILE##*.} in
erl )
sed -i "s/$PREFIX$SEARCH/$PREFIX$REPLACE/g" $FILE ;;
hrl )
sed -i "s/$PREFIX$SEARCH/$PREFIX$REPLACE/g" $FILE ;;
esac
}

function SaR {
SEARCH=$1
REPLACE=$2

for PREFIX in " " "("; do
for FILE in `grep -lr "$PREFIX$SEARCH" $ROOT/{core,applications,deps}`; do
case ${FILE##*.} in
erl )
sed -i "s/$PREFIX$SEARCH/$PREFIX$REPLACE/g" $FILE ;;
hrl )
sed -i "s/$PREFIX$SEARCH/$PREFIX$REPLACE/g" $FILE ;;
esac
for PREFIX in " " "(" "{" "="; do
for FILE in `grep -lr "$PREFIX$SEARCH" $ROOT/{core,applications,deps} --exclude=$EXCLUDES`; do
SaRF $SEARCH $REPLACE $FILE $PREFIX
done
done
}
Expand Down Expand Up @@ -46,4 +57,19 @@ SaR "tree()" "trees:tree()"
echo "replacing set()"
SaR "set()" "sets:set()"

echo "replacing erlang:now()"
SaR "erlang:now" "erlang:timestamp"

echo "replacing RabbitMQ ?QUEUE()"
SaR "?QUEUE()" "queue:queue()"

echo "replacing RabbitMQ ?DICT()"
SaR "?DICT()" "dict:dict()"

echo "replacing RabbitMQ ?SET()"
SaR "?SET()" "sets:set()"

echo "replacing apns Queue::queue()"
SaRF "Queue::queue()" "Queue::queue:queue()" "$ROOT/applications/pusher/lib/apns/src/apns_queue.erl" ""

popd > /dev/null

0 comments on commit 71175a1

Please sign in to comment.