Struct feattle::BackgroundSync[][src]

pub struct BackgroundSync<F> { /* fields omitted */ }
Expand description

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

Create a new poller for the given feattles instance. It will call Arc::downgrade() to detect when the value is dropped.

After a successful reload, will wait for this long before starting the next one. By default this is 30 seconds.

After a failed reload, will wait for this long before starting the next one. By default this is 60 seconds.

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.