summaryrefslogtreecommitdiff
path: root/src/mem3/include/mem3.hrl
blob: d97b25469626b3698e9a12afc726840231642fca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
% Licensed under the Apache License, Version 2.0 (the "License"); you may not
% use this file except in compliance with the License. You may obtain a copy of
% the License at
%
%   http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
% WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
% License for the specific language governing permissions and limitations under
% the License.


% The last element in the ring
-define(RING_END, 2 bsl 31 - 1).


% type specification hacked to suppress dialyzer warning re: match spec
-record(shard, {
    name :: binary() | '_' | 'undefined',
    node :: node() | '_' | 'undefined',
    dbname :: binary() | 'undefined',
    range :: [non_neg_integer() | '$1' | '$2'] | '_' | 'undefined',
    ref :: reference() | '_' | 'undefined',
    opts :: list() | 'undefined'
}).

%% Do not reference outside of mem3.
-record(ordered_shard, {
    name :: binary() | '_',
    node :: node() | '_',
    dbname :: binary(),
    range :: [non_neg_integer() | '$1' | '$2'] | '_',
    ref :: reference() | 'undefined' | '_',
    order :: non_neg_integer() | 'undefined' | '_',
    opts :: list()
}).

%% types
-type join_type() :: init | join | replace | leave.
-type join_order() :: non_neg_integer().
-type options() :: list().
-type mem_node() :: {join_order(), node(), options()}.
-type mem_node_list() :: [mem_node()].
-type arg_options() :: {test, boolean()}.
-type args() :: [] | [arg_options()].
-type test() :: undefined | node().
-type epoch() :: float().
-type clock() :: {node(), epoch()}.
-type vector_clock() :: [clock()].
-type ping_node() :: node() | nil.
-type gossip_fun() :: call | cast.

-type part() :: #shard{}.
-type fullmap() :: [part()].
-type ref_part_map() :: {reference(), part()}.
-type tref() :: reference().
-type np() :: {node(), part()}.
-type beg_acc() :: [integer()].