diff --git a/rebar.config b/rebar.config index e49632a..8256094 100644 --- a/rebar.config +++ b/rebar.config @@ -1,12 +1,15 @@ {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)", []}]}. @@ -14,12 +17,12 @@ {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"}} ]}. diff --git a/rebar.config.script b/rebar.config.script deleted file mode 100644 index 58f42a8..0000000 --- a/rebar.config.script +++ /dev/null @@ -1,12 +0,0 @@ -case erlang:system_info(otp_release) < "R16" of - true -> - CONFIG; - false -> - HashDefine = [{d,new_hash}], - case lists:keysearch(erl_opts, 1, CONFIG) of - {value, {erl_opts, Opts}} -> - lists:keyreplace(erl_opts,1,CONFIG,{erl_opts,Opts++HashDefine}); - false -> - CONFIG ++ [{erl_opts, HashDefine}] - end -end. diff --git a/src/stanchion_utils.erl b/src/stanchion_utils.erl index c868ca4..0a7f7b8 100644 --- a/src/stanchion_utils.erl +++ b/src/stanchion_utils.erl @@ -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 %% =================================================================== @@ -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}) -> @@ -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), @@ -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 @@ -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