Skip to main content

MemoryCache

Struct MemoryCache 

Source
pub struct MemoryCache { /* private fields */ }
Expand description

In-memory BatchCache: batches that could not be uploaded wait for the next attempt, bounded by max_bytes and 512 batches (MAX_BATCHES, oldest evicted). The newest batch always stays, even when it alone is larger than max_bytes. Lost with the process.

Implementations§

Source§

impl MemoryCache

Source

pub fn new(max_bytes: u64) -> Self

An empty cache holding at most max_bytes of batches, apart from the newest batch, which always stays.

Trait Implementations§

Source§

impl BatchCache for MemoryCache

Source§

fn push(&self, id: &str, body: &[u8]) -> Result<Vec<String>>

Store one encoded batch under id: once this returns Ok the batch is committed (for FileCache, on disk). Returns the ids of older batches evicted to make room (the exporter counts their events as dropped).
Source§

fn replace(&self, old: &str, new: &[(String, Vec<u8>)]) -> Result<Vec<String>>

Replace the batch old with new (a split): all of new is committed before old goes, and nothing is evicted in between, so a crash can duplicate records but never lose them. A missing old returns io::ErrorKind::NotFound without storing children; an error does not promise that a concurrently evicted parent still exists. Returns the ids evicted afterwards, excluding any parent already reported as evicted.
Source§

fn pending(&self) -> Vec<String>

Ids of stored batches, oldest first.
Source§

fn read(&self, id: &str) -> Result<Vec<u8>>

The body stored under id: ErrorKind::NotFound when it is gone, another error when it exists but cannot be read right now (e.g. a locked device’s file protection).
Source§

fn remove(&self, id: &str) -> Result<()>

Delete one batch; a batch already gone is not an error.
Source§

fn clear(&self) -> Result<()>

Discard everything (telemetry disabled: nothing may be replayed later); Err when something could not be deleted.
Source§

fn take_evicted(&self) -> Vec<String>

Ids evicted before the exporter could see them (over the bounds when the cache was opened), handed over once so they are counted as lost.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V