Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTP 17 compatibility #104

Merged
merged 4 commits into from
Sep 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
{sub_dirs, ["rel"]}.

{require_otp_vsn, "R14B0[234]|R15|R16"}.
{require_otp_vsn, "R16|17"}.

{cover_enabled, true}.

{lib_dirs, ["deps", "apps"]}.

{erl_opts, [debug_info, warnings_as_errors, {parse_transform, lager_transform}]}.
{erl_opts, [debug_info,
warnings_as_errors,
{parse_transform, lager_transform},
{platform_define, "^[0-9]+", namespaced_types}]}.

{xref_checks, []}.
{xref_queries, [{"(XC - UC) || (XU - X - B)", []}]}.

{reset_after_eunit, true}.

{deps, [
{lager, ".*", {git, "git://github.com/basho/lager", {tag, "2.2.0"}}},
{lager_syslog, ".*", {git, "git://github.com/basho/lager_syslog", {tag, "2.1.1"}}},
{cuttlefish, ".*", {git, "git://github.com/basho/cuttlefish", {tag, "2.0.4"}}},
{node_package, ".*", {git, "git://github.com/basho/node_package", {tag, "2.0.3"}}},
{webmachine, "1.10.*", {git, "git://github.com/basho/webmachine", {tag, "1.10.8"}}},
{riakc, ".*", {git, "git://github.com/basho/riak-erlang-client", {tag, "2.1.1"}}},
{lager, ".*", {git, "git://github.com/basho/lager", {tag, "2.1.1"}}},
{lager_syslog, ".*", {git, "git://github.com/basho/lager_syslog", {tag, "2.1.1"}}},
{exometer_core, ".*", {git, "git://github.com/Feuerlabs/exometer_core", {tag, "1.2"}}},
{eper, ".*", {git, "git://github.com/basho/eper.git", "0.92-basho1"}}
]}.
12 changes: 0 additions & 12 deletions rebar.config.script

This file was deleted.

41 changes: 20 additions & 21 deletions src/stanchion_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@
-type bucket_op_options() :: [bucket_op_option()].
-type bucket_op_option() :: {acl, acl()} | {policy, binary()} | delete_policy | {bag, binary()}.

-ifdef(namespaced_types).
-type dictionary() :: dict:dict().
-else.
-type dictionary() :: dict().
-endif.

%% ===================================================================
%% Public API
%% ===================================================================
Expand Down Expand Up @@ -199,7 +205,7 @@ get_manifests(RiakcPid, Bucket, Key) ->
end.

%% @doc Determine if a set of contents of a riak object has a tombstone.
-spec has_tombstone({dict(), binary()}) -> boolean().
-spec has_tombstone({dictionary(), binary()}) -> boolean().
has_tombstone({_, <<>>}) ->
true;
has_tombstone({MD, _V}) ->
Expand Down Expand Up @@ -257,7 +263,7 @@ put_bucket(BucketObj, OwnerId, Opts, RiakPid) ->
stanchion_stats:update([riakc, put_cs_bucket], TAT),
Result.

-spec make_new_metadata(dict(), bucket_op_options()) -> dict().
-spec make_new_metadata(dictionary(), bucket_op_options()) -> dictionary().
make_new_metadata(MD, Opts) ->
MetaVals = dict:fetch(?MD_USERMETA, MD),
UserMetaData = make_new_user_metadata(MetaVals, Opts),
Expand Down Expand Up @@ -386,20 +392,11 @@ update_user(KeyId, UserFields) ->
end.


-ifdef(new_hash).
sha_mac(KeyData, STS) ->
crypto:hmac(sha, KeyData, STS).

md5(Bin) ->
crypto:hash(md5, Bin).
-else.
sha_mac(KeyData, STS) ->
crypto:sha_mac(KeyData, STS).

md5(Bin) ->
crypto:md5(Bin).
-endif.


%% ===================================================================
%% Internal functions
Expand Down Expand Up @@ -815,16 +812,18 @@ fetch_user(Key, RiakPid) ->
{ok, Obj} ->
{ok, {Obj, true}};
{error, _} ->
WeakOptions = [{r, quorum}, {pr, one}, {notfound_ok, false}],

{Res1, TAT1} = ?TURNAROUND_TIME(riakc_pb_socket:get(RiakPid, ?USER_BUCKET, Key, WeakOptions)),
stanchion_stats:update([riakc, get_user], TAT1),
case Res1 of
{ok, Obj} ->
{ok, {Obj, false}};
{error, Reason} ->
{error, Reason}
end
weak_fetch_user(Key, RiakPid)
end.

weak_fetch_user(Key, RiakPid) ->
WeakOptions = [{r, quorum}, {pr, one}, {notfound_ok, false}],
{Res, TAT} = ?TURNAROUND_TIME(riakc_pb_socket:get(RiakPid, ?USER_BUCKET, Key, WeakOptions)),
stanchion_stats:update([riakc, get_user], TAT),
case Res of
{ok, Obj} ->
{ok, {Obj, false}};
{error, Reason} ->
{error, Reason}
end.

%% @doc Resolve the set of buckets for a user when
Expand Down