pub struct StreamConfig {Show 14 fields
pub column_mapping: Option<ColumnMapping>,
pub event_signature: Option<String>,
pub hex_output: HexOutput,
pub batch_size: u64,
pub max_batch_size: Option<u64>,
pub min_batch_size: u64,
pub concurrency: usize,
pub max_num_blocks: Option<usize>,
pub max_num_transactions: Option<usize>,
pub max_num_logs: Option<usize>,
pub max_num_traces: Option<usize>,
pub response_bytes_target: u64,
pub max_buffered_bytes: Option<u64>,
pub reverse: bool,
}Expand description
Config for hypersync event streaming.
Fields§
§column_mapping: Option<ColumnMapping>Column mapping for stream function output. It lets you map columns you want into the DataTypes you want.
event_signature: Option<String>Event signature used to populate decode logs. Decode logs would be empty if set to None.
hex_output: HexOutputDetermines formatting of binary columns numbers into utf8 hex.
batch_size: u64Initial, deliberately-overestimated batch size, used for the first wave of requests and as a fallback before any response density has been measured.
max_batch_size: Option<u64>Optional hard upper cap on the number of blocks fetched in a single
request. None (the default) means no cap: an over-large request that the
server truncates simply leaves a gap that is backfilled, so overshoot is
self-correcting. Set it to bound blocks-per-chunk explicitly.
min_batch_size: u64Hard lower clamp on the projected block count, to avoid tiny ranges.
concurrency: usizeNumber of async threads that would be spawned to execute different block ranges of queries.
0 is an error, 1 streams sequentially, >= 2 uses the projecting scheduler.
max_num_blocks: Option<usize>Max number of blocks to fetch in a single request.
max_num_transactions: Option<usize>Max number of transactions to fetch in a single request.
max_num_logs: Option<usize>Max number of logs to fetch in a single request.
max_num_traces: Option<usize>Max number of traces to fetch in a single request.
response_bytes_target: u64Target response size in bytes. Each request’s block span is projected from the most recently observed byte-density to aim each response at this size.
max_buffered_bytes: Option<u64>Optional cap on the bytes of fetched-but-undelivered chunks held in the
reorder buffer (consumer backpressure). None (the default) is
adaptive: it starts at 2 * concurrency * response_bytes_target and
grows to 2 * concurrency * max(response_bytes_target, largest_response)
so the pipeline stays full even for byte-heavy queries whose responses far
exceed the target (otherwise a single response could exceed the cap and
throttle look-ahead to near-sequential). Set an explicit value to bound
memory; an explicit cap is honoured verbatim and never grown. Some(0) is
valid and means “no look-ahead buffer”: only the chunk delivery is
currently waiting on is fetched, so the stream runs effectively
sequentially with minimal memory (it still completes — the watermark chunk
is always allowed through).
reverse: boolStream data in reverse order
Implementations§
Source§impl StreamConfig
impl StreamConfig
Sourcepub const fn default_concurrency() -> usize
pub const fn default_concurrency() -> usize
Default concurrency for stream processing
Sourcepub const fn default_batch_size() -> u64
pub const fn default_batch_size() -> u64
Default initial batch size
Sourcepub const fn default_min_batch_size() -> u64
pub const fn default_min_batch_size() -> u64
Default minimum batch size
Sourcepub const fn default_response_bytes_target() -> u64
pub const fn default_response_bytes_target() -> u64
Default target response size in bytes that projection aims each response at
Sourcepub const fn default_reverse() -> bool
pub const fn default_reverse() -> bool
Default reverse streaming setting
Sourcepub fn dense() -> Self
pub fn dense() -> Self
Preset for dense workloads: queries that match a lot of data per block (busy contracts, all-logs, popular ERC-20 transfers).
Such streams are throughput-bound and scale well with parallelism, so this
raises concurrency above the default. The default response_bytes_target
(400 KB) is already a good fit — benchmarking showed dense responses
plateau near that size, and pushing the target higher mostly adds
truncation/backfill rather than bigger responses.
max_buffered_bytes is left unset so the adaptive default applies. If you
have plenty of rate-limit headroom you can push concurrency higher still.
Sourcepub fn sparse() -> Self
pub fn sparse() -> Self
Preset for sparse workloads: selective queries over wide block ranges (rare events, low-volume contracts) where most blocks match nothing.
Here latency, not bytes, dominates, and benchmarking showed that high
concurrency actually hurts: extra workers just fragment a large empty
region into more (smaller) requests. So this keeps concurrency moderate and
raises batch_size so the first wave covers a lot of ground before
per-request projection kicks in — an over-estimate that self-corrects via
backfill if it hits a dense patch.
Sourcepub fn archival() -> Self
pub fn archival() -> Self
Preset for archival / byte-heavy workloads: full block + transaction
pulls (e.g. include_all_blocks with wide field selection) where each
response is many megabytes.
These streams are bounded by the reorder buffer, not concurrency: a single
response can dwarf response_bytes_target, so the adaptive
max_buffered_bytes default (left unset here) is what keeps the pipeline
full — in benchmarks it roughly doubled throughput versus a buffer sized to
the target. Concurrency past ~10–15 gives little extra here.
Trait Implementations§
Source§impl Clone for StreamConfig
impl Clone for StreamConfig
Source§fn clone(&self) -> StreamConfig
fn clone(&self) -> StreamConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StreamConfig
impl Debug for StreamConfig
Source§impl Default for StreamConfig
impl Default for StreamConfig
Source§impl<'de> Deserialize<'de> for StreamConfig
impl<'de> Deserialize<'de> for StreamConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for StreamConfig
impl JsonSchema for StreamConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreAuto Trait Implementations§
impl Freeze for StreamConfig
impl RefUnwindSafe for StreamConfig
impl Send for StreamConfig
impl Sync for StreamConfig
impl Unpin for StreamConfig
impl UnsafeUnpin for StreamConfig
impl UnwindSafe for StreamConfig
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more