pub struct PollerThread { /* private fields */ }
Expand description
A configuration poller thread.
The poller thread polls the server periodically to fetch the latest configuration.
Use Client::start_poller_thread
to get an instance.
The Client returns None
for assignments before the first configuration is fetched. So it is
recommended to call PollerThread::wait_for_configuration
before requesting assignments.
Implementations§
Source§impl PollerThread
impl PollerThread
Sourcepub fn wait_for_configuration(&self) -> Result<()>
pub fn wait_for_configuration(&self) -> Result<()>
Waits for the configuration to be fetched.
This method blocks until the poller thread has fetched the configuration.
§Returns
Returns Result<()>
where Ok(())
indicates successful configuration fetch and any
error that occurred during the process.
§Errors
This method can fail with the following errors:
Error::PollerThreadPanicked
: If the poller thread panicked while waiting for configuration.
§Example
let poller = client.start_poller_thread().unwrap();
match poller.wait_for_configuration() {
Ok(()) => println!("Configuration fetched successfully."),
Err(err) => eprintln!("Error fetching configuration: {:?}", err),
}
Sourcepub fn stop(&self)
pub fn stop(&self)
Stop the poller thread.
This function does not wait for the thread to actually stop.
Sourcepub fn shutdown(self) -> Result<()>
pub fn shutdown(self) -> Result<()>
Stop the poller thread and block waiting for it to exit.
If you don’t need to wait for the thread to exit, use PollerThread::stop
instead.
§Errors
Returns an error of type Error
in the following cases:
Error::PollerThreadPanicked
if the thread has panicked.
§Examples
poller_thread.shutdown().expect("Failed to shut down the poller thread");