pub struct AsyncFlagPoller { /* private fields */ }Expand description
Asynchronous poller for feature flag definitions.
Runs a tokio task that periodically fetches flag definitions from the
PostHog API and updates the shared cache. Use this for async applications.
For blocking/sync applications, use FlagPoller instead.
Implementations§
Source§impl AsyncFlagPoller
impl AsyncFlagPoller
Sourcepub fn new(config: LocalEvaluationConfig, cache: FlagCache) -> Self
pub fn new(config: LocalEvaluationConfig, cache: FlagCache) -> Self
Create an asynchronous flag definition poller.
§Parameters
config: Credentials, host, polling interval, and request timeout.cache: Shared cache updated by the poller.
Sourcepub async fn start(&mut self)
pub async fn start(&mut self)
Start the polling task.
Performs an initial async load, then refreshes definitions in the
background until AsyncFlagPoller::stop is called or the poller is
dropped.
Sourcepub async fn load_flags(&self) -> Result<(), Error>
pub async fn load_flags(&self) -> Result<(), Error>
Load flags asynchronously and update the cache once.
§Errors
Returns Error::Connection for request failures or non-success HTTP
statuses, and Error::Serialization when the response cannot be
parsed.
Sourcepub async fn is_running(&self) -> bool
pub async fn is_running(&self) -> bool
Check if the poller currently has a running background task.
Trait Implementations§
Source§impl Drop for AsyncFlagPoller
Available on crate feature async-client only.
impl Drop for AsyncFlagPoller
Available on crate feature
async-client only.Auto Trait Implementations§
impl !RefUnwindSafe for AsyncFlagPoller
impl !UnwindSafe for AsyncFlagPoller
impl Freeze for AsyncFlagPoller
impl Send for AsyncFlagPoller
impl Sync for AsyncFlagPoller
impl Unpin for AsyncFlagPoller
impl UnsafeUnpin for AsyncFlagPoller
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
Mutably borrows from an owned value. Read more