Skip to content

Commit

Permalink
remove lager
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgo committed Jan 2, 2013
1 parent fbabdf2 commit 21cf40a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
6 changes: 2 additions & 4 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
{lib_dirs, ["deps"]}.

{deps, [
{lager, ".*", {git, "git://github.com/basho/lager.git", {branch, "master"}}},
{jsx, ".*", {git, "git://github.com/talentdeficit/jsx.git", {branch, "master"}}},
{ibrowse, "", {git, "git://github.com/cmullaparthi/ibrowse.git", {branch, "master"}}},
{mochiweb, "1.5.1", {git, "git://github.com/basho/mochiweb",
Expand All @@ -15,9 +14,8 @@

{erl_opts, [
fail_on_warning,
debug_info,
%%warn_missing_spec,
{parse_transform, lager_transform}
debug_info
%%warn_missing_spec
]}.

{cover_enabled, true}.
Expand Down
1 change: 0 additions & 1 deletion src/ddb.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
{applications, [
kernel,
stdlib,
lager,
crypto,
ssl,
ibrowse
Expand Down
2 changes: 1 addition & 1 deletion src/ddb.erl
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ update_action('delete') -> <<"DELETE">>.

request(Target, JSON) ->
Body = jsx:term_to_json(JSON),
ok = lager:debug("REQUEST BODY ~n~p", [Body]),
%%ok = lager:debug("REQUEST BODY ~n~p", [Body]),
Headers = headers(Target, Body),
Opts = [{'response_format', 'binary'}],
F = fun() -> ibrowse:send_req(?DDB_ENDPOINT, [{'Content-type', ?CONTENT_TYPE} | Headers], 'post', Body, Opts) end,
Expand Down
20 changes: 10 additions & 10 deletions src/ddb_aws.erl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ retry(F, Max, H)

retry(_, Max, N, _)
when Max == N ->
ok = lager:error("Maximum retries (~p) reached, aborting...", [Max]),
%%ok = lager:error("Maximum retries (~p) reached, aborting...", [Max]),
{'error', 'maximum_retries_reached'};

retry(F, Max, N, H)
Expand All @@ -53,34 +53,34 @@ retry(F, Max, N, H)
{ok, Code, _, Body} when Code >= "400" andalso Code < "500" ->
case jsx:is_json(Body) of
false ->
ok = lager:error("Got client error (~s) ~p, aborting...", [Code, Body]),
%%ok = lager:error("Got client error (~s) ~p, aborting...", [Code, Body]),
{'error', H(Body)};
true ->
JSON = jsx:json_to_term(Body),
case proplists:get_value(<<"__type">>, JSON) of
<<"com.amazonaws.dynamodb.v20111205#ProvisionedThroughputExceededException">> ->
ok = lager:warning("Got client error (~s) ~p, retrying...", [Code, Body]),
%%ok = lager:warning("Got client error (~s) ~p, retrying...", [Code, Body]),
retry(F, Max, N + 1, H);
<<"com.amazonaws.dynamodb.v20111205#ThrottlingException">> ->
ok = lager:warning("Got client error (~s) ~p, retrying...", [Code, Body]),
%%ok = lager:warning("Got client error (~s) ~p, retrying...", [Code, Body]),
retry(F, Max, N + 1, H);
<<"com.amazon.coral.service#ExpiredTokenException">> ->
ok = lager:warning("Got client error (~s) ~p, expired token...", [Code, Body]),
%%ok = lager:warning("Got client error (~s) ~p, expired token...", [Code, Body]),
{'error', 'expired_token'};
<<"com.amazonaws.dynamodb.v20111205#ConditionalCheckFailedException">> ->
%% This is expected in some use cases, so just trace at info level
ok = lager:info("Got client error (~s) ~p, aborting...", [Code, Body]),
%%ok = lager:info("Got client error (~s) ~p, aborting...", [Code, Body]),
{'error', H(Body)};
_ ->
ok = lager:error("Got client error (~s) ~p, aborting...", [Code, Body]),
%%ok = lager:error("Got client error (~s) ~p, aborting...", [Code, Body]),
{'error', H(Body)}
end
end;
{'ok', Code, _, Body} ->
ok = lager:warning("Unexpected response (~s) ~p, retrying...", [Code, Body]),
%%ok = lager:warning("Unexpected response (~s) ~p, retrying...", [Code, Body]),
retry(F, Max, N + 1, H);
{'error', Error} ->
ok = lager:debug("Got ~p retrying...", [Error]),
%%ok = lager:debug("Got ~p retrying...", [Error]),
retry(F, Max, N + 1, H)
end.

Expand All @@ -91,7 +91,7 @@ backoff(Attempts)
when is_integer(Attempts) ->
%% attempt exponential backoff
Delay = round(crypto:rand_uniform(1, 101) * math:pow(4, Attempts)),
ok = lager:debug("Waiting ~bms before retrying", [Delay]),
%%ok = lager:debug("Waiting ~bms before retrying", [Delay]),
timer:sleep(Delay).

-spec timestamp() -> string().
Expand Down

0 comments on commit 21cf40a

Please sign in to comment.