pub struct FeatureFlagService { /* private fields */ }Expand description
The main feature-flag service.
Wrap a FlagStore (for persistence) and an optional GroupResolver
(for named-group membership). The service is cheaply clone-able and
intended to be stored as an AppState extension:
state.insert_extension(FeatureFlagService::new(Arc::new(InMemoryFlagStore::new())));Implementations§
Source§impl FeatureFlagService
impl FeatureFlagService
Sourcepub fn with_group_resolver(self, resolver: GroupResolver) -> Self
pub fn with_group_resolver(self, resolver: GroupResolver) -> Self
Attach a group resolver so named-group gates are evaluated.
Sourcepub fn is_enabled(&self, flag_key: &str, actor_id: Option<&str>) -> bool
pub fn is_enabled(&self, flag_key: &str, actor_id: Option<&str>) -> bool
Return true if flag_key is enabled for actor_id.
Returns false for unknown flags (fail-closed).
Sourcepub fn set_rollout(
&self,
flag_key: &str,
pct: u8,
actor: Option<&str>,
) -> Result<(), FlagStoreError>
pub fn set_rollout( &self, flag_key: &str, pct: u8, actor: Option<&str>, ) -> Result<(), FlagStoreError>
Set the percent-rollout gate for flag_key to pct (0–100).
§Errors
Propagates FlagStoreError from the backing store.
Sourcepub fn allow_actor(
&self,
flag_key: &str,
actor_id: &str,
actor: Option<&str>,
) -> Result<(), FlagStoreError>
pub fn allow_actor( &self, flag_key: &str, actor_id: &str, actor: Option<&str>, ) -> Result<(), FlagStoreError>
Add actor_id to the explicit allowlist for flag_key.
§Errors
Propagates FlagStoreError from the backing store.
Sourcepub fn add_group(
&self,
flag_key: &str,
group: &str,
actor: Option<&str>,
) -> Result<(), FlagStoreError>
pub fn add_group( &self, flag_key: &str, group: &str, actor: Option<&str>, ) -> Result<(), FlagStoreError>
Add group to the named-group allowlist for flag_key.
§Errors
Propagates FlagStoreError from the backing store.
Sourcepub fn list(&self) -> Result<Vec<FlagConfig>, FlagStoreError>
pub fn list(&self) -> Result<Vec<FlagConfig>, FlagStoreError>
Sourcepub fn history(
&self,
flag_key: &str,
limit: usize,
) -> Result<Vec<FlagChangeRecord>, FlagStoreError>
pub fn history( &self, flag_key: &str, limit: usize, ) -> Result<Vec<FlagChangeRecord>, FlagStoreError>
Return the most recent limit change records for flag_key.
§Errors
Propagates FlagStoreError from the backing store.
Trait Implementations§
Source§impl Clone for FeatureFlagService
impl Clone for FeatureFlagService
Source§fn clone(&self) -> FeatureFlagService
fn clone(&self) -> FeatureFlagService
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for FeatureFlagService
impl !UnwindSafe for FeatureFlagService
impl Freeze for FeatureFlagService
impl Send for FeatureFlagService
impl Sync for FeatureFlagService
impl Unpin for FeatureFlagService
impl UnsafeUnpin for FeatureFlagService
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§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>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§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>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§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.Source§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.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> RepositoryHooksClone for Twhere
T: Clone,
impl<T> RepositoryHooksClone for Twhere
T: Clone,
Source§fn autumn_clone(&self) -> T
fn autumn_clone(&self) -> T
Source§impl<T, Conn> RunQueryDsl<Conn> for T
impl<T, Conn> RunQueryDsl<Conn> for T
Source§fn execute<'conn, 'query>(
self,
conn: &'conn mut Conn,
) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
fn execute<'conn, 'query>( self, conn: &'conn mut Conn, ) -> <Conn as AsyncConnectionCore>::ExecuteFuture<'conn, 'query>
Source§fn load<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
fn load<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
Source§fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnectionCore,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
fn load_stream<'conn, 'query, U>(
self,
conn: &'conn mut Conn,
) -> Self::LoadFuture<'conn>where
Conn: AsyncConnectionCore,
U: 'conn,
Self: LoadQuery<'query, Conn, U> + 'query,
Stream] with the returned rows. Read moreSource§fn get_result<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
fn get_result<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, LoadNext<Pin<Box<Self::Stream<'conn>>>>>
Source§fn get_results<'query, 'conn, U>(
self,
conn: &'conn mut Conn,
) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
fn get_results<'query, 'conn, U>( self, conn: &'conn mut Conn, ) -> AndThen<Self::LoadFuture<'conn>, TryCollect<Self::Stream<'conn>, Vec<U>>>
Vec with the affected rows. Read moreSource§impl<T> Scoped for T
impl<T> Scoped for T
Source§fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
fn scope(ctx: &PolicyContext) -> ScopeQuery<'_, Self>
ScopeQuery for this type. Resolves the
registered scope at .load() time, not here.