#[non_exhaustive]pub struct DbFeatureDriver { /* private fields */ }Expand description
Feature flag driver backed by a database table rullst_feature_flags.
Uses a concurrent process-local cache with a configurable TTL. Lookup latency depends on contention, key/value size, hardware, and build profile.
§Note on Database Pool Initialization
This driver requires a live database pool to function. If feature flags are evaluated before the
database connection pool has been initialized (e.g., in early application startup or static constructors),
this driver will gracefully return None (falling through to subsequent drivers in the chain)
rather than blocking or panicking.
Implementations§
Source§impl DbFeatureDriver
impl DbFeatureDriver
Sourcepub fn new() -> DbFeatureDriver
pub fn new() -> DbFeatureDriver
Creates a new DbFeatureDriver with a default cache TTL of 5 seconds.
Sourcepub fn with_ttl(ttl: Duration) -> DbFeatureDriver
pub fn with_ttl(ttl: Duration) -> DbFeatureDriver
Creates a new DbFeatureDriver with a custom cache TTL duration.
Overrides the default TTL.
Sourcepub fn invalidate_process_cache()
pub fn invalidate_process_cache()
Invalidates cached database flags in every DbFeatureDriver in this process.
Call this only after the corresponding database transaction commits. Other processes and direct database writers remain visible through the configured TTL unless the application distributes this signal itself.
Trait Implementations§
Source§impl Default for DbFeatureDriver
impl Default for DbFeatureDriver
Source§fn default() -> DbFeatureDriver
fn default() -> DbFeatureDriver
Source§impl FeatureDriver for DbFeatureDriver
impl FeatureDriver for DbFeatureDriver
Source§fn enabled<'life0, 'life1, 'async_trait>(
&'life0 self,
flag: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<bool>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
DbFeatureDriver: 'async_trait,
fn enabled<'life0, 'life1, 'async_trait>(
&'life0 self,
flag: &'life1 str,
) -> Pin<Box<dyn Future<Output = Option<bool>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
DbFeatureDriver: 'async_trait,
Source§fn enabled_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
flag: &'life1 str,
identifier: &'life2 str,
) -> Pin<Box<dyn Future<Output = Option<bool>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
DbFeatureDriver: 'async_trait,
fn enabled_for<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
flag: &'life1 str,
identifier: &'life2 str,
) -> Pin<Box<dyn Future<Output = Option<bool>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
DbFeatureDriver: 'async_trait,
Source§fn variant<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
flag: &'life1 str,
identifier: &'life2 str,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
DbFeatureDriver: 'async_trait,
fn variant<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
flag: &'life1 str,
identifier: &'life2 str,
) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
DbFeatureDriver: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for DbFeatureDriver
impl Freeze for DbFeatureDriver
impl Send for DbFeatureDriver
impl Sync for DbFeatureDriver
impl Unpin for DbFeatureDriver
impl UnsafeUnpin for DbFeatureDriver
impl UnwindSafe for DbFeatureDriver
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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