Skip to main content

BlockManagerConfigBuilder

Struct BlockManagerConfigBuilder 

Source
pub struct BlockManagerConfigBuilder<T: BlockMetadata> { /* private fields */ }
Expand description

Builder for BlockManager configuration.

Construct via BlockManager::builder() and finish with build().

Implementations§

Source§

impl<T: BlockMetadata> BlockManagerConfigBuilder<T>

Source

pub fn new() -> Self

Create a new builder.

Source

pub fn block_count(self, count: usize) -> Self

Set the number of blocks in the pool.

Source

pub fn block_size(self, size: usize) -> Self

Set the block size (number of tokens per block).

§Requirements
  • Must be >= 1 and <= 1024
  • Must be a power of 2
§Panics

Panics if the block size doesn’t meet requirements.

Source

pub fn duplication_policy(self, policy: BlockDuplicationPolicy) -> Self

Set the duplication policy.

Source

pub fn registry(self, registry: BlockRegistry) -> Self

Set the block registry.

Source

pub fn with_lru_backend(self) -> Self

Use simple LRU backend (capacity automatically set to block_count).

Source

pub fn with_multi_lru_backend(self) -> Self

Use multi-level LRU backend with 4 fixed priority levels.

Default thresholds: [3, 8, 15] for transitions between: Cold (0-2 hits) -> Warm (3-7) -> Hot (8-14) -> Very Hot (15+).

Source

pub fn with_multi_lru_backend_custom_thresholds( self, cold_to_warm: u8, warm_to_hot: u8, hot_to_very_hot: u8, ) -> Self

Use multi-level LRU with custom frequency thresholds.

§Requirements
  • Thresholds must be in ascending order: cold_to_warm < warm_to_hot < hot_to_very_hot
  • hot_to_very_hot must be <= 15 (4-bit counter maximum)
  • cold_to_warm must be >= 1 (to distinguish from never-accessed blocks)
§Arguments
  • cold_to_warm - Minimum frequency to move from Cold to Warm level
  • warm_to_hot - Minimum frequency to move from Warm to Hot level
  • hot_to_very_hot - Minimum frequency to move from Hot to Very Hot level
§Panics

Panics if thresholds don’t meet the requirements above.

Source

pub fn with_hashmap_backend(self, reuse_policy: Box<dyn ReusePolicy>) -> Self

Use HashMap backend with custom reuse policy.

Source

pub fn with_lineage_backend(self) -> Self

Use lineage backend.

Source

pub fn aggregator(self, aggregator: MetricsAggregator) -> Self

Set a metrics aggregator for prometheus export.

The aggregator will automatically receive this manager’s metrics source.

Source

pub fn build(self) -> Result<BlockManager<T>, BlockManagerBuilderError>

Build the BlockManager.

Validates configuration and constructs all pools, the upgrade closure, and the metrics source. Returns an error if validation fails or backend construction fails.

Trait Implementations§

Source§

impl<T: BlockMetadata> Default for BlockManagerConfigBuilder<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more