pub struct Builder<Types, S, P> {Show 17 fields
storage: S,
provider: P,
backoff: ExponentialBackoffBuilder,
rate_limit: usize,
range_chunk_size: usize,
minor_scan_interval: Duration,
major_scan_interval: usize,
major_scan_offset: usize,
proactive_range_chunk_size: Option<usize>,
active_fetch_delay: Duration,
chunk_fetch_delay: Duration,
proactive_fetching: bool,
aggregator: bool,
aggregator_chunk_size: Option<usize>,
types_migration_batch_size: u64,
leaf_only: bool,
_types: PhantomData<Types>,
}
Expand description
Builder for FetchingDataSource
with configuration.
Fields§
§storage: S
§provider: P
§backoff: ExponentialBackoffBuilder
§rate_limit: usize
§range_chunk_size: usize
§minor_scan_interval: Duration
§major_scan_interval: usize
§major_scan_offset: usize
§proactive_range_chunk_size: Option<usize>
§active_fetch_delay: Duration
§chunk_fetch_delay: Duration
§proactive_fetching: bool
§aggregator: bool
§aggregator_chunk_size: Option<usize>
§types_migration_batch_size: u64
§leaf_only: bool
§_types: PhantomData<Types>
Implementations§
Source§impl<Types, S, P> Builder<Types, S, P>
impl<Types, S, P> Builder<Types, S, P>
Sourcepub fn new(storage: S, provider: P) -> Self
pub fn new(storage: S, provider: P) -> Self
Construct a new builder with the given storage and fetcher and the default options.
pub fn leaf_only(self) -> Self
Sourcepub fn with_min_retry_interval(self, interval: Duration) -> Self
pub fn with_min_retry_interval(self, interval: Duration) -> Self
Set the minimum delay between retries of failed operations.
Sourcepub fn with_max_retry_interval(self, interval: Duration) -> Self
pub fn with_max_retry_interval(self, interval: Duration) -> Self
Set the maximum delay between retries of failed operations.
Sourcepub fn with_retry_multiplier(self, multiplier: f64) -> Self
pub fn with_retry_multiplier(self, multiplier: f64) -> Self
Set the multiplier for exponential backoff when retrying failed requests.
Sourcepub fn with_retry_randomization_factor(self, factor: f64) -> Self
pub fn with_retry_randomization_factor(self, factor: f64) -> Self
Set the randomization factor for randomized backoff when retrying failed requests.
Sourcepub fn with_retry_timeout(self, timeout: Duration) -> Self
pub fn with_retry_timeout(self, timeout: Duration) -> Self
Set the maximum time to retry failed operations before giving up.
Sourcepub fn with_rate_limit(self, with_rate_limit: usize) -> Self
pub fn with_rate_limit(self, with_rate_limit: usize) -> Self
Set the maximum number of simultaneous fetches.
Sourcepub fn with_range_chunk_size(self, range_chunk_size: usize) -> Self
pub fn with_range_chunk_size(self, range_chunk_size: usize) -> Self
Set the number of items to process at a time when loading a range or stream.
This determines:
- The number of objects to load from storage in a single request
- The number of objects to buffer in memory per request/stream
- The number of concurrent notification subscriptions per request/stream
Sourcepub fn with_minor_scan_interval(self, interval: Duration) -> Self
pub fn with_minor_scan_interval(self, interval: Duration) -> Self
Set the time interval between minor proactive fetching scans.
See proactive fetching.
Sourcepub fn with_major_scan_interval(self, interval: usize) -> Self
pub fn with_major_scan_interval(self, interval: usize) -> Self
Set the interval (denominated in minor scans) between major proactive fetching scans.
See proactive fetching.
Sourcepub fn with_major_scan_offset(self, offset: usize) -> Self
pub fn with_major_scan_offset(self, offset: usize) -> Self
Set the offset (denominated in minor scans) before the first major proactive fetching scan.
This is useful when starting multiple nodes at the same time: major proactive scans can have
a measurable impact on the performance of the node for a brief time while the scan is
running, so it may be desirable to prevent a group of nodes from all doing major scans at
the same time. This can be achieved by giving each node a different major_scan_offset
.
See also proactive fetching.
Sourcepub fn with_proactive_range_chunk_size(self, range_chunk_size: usize) -> Self
pub fn with_proactive_range_chunk_size(self, range_chunk_size: usize) -> Self
Set the number of items to process at a time when scanning for proactive fetching.
This is similar to Self::with_range_chunk_size
, but only affects the chunk size for
proactive fetching scans, not for normal subscription streams. This can be useful to tune
the proactive scanner to be more or less greedy with persistent storage resources.
By default (i.e. if this method is not called) the proactive range chunk size will be set to whatever the normal range chunk size is.
Sourcepub fn with_active_fetch_delay(self, active_fetch_delay: Duration) -> Self
pub fn with_active_fetch_delay(self, active_fetch_delay: Duration) -> Self
Add a delay between active fetches in proactive scans.
This can be used to limit the rate at which this query service makes requests to other query services during proactive scans. This is useful if the query service has a lot of blocks to catch up on, as without a delay, scanning can be extremely burdensome on the peer.
Sourcepub fn with_chunk_fetch_delay(self, chunk_fetch_delay: Duration) -> Self
pub fn with_chunk_fetch_delay(self, chunk_fetch_delay: Duration) -> Self
Adds a delay between chunk fetches during proactive scans.
In a proactive scan, we retrieve a range of objects from a provider or local storage (e.g., a database).
Without a delay between fetching these chunks, the process can become very CPU-intensive, especially
when chunks are retrieved from local storage. While there is already a delay for active fetches
(active_fetch_delay
), situations may arise when subscribed to an old stream that fetches most of the data
from local storage.
This additional delay helps to limit constant maximum CPU usage and ensures that local storage remains accessible to all processes, not just the proactive scanner.
Sourcepub fn disable_proactive_fetching(self) -> Self
pub fn disable_proactive_fetching(self) -> Self
Run without proactive fetching.
This can reduce load on the CPU and the database, but increases the probability that
requests will fail due to missing resources. If resources are constrained, it is recommended
to run with rare proactive fetching (see
with_major_scan_interval
,
with_minor_scan_interval
), rather than disabling it
entirely.
Sourcepub fn disable_aggregator(self) -> Self
pub fn disable_aggregator(self) -> Self
Run without an aggregator.
This can reduce load on the CPU and the database, but it will cause aggregate statistics (such as transaction counts) not to update.
Sourcepub fn with_aggregator_chunk_size(self, chunk_size: usize) -> Self
pub fn with_aggregator_chunk_size(self, chunk_size: usize) -> Self
Set the number of items to process at a time when computing aggregate statistics.
This is similar to Self::with_range_chunk_size
, but only affects the chunk size for
the aggregator task, not for normal subscription streams. This can be useful to tune
the aggregator to be more or less greedy with persistent storage resources.
By default (i.e. if this method is not called) the proactive range chunk size will be set to whatever the normal range chunk size is.
Sourcepub fn with_types_migration_batch_size(self, batch: u64) -> Self
pub fn with_types_migration_batch_size(self, batch: u64) -> Self
Sets the batch size for the types migration.
Determines how many (leaf, vid)
rows are selected from the old types table
and migrated at once.
pub fn is_leaf_only(&self) -> bool
Source§impl<Types, S, P> Builder<Types, S, P>where
Types: NodeType,
Payload<Types>: QueryablePayload<Types>,
Header<Types>: QueryableHeader<Types>,
S: PruneStorage + VersionedDataSource + HasMetrics + MigrateTypes<Types> + 'static,
for<'a> S::ReadOnly<'a>: AvailabilityStorage<Types> + PrunedHeightStorage + NodeStorage<Types> + AggregatesStorage<Types>,
for<'a> S::Transaction<'a>: UpdateAvailabilityStorage<Types> + UpdateAggregatesStorage<Types>,
P: AvailabilityProvider<Types>,
impl<Types, S, P> Builder<Types, S, P>where
Types: NodeType,
Payload<Types>: QueryablePayload<Types>,
Header<Types>: QueryableHeader<Types>,
S: PruneStorage + VersionedDataSource + HasMetrics + MigrateTypes<Types> + 'static,
for<'a> S::ReadOnly<'a>: AvailabilityStorage<Types> + PrunedHeightStorage + NodeStorage<Types> + AggregatesStorage<Types>,
for<'a> S::Transaction<'a>: UpdateAvailabilityStorage<Types> + UpdateAggregatesStorage<Types>,
P: AvailabilityProvider<Types>,
Sourcepub async fn build(self) -> Result<FetchingDataSource<Types, S, P>>
pub async fn build(self) -> Result<FetchingDataSource<Types, S, P>>
Build a FetchingDataSource
with these options.
Auto Trait Implementations§
impl<Types, S, P> Freeze for Builder<Types, S, P>
impl<Types, S, P> RefUnwindSafe for Builder<Types, S, P>
impl<Types, S, P> Send for Builder<Types, S, P>
impl<Types, S, P> Sync for Builder<Types, S, P>
impl<Types, S, P> Unpin for Builder<Types, S, P>
impl<Types, S, P> UnwindSafe for Builder<Types, S, P>
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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<T> Conv for T
impl<T> Conv for T
§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
§fn deserialize(
&self,
deserializer: &mut D,
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.