|
| 1 | +%% Two ways of specifying configuration parameters, designed for high concurrency. |
1 | 2 | -type config_type() :: {config_mod, module()} |
2 | 3 | | {vbisect, vbisect:bindict()}. |
3 | 4 |
|
4 | | --type lb_queue_name() :: ets_buffer:buffer_name(). |
5 | | --type audit_ets_name() :: ets_buffer:buffer_name(). |
6 | | --type session_queue_name() :: ets_buffer:buffer_name(). |
7 | | --type requests_queue_name() :: ets_buffer:buffer_name(). |
8 | | --type host_list() :: [{Ip_Addr::string(), Port::pos_integer()}]. |
9 | | --type timeout_in_ms() :: pos_integer(). %% in milliseconds |
10 | | --type max_sessions() :: pos_integer(). |
11 | | --type max_retries() :: non_neg_integer(). |
12 | | --type decay_prob() :: non_neg_integer(). %% number of chances in 1M of death |
| 5 | +%% Buffering module names are used for telemetry. |
| 6 | +-type buffering_strategy_module() :: module(). |
13 | 7 |
|
| 8 | +%% There are three queues used by elsyium. |
| 9 | +-type queue_name() :: ets_buffer:buffer_name() | atom(). |
| 10 | +-type lb_queue_name() :: queue_name(). % Cassandra node load balancer queue |
| 11 | +-type connection_queue_name() :: queue_name(). % Cassandra open connections queue |
| 12 | +-type requests_queue_name() :: queue_name(). % Pending requests queue |
| 13 | + |
| 14 | +-type audit_ets_name() :: atom(). % Audit ets table for telemetry data |
| 15 | + |
| 16 | +-type cassandra_node() :: {Ip_Or_Hostname::inet:hostname(), Port::inet:port_number()}. % Cassandra node |
| 17 | +-type host_list() :: [cassandra_node()]. % Host list used by load balancer |
| 18 | + |
| 19 | +-type timeout_in_ms() :: pos_integer(). % In milliseconds |
| 20 | +-type max_retries() :: non_neg_integer(). |
| 21 | +-type decay_prob() :: non_neg_integer(). % Chances in 1B of connection death |
| 22 | + |
| 23 | +%% Currently Cassandra connections are seestar_sessions. |
| 24 | +-type connection_id() :: pid(). % Live process holding socket to Cassandra. |
| 25 | +-type fun_request() :: fun((connection_id(), [any()], seestar:consistency()) -> [any()]). |
| 26 | +-type query_request() :: {bare_fun, config_type(), fun_request(), [any()], seestar:consistency()} |
| 27 | + | {mod_fun, config_type(), module(), atom(), [any()], seestar:consistency()}. |
| 28 | + |
| 29 | +-type cassandra_connection() :: {cassandra_node(), connection_id()}. |
| 30 | +-type connection_baton() :: {{connection_id(), reference}, erlang:timestamp()}. |
| 31 | + |
| 32 | +-type pending_request_pid() :: pid(). |
| 33 | +-type pending_request_baton() :: {{pending_request_pid(), reference()}, erlang:timestamp()}. |
| 34 | + |
| 35 | +%% Connection count errors reported by ets_buffer, new buffering strategies may need new error types. |
| 36 | +-type connection_count_error() :: ets_buffer:buffer_error(). |
| 37 | +-type max_connections() :: pos_integer() | connection_count_error(). |
| 38 | +-type pending_count() :: pos_integer() | connection_count_error(). |
| 39 | + |
| 40 | +-type idle_status() :: {idle_connections, {connection_queue_name(), |
| 41 | + Idle::max_connections(), Max::max_connections()}}. |
| 42 | +-type pending_status() :: {pending_requests, {requests_queue_name(), |
| 43 | + pending_count(), timeout_in_ms()}}. |
| 44 | +-type status_reply() :: {status, {idle_status(), pending_status()}}. |
| 45 | + |
| 46 | +-type pending_checkin() :: {boolean() | pending, {connection_queue_name(), |
| 47 | + max_connections(), max_connections()}}. |
| 48 | + |
| 49 | +%% Errors when a pending request does not get a chance to return a query result. |
14 | 50 | -type wait_for_session_error() :: {wait_for_session_timeout, pos_integer()} |
15 | 51 | | {wait_for_session_error, any()}. |
16 | 52 |
|
| 53 | +%% Errors when a query request fails after submitting to Cassandra. |
17 | 54 | -type worker_reply_error() :: {worker_reply_timeout, pos_integer()} |
18 | 55 | | {worker_reply_error, any()}. |
19 | 56 |
|
| 57 | +%% Errors getting a connection to Cassandra. |
| 58 | +-type connection_error() :: {error, no_db_connections}. |
| 59 | + |
| 60 | +%% All errors that a pending request may encounter. |
20 | 61 | -type pend_request_error() :: ets_buffer:buffer_error() |
21 | 62 | | wait_for_session_error() |
22 | | - | worker_reply_error(). |
| 63 | + | worker_reply_error() |
| 64 | + | connection_error(). |
| 65 | + |
| 66 | +%% Query_reply is a successful return; query_result contains all possible query returns. |
| 67 | +-type query_reply() :: any(). |
| 68 | +-type query_result() :: pend_request_error() | query_reply(). |
0 commit comments