pub enum PolymorphicEnvelopeBuffer {
InMemory(EnvelopeBuffer<MemoryStackProvider>),
Sqlite(EnvelopeBuffer<SqliteStackProvider>),
}
Expand description
Polymorphic envelope buffering interface.
The underlying buffer can either be disk-based or memory-based, depending on the given configuration.
NOTE: This is implemented as an enum because a trait object with async methods would not be object safe.
Variants§
InMemory(EnvelopeBuffer<MemoryStackProvider>)
An enveloper buffer that uses in-memory envelopes stacks.
Sqlite(EnvelopeBuffer<SqliteStackProvider>)
An enveloper buffer that uses sqlite envelopes stacks.
Implementations§
source§impl PolymorphicEnvelopeBuffer
impl PolymorphicEnvelopeBuffer
sourcepub fn is_memory(&self) -> bool
pub fn is_memory(&self) -> bool
Returns true if the implementation stores all envelopes in RAM.
sourcepub async fn from_config(
partition_id: u8,
config: &Config,
memory_checker: MemoryChecker,
) -> Result<Self, EnvelopeBufferError>
pub async fn from_config( partition_id: u8, config: &Config, memory_checker: MemoryChecker, ) -> Result<Self, EnvelopeBufferError>
Creates either a memory-based or a disk-based envelope buffer, depending on the given configuration.
sourcepub async fn initialize(&mut self)
pub async fn initialize(&mut self)
Initializes the envelope buffer.
sourcepub async fn push(
&mut self,
envelope: Box<Envelope>,
) -> Result<(), EnvelopeBufferError>
pub async fn push( &mut self, envelope: Box<Envelope>, ) -> Result<(), EnvelopeBufferError>
Adds an envelope to the buffer.
sourcepub async fn peek(&mut self) -> Result<Peek, EnvelopeBufferError>
pub async fn peek(&mut self) -> Result<Peek, EnvelopeBufferError>
Returns a reference to the next-in-line envelope.
sourcepub async fn pop(
&mut self,
) -> Result<Option<Box<Envelope>>, EnvelopeBufferError>
pub async fn pop( &mut self, ) -> Result<Option<Box<Envelope>>, EnvelopeBufferError>
Pops the next-in-line envelope.
sourcepub fn mark_ready(&mut self, project: &ProjectKey, is_ready: bool) -> bool
pub fn mark_ready(&mut self, project: &ProjectKey, is_ready: bool) -> bool
Marks a project as ready or not ready.
The buffer re-prioritizes its envelopes based on this information.
Returns true
if at least one priority was changed.
sourcepub fn mark_seen(
&mut self,
project_key_pair: &ProjectKeyPair,
next_fetch: Duration,
)
pub fn mark_seen( &mut self, project_key_pair: &ProjectKeyPair, next_fetch: Duration, )
Marks a stack as seen.
Non-ready stacks are deprioritized when they are marked as seen, such that
the next call to .peek()
will look at a different stack. This prevents
head-of-line blocking.
sourcepub fn has_capacity(&self) -> bool
pub fn has_capacity(&self) -> bool
Returns true
whether the buffer has capacity to accept new [Envelope
]s.
sourcepub async fn shutdown(&mut self) -> bool
pub async fn shutdown(&mut self) -> bool
Shuts down the PolymorphicEnvelopeBuffer
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PolymorphicEnvelopeBuffer
impl !RefUnwindSafe for PolymorphicEnvelopeBuffer
impl Send for PolymorphicEnvelopeBuffer
impl Sync for PolymorphicEnvelopeBuffer
impl Unpin for PolymorphicEnvelopeBuffer
impl !UnwindSafe for PolymorphicEnvelopeBuffer
Blanket Implementations§
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> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§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> 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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request