nimbus/stateful/client/
mod.rsmod fs_client;
pub(crate) mod http_client;
pub(crate) mod null_client;
use crate::error::{NimbusError, Result};
use crate::Experiment;
use fs_client::FileSystemClient;
use null_client::NullClient;
use remote_settings::RemoteSettings;
use remote_settings::RemoteSettingsConfig;
pub(crate) fn create_client(
config: Option<RemoteSettingsConfig>,
) -> Result<Box<dyn SettingsClient + Send>> {
Ok(match config {
Some(config) => {
assert!(config.server_url.is_none());
let Some(remote_settings_server) = config.server.as_ref() else {
return Ok(Box::new(RemoteSettings::new(config)?));
};
let url = remote_settings_server.url()?;
if url.scheme() == "file" {
let path = match url.to_file_path() {
Ok(path) => path,
_ => return Err(NimbusError::InvalidPath(url.into())),
};
Box::new(FileSystemClient::new(path)?)
} else {
Box::new(RemoteSettings::new(config)?)
}
}
None => Box::new(NullClient::new()),
})
}
pub(crate) trait SettingsClient {
#[allow(dead_code)]
fn get_experiments_metadata(&self) -> Result<String>;
fn fetch_experiments(&self) -> Result<Vec<Experiment>>;
}