hyperfuel_client/config.rs
1use serde::{Deserialize, Serialize};
2use std::num::NonZeroU64;
3use url::Url;
4
5use crate::ColumnMapping;
6
7/// Configuration for the hypersync client.
8#[derive(Default, Debug, Clone, Deserialize, Serialize)]
9pub struct ClientConfig {
10 /// HyperSync server URL.
11 pub url: Option<Url>,
12 /// HyperSync server bearer token.
13 pub bearer_token: Option<String>,
14 /// Milliseconds to wait for a response before timing out.
15 pub http_req_timeout_millis: Option<NonZeroU64>,
16 /// Number of retries to attempt before returning error.
17 pub max_num_retries: Option<usize>,
18 /// Milliseconds that would be used for retry backoff increasing.
19 pub retry_backoff_ms: Option<u64>,
20 /// Initial wait time for request backoff.
21 pub retry_base_ms: Option<u64>,
22 /// Ceiling time for request backoff.
23 pub retry_ceiling_ms: Option<u64>,
24}
25
26/// Config for hypersync event streaming.
27#[derive(Default, Debug, Clone, Serialize, Deserialize)]
28pub struct StreamConfig {
29 /// Column mapping for stream function output.
30 /// It lets you map columns you want into the DataTypes you want.
31 pub column_mapping: Option<ColumnMapping>,
32 /// Event signature used to populate decode logs. Decode logs would be empty if set to None.
33 pub event_signature: Option<String>,
34 /// Determines formatting of binary columns numbers into utf8 hex.
35 #[serde(default)]
36 pub hex_output: HexOutput,
37 /// Initial batch size. Size would be adjusted based on response size during execution.
38 pub batch_size: Option<u64>,
39 /// Maximum batch size that could be used during dynamic adjustment.
40 pub max_batch_size: Option<u64>,
41 /// Minimum batch size that could be used during dynamic adjustment.
42 pub min_batch_size: Option<u64>,
43 /// Number of async threads that would be spawned to execute different block ranges of queries.
44 pub concurrency: Option<usize>,
45 /// Max number of blocks to fetch in a single request.
46 pub max_num_blocks: Option<usize>,
47 /// Max number of transactions to fetch in a single request.
48 pub max_num_transactions: Option<usize>,
49 /// Max number of receipts to fetch in a single request.
50 pub max_num_receipts: Option<usize>,
51 /// Max number of inputs to fetch in a single request.
52 pub max_num_inputs: Option<usize>,
53 /// Max number of outputs to fetch in a single request.
54 pub max_num_outputs: Option<usize>,
55 /// Size of a response in bytes from which step size will be lowered
56 pub response_bytes_ceiling: Option<u64>,
57 /// Size of a response in bytes from which step size will be increased
58 pub response_bytes_floor: Option<u64>,
59 /// Stream data in reverse order
60 pub reverse: Option<bool>,
61}
62
63/// Determines format of Binary column
64#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
65pub enum HexOutput {
66 /// Binary column won't be formatted as hex
67 NoEncode,
68 /// Binary column would be formatted as prefixed hex i.e. 0xdeadbeef
69 Prefixed,
70 /// Binary column would be formatted as non prefixed hex i.e. deadbeef
71 NonPrefixed,
72}
73
74impl Default for HexOutput {
75 fn default() -> Self {
76 Self::NoEncode
77 }
78}