forked from cqerl/cqerl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cqerl.hrl
83 lines (68 loc) · 2.9 KB
/
cqerl.hrl
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
-define(CQERL_CONSISTENCY_ANY, 0).
-define(CQERL_CONSISTENCY_ONE, 1).
-define(CQERL_CONSISTENCY_TWO, 2).
-define(CQERL_CONSISTENCY_THREE, 3).
-define(CQERL_CONSISTENCY_QUORUM, 4).
-define(CQERL_CONSISTENCY_ALL, 5).
-define(CQERL_CONSISTENCY_LOCAL_QUORUM, 6).
-define(CQERL_CONSISTENCY_EACH_QUORUM, 7).
-define(CQERL_CONSISTENCY_SERIAL, 8).
-define(CQERL_CONSISTENCY_LOCAL_SERIAL, 9).
-define(CQERL_CONSISTENCY_LOCAL_ONE, 10).
-define(CQERL_BATCH_LOGGED, 0).
-define(CQERL_BATCH_UNLOGGED, 1).
-define(CQERL_BATCH_COUNTER, 2).
-define(CQERL_EVENT_TOPOLOGY_CHANGE, 'TOPOLOGY_CHANGE').
-define(CQERL_EVENT_STATUS_CHANGE, 'STATUS_CHANGE').
-define(CQERL_EVENT_SCHEMA_CHANGE, 'SCHEMA_CHANGE').
-define(CQERL_IS_CLIENT(Client),
is_tuple(Client) andalso
tuple_size(Client) == 2 andalso
is_pid(element(1, Client)) andalso
is_reference(element(2, Client))
).
-define(CQERL_PARSE_ADDR (Addr), case erlang:function_exported(inet, parse_address, 1) of
true -> inet:parse_address(Addr);
false -> inet_parse:address(Addr)
end).
-type consistency_level() :: ?CQERL_CONSISTENCY_ANY .. ?CQERL_CONSISTENCY_LOCAL_ONE.
-type column_type() ::
{custom, binary()} |
{map, column_type(), column_type()} |
{set | list, column_type()} | datatype().
-type datatype() :: ascii | bigint | blob | boolean | counter | decimal | double |
float | int | timestamp | uuid | varchat | varint | timeuuid | inet.
-type parameter_val() :: number() | binary() | list() | atom().
-type parameter() :: { datatype(), parameter_val() }.
-type named_parameter() :: { atom(), parameter_val() }.
-record(cql_query, {
statement = <<>> :: binary(),
values = [] :: [ parameter() | named_parameter() ],
reusable = undefined :: undefined | boolean(),
named = false :: boolean(),
page_size = 100 :: integer(),
page_state :: binary() | undefined,
consistency = ?CQERL_CONSISTENCY_ONE :: consistency_level(),
serial_consistency = undefined :: ?CQERL_CONSISTENCY_SERIAL | ?CQERL_CONSISTENCY_LOCAL_SERIAL | undefined
}).
-record(cql_call, {
type :: sync | async,
caller :: {pid(), reference()},
client :: reference()
}).
-record(cql_query_batch, {
consistency = ?CQERL_CONSISTENCY_ONE :: ?CQERL_CONSISTENCY_ANY .. ?CQERL_CONSISTENCY_LOCAL_SERIAL,
mode = ?CQERL_BATCH_LOGGED :: ?CQERL_BATCH_LOGGED .. ?CQERL_BATCH_COUNTER,
queries = [] :: list(tuple())
}).
-record(cql_result, {
columns = [] :: list(tuple()),
dataset = [] :: list(list(term())),
cql_query :: #cql_query{},
client :: {pid(), reference()}
}).
-record(cql_schema_changed, {
change_type :: created | updated | dropped,
keyspace :: binary(),
table :: binary()
}).