nimbus/stateful/client/
mod.rs1mod fs_client;
6pub(crate) mod http_client;
7pub(crate) mod null_client;
8
9use std::sync::Arc;
10
11use remote_settings::RemoteSettingsService;
12use url::Url;
13
14use crate::Experiment;
15use crate::error::{NimbusError, Result};
16use crate::stateful::client::fs_client::FileSystemClient;
17use crate::stateful::client::null_client::NullClient;
18
19pub struct NimbusServerSettings {
20 pub rs_service: Arc<RemoteSettingsService>,
21 pub collection_name: String,
22}
23
24pub(crate) fn create_client(
25 rs_info: Option<NimbusServerSettings>,
26) -> Result<Box<dyn SettingsClient + Send>> {
27 Ok(match rs_info {
28 Some(NimbusServerSettings {
29 rs_service,
30 collection_name,
31 }) => {
32 let url = Url::parse(&rs_service.client_url())?; match url.scheme() {
34 "file" => {
35 let path = match url.to_file_path() {
39 Ok(path) => path,
40 _ => return Err(NimbusError::InvalidPath(url.into())),
41 };
42 Box::new(FileSystemClient::new(path)?)
43 }
44 _ => Box::new(rs_service.make_client(collection_name)),
45 }
46 }
47 None => Box::new(NullClient::new()),
48 })
49}
50
51pub(crate) trait SettingsClient {
53 #[allow(dead_code)]
54 fn get_experiments_metadata(&self) -> Result<String>;
55 fn fetch_experiments(&self) -> Result<Vec<Experiment>>;
56}