Skip to content

Commit

Permalink
Add ability to get all bucket props
Browse files Browse the repository at this point in the history
It's useful to be able to get all the bucket properties in one go.
This is used by repair to get the `n_val` for all buckets.
  • Loading branch information
rzezeski committed Jun 12, 2012
1 parent 036e409 commit 5ea116a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/riak_core_bucket.erl
Expand Up @@ -29,7 +29,10 @@
set_bucket/2, set_bucket/2,
get_bucket/1, get_bucket/1,
get_bucket/2, get_bucket/2,
merge_props/2]). get_buckets/1,
merge_props/2,
name/1,
n_val/1]).


-ifdef(TEST). -ifdef(TEST).
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
Expand Down Expand Up @@ -107,6 +110,14 @@ get_bucket(Name, Ring) ->
{ok, Bucket} -> Bucket {ok, Bucket} -> Bucket
end. end.


%% @doc Get bucket properties `Props' for all the buckets in the given
%% `Ring'
-spec get_buckets(riak_core_ring:riak_core_ring()) ->
Props::list().
get_buckets(Ring) ->
Names = riak_core_ring:get_buckets(Ring),
[get_bucket(Name, Ring) || Name <- Names].

%% @private %% @private
-spec validate_props(BucketProps::list({PropName::atom(), Value::any()}), -spec validate_props(BucketProps::list({PropName::atom(), Value::any()}),
Validators::list(module()), Validators::list(module()),
Expand All @@ -121,6 +132,12 @@ validate_props(BucketProps0, [{_App, Validator}|T], Errors0) ->
{BucketProps, Errors} = Validator:validate(BucketProps0), {BucketProps, Errors} = Validator:validate(BucketProps0),
validate_props(BucketProps, T, lists:flatten([Errors|Errors0])). validate_props(BucketProps, T, lists:flatten([Errors|Errors0])).


name(BProps) ->
proplists:get_value(name, BProps).

n_val(BProps) ->
proplists:get_value(n_val, BProps).

%% =================================================================== %% ===================================================================
%% EUnit tests %% EUnit tests
%% =================================================================== %% ===================================================================
Expand Down

0 comments on commit 5ea116a

Please sign in to comment.