[−][src]Struct feattle_sync::BackgroundSync
Spawn a tokio task to poll Feattles::reload()
continuously
A feattles instance will only ask the persistence layer for the current values when the
Feattles::reload()
method is called. This type would do so regularly for you, until the
Feattles
instance is dropped.
Example
use feattle_core::{feattles, Feattles}; use feattle_sync::BackgroundSync; use feattle_core::persist::NoPersistence; use std::sync::Arc; feattles! { struct MyToggles { a: bool, } } // `NoPersistence` here is just a mock for the sake of the example let toggles = Arc::new(MyToggles::new(NoPersistence)); BackgroundSync::new(&toggles).spawn();
Implementations
impl<F> BackgroundSync<F>
[src]
pub fn new(feattles: &Arc<F>) -> Self
[src]
Create a new poller for the given feattles instance. It will call Arc::downgrade()
to
detect when the value is dropped.
pub fn interval(&mut self, value: Duration) -> &mut Self
[src]
Set both Self::ok_interval
and Self::err_interval
pub fn ok_interval(&mut self, value: Duration) -> &mut Self
[src]
After a successful reload, will wait for this long before starting the next one. By default this is 30 seconds.
pub fn err_interval(&mut self, value: Duration) -> &mut Self
[src]
After a failed reload, will wait for this long before starting the next one. By default this is 60 seconds.
pub fn spawn<P>(self) -> JoinHandle<()> where
F: Feattles<P>,
P: Persist,
[src]
F: Feattles<P>,
P: Persist,
Spawn a new tokio task, returning its handle. Usually you do not want to anything with the returned handle, since the task will run by itself until the feattles instance gets dropped.
Operational logs are generated with the crate log
.
Trait Implementations
Auto Trait Implementations
impl<F> RefUnwindSafe for BackgroundSync<F> where
F: RefUnwindSafe,
F: RefUnwindSafe,
impl<F> Send for BackgroundSync<F> where
F: Send + Sync,
F: Send + Sync,
impl<F> Sync for BackgroundSync<F> where
F: Send + Sync,
F: Send + Sync,
impl<F> Unpin for BackgroundSync<F>
impl<F> UnwindSafe for BackgroundSync<F> where
F: RefUnwindSafe,
F: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,