anchor.diff:           get_bucket/1,
            get_buckets/0,
            get_buckets/1,
  +         min_live_copies/1,
            ram_quota/1,
            raw_ram_quota/1,
            num_replicas/1,
  
positive.code: -module(ns_bucket).
  
  -include("ns_common.hrl").
  
  %% API
  -export([config/1,
  
negative.code:             X
      end.
  
  -spec min_live_copies(string()) -> non_neg_integer() | undefined.
  min_live_copies(Bucket) ->
      case get_bucket(Bucket) of
          {ok, Config} ->
              min_live_copies(ns_node_disco:nodes_actual_proper(), Config);
          _ ->
              undefined
      end.
  
  %% @doc Separate out the guts of can_fail_over to make it testable.
  -spec min_live_copies([node()], list()) -> non_neg_integer() | undefined.
  min_live_copies(LiveNodes, Config) ->
      case proplists:get_value(map, Config) of
          undefined -> undefined;
          Map ->
              lists:foldl(
                fun (Chain, Min) ->
                        NumLiveCopies =
                            lists:foldl(
                              fun (Node, Acc) ->
                                      case lists:member(Node, LiveNodes) of
                                          true -> Acc + 1;
                                          false -> Acc
                                      end
                              end, 0, Chain),
                        erlang:min(Min, NumLiveCopies)
                end, length(hd(Map)), Map)
      end.
  
  -spec num_replicas([{_,_}]) -> integer().
  num_replicas(Bucket) ->
      case proplists:get_value(num_replicas, Bucket) of
  