Skip to content
Browse files

move some types to riak_core

  • Loading branch information...
1 parent ae9ae41 commit da41938350d85472b2c592375128f294527af311 @argv0 argv0 committed May 13, 2011
Showing with 36 additions and 5 deletions.
  1. +31 −0 src/riak_core.erl
  2. +5 −5 src/riak_core_apl.erl
View
31 src/riak_core.erl
@@ -25,6 +25,37 @@
-export([add_guarded_event_handler/3, add_guarded_event_handler/4]).
-export([delete_guarded_event_handler/3]).
+-export_type([quorum_type/0,
+ symbolic_rw_val/0,
+ integer_rw_val/0,
+ n_val/0,
+ r_val/0,
+ w_val/0,
+ rw_val/0,
+ dw_val/0,
+ pw_val/0,
+ pr_val/0,
+ pos_quorum_val/0,
+ non_neg_quorum_val/0,
+ quorum_val/0]).
+
+-type quorum_type() :: r | w | rw | dw | pw | pr.
+-type symbolic_rw_val() :: one | quorum | all | default.
+-type pos_rw_val() :: pos_integer().
+-type non_neg_rw_val() :: non_neg_integer().
+-type integer_rw_val() :: pos_rw_val() | non_neg_rw_val().
+-type n_val() :: non_neg_rw_val().
+-type quorum_val_t(IntType) :: symbolic_rw_val() | IntType.
+-type pos_quorum_val() :: quorum_val_t(pos_rw_val()).
+-type non_neg_quorum_val() :: quorum_val_t(non_neg_rw_val()).
+-type r_val() :: non_neg_quorum_val().
+-type w_val() :: non_neg_quorum_val().
+-type rw_val() :: pos_quorum_val().
+-type dw_val() :: non_neg_quorum_val().
+-type pw_val() :: non_neg_quorum_val().
+-type pr_val() :: non_neg_quorum_val().
+-type quorum_val() :: pos_quorum_val() | non_neg_quorum_val().
+
%% @spec stop() -> ok
%% @doc Stop the riak application and the calling process.
stop() -> stop("riak stop requested").
View
10 src/riak_core_apl.erl
@@ -53,22 +53,22 @@ active_owners(Ring, UpNodes) ->
lists:reverse(Up).
%% Get the active preflist taking account of which nodes are up
--spec get_apl(chash:bin_index(), riak_client:n_val(), riak_core_node_watcher:service()) -> preflist().
+-spec get_apl(chash:bin_index(), riak_core:n_val(), riak_core_node_watcher:service()) -> preflist().
get_apl(DocIdx, N, Service) ->
{ok, Ring} = riak_core_ring_manager:get_my_ring(),
get_apl(DocIdx, N, Ring, riak_core_node_watcher:nodes(Service)).
%% Get the active preflist taking account of which nodes are up
%% for a given ring/upnodes list
--spec get_apl(chash:bin_index(), riak_client:n_val(), ring(), [chash:chash_node()]) -> preflist().
+-spec get_apl(chash:bin_index(), riak_core:n_val(), ring(), [chash:chash_node()]) -> preflist().
get_apl(DocIdx, N, Ring, UpNodes) ->
[{Partition, Node} || {{Partition, Node}, _Type} <-
get_apl_ann(DocIdx, N, Ring, UpNodes)].
%% Get the active preflist taking account of which nodes are up
%% for a given ring/upnodes list and annotate each node with type of
%% primary/fallback
--spec get_apl_ann(chash:bin_index(), riak_client:n_val(), ring(), [chash:chash_node()]) -> preflist2().
+-spec get_apl_ann(chash:bin_index(), riak_core:n_val(), ring(), [chash:chash_node()]) -> preflist2().
get_apl_ann(DocIdx, N, Ring, UpNodes) ->
UpNodes1 = ordsets:from_list(UpNodes),
Preflist = riak_core_ring:preflist(DocIdx, Ring),
@@ -77,13 +77,13 @@ get_apl_ann(DocIdx, N, Ring, UpNodes) ->
lists:reverse(Up) ++ find_fallbacks(Pangs, Fallbacks, UpNodes1, []).
%% Same as get_apl, but returns only the primaries.
--spec get_primary_apl(chash:bin_index(), riak_client:n_val(), riak_core_node_watcher:service()) -> preflist().
+-spec get_primary_apl(chash:bin_index(), riak_core:n_val(), riak_core_node_watcher:service()) -> preflist().
get_primary_apl(DocIdx, N, Service) ->
{ok, Ring} = riak_core_ring_manager:get_my_ring(),
get_primary_apl(DocIdx, N, Ring, riak_core_node_watcher:nodes(Service)).
%% Same as get_apl, but returns only the primaries.
--spec get_primary_apl(chash:bin_index(), riak_client:n_val(), ring(), [chash:chash_node()]) -> preflist().
+-spec get_primary_apl(chash:bin_index(), riak_core:n_val(), ring(), [chash:chash_node()]) -> preflist().
get_primary_apl(DocIdx, N, Ring, UpNodes) ->
UpNodes1 = ordsets:from_list(UpNodes),
Preflist = riak_core_ring:preflist(DocIdx, Ring),

0 comments on commit da41938

Please sign in to comment.
Something went wrong with that request. Please try again.