pub struct FlagPoller { /* private fields */ }Expand description
Synchronous poller for feature flag definitions.
Runs a background thread that periodically fetches flag definitions from
the PostHog API and updates the shared cache. Use this for blocking/sync
applications. With the async-client feature enabled, use
AsyncFlagPoller for async applications instead.
Implementations§
Source§impl FlagPoller
impl FlagPoller
Sourcepub fn new(config: LocalEvaluationConfig, cache: FlagCache) -> Self
pub fn new(config: LocalEvaluationConfig, cache: FlagCache) -> Self
Create a synchronous flag definition poller.
§Parameters
config: Credentials, host, polling interval, and request timeout.cache: Shared cache updated by the poller.
Sourcepub fn start(&mut self)
pub fn start(&mut self)
Start the polling thread.
Performs an initial synchronous load, then refreshes definitions in the
background until FlagPoller::stop is called or the poller is dropped.
Sourcepub fn load_flags(&self) -> Result<(), Error>
pub fn load_flags(&self) -> Result<(), Error>
Load flags synchronously 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.
Trait Implementations§
Source§impl Drop for FlagPoller
impl Drop for FlagPoller
Auto Trait Implementations§
impl !RefUnwindSafe for FlagPoller
impl !UnwindSafe for FlagPoller
impl Freeze for FlagPoller
impl Send for FlagPoller
impl Sync for FlagPoller
impl Unpin for FlagPoller
impl UnsafeUnpin for FlagPoller
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