diff --git a/nimbus/examples/experiment.rs b/nimbus/examples/experiment.rs index bcc94eab34..eda94c86e7 100644 --- a/nimbus/examples/experiment.rs +++ b/nimbus/examples/experiment.rs @@ -4,7 +4,7 @@ use clap::{App, Arg, SubCommand}; use env_logger::Env; -use nimbus::{AppContext, AvailableRandomizationUnits, Config, NimbusClient}; +use nimbus::{AppContext, AvailableRandomizationUnits, NimbusClient, RemoteSettingsConfig}; use std::io::prelude::*; const DEFAULT_BASE_URL: &str = "https://settings.stage.mozaws.net"; // TODO: Replace this with prod @@ -75,7 +75,7 @@ fn main() { log::info!("Collection name is {}", collection_name); // initiate the optional config - let config = Config { + let config = RemoteSettingsConfig { server_url: Some(server_url.to_string()), bucket_name: Some(bucket_name.to_string()), }; diff --git a/nimbus/src/config.rs b/nimbus/src/config.rs index ed514e1d28..a86fca7d48 100644 --- a/nimbus/src/config.rs +++ b/nimbus/src/config.rs @@ -13,7 +13,7 @@ /// - `server_url`: The url for the settings server that would be used to retrieve experiments /// - `bucket_name`: The name of the bucket containing the collection on the server #[derive(Debug, Clone)] -pub struct Config { +pub struct RemoteSettingsConfig { pub server_url: Option, pub bucket_name: Option, } diff --git a/nimbus/src/evaluator.rs b/nimbus/src/evaluator.rs index 8e7585f0c4..f30fd6411c 100644 --- a/nimbus/src/evaluator.rs +++ b/nimbus/src/evaluator.rs @@ -63,6 +63,8 @@ pub fn filter_enrolled( { Some(id) => id, None => { + // XXX: When we link we glean, it would be nice + // if we could emit a failure telemetry event here. log::info!( "Could not find a suitable randomization unit for {}. Skipping experiment.", &exp.slug diff --git a/nimbus/src/http_client.rs b/nimbus/src/http_client.rs index 7e6bfce68c..a676d83d3d 100644 --- a/nimbus/src/http_client.rs +++ b/nimbus/src/http_client.rs @@ -14,7 +14,7 @@ //! But the simple subset implemented here meets our needs for now. use super::Experiment; -use crate::config::Config; +use crate::config::RemoteSettingsConfig; use crate::error::{Error, Result}; use url::Url; use viaduct::{status_codes, Request, Response}; @@ -36,8 +36,11 @@ pub struct Client { impl Client { #[allow(unused)] - pub fn new(collection_name: &str, config: Option) -> Result { - let (base_url, bucket_name) = Self::get_params_from_config(config)?; + pub fn new( + collection_name: &str, + remote_settings_config: Option, + ) -> Result { + let (base_url, bucket_name) = Self::get_params_from_config(remote_settings_config)?; Ok(Self { base_url, collection_name: collection_name.to_string(), @@ -45,7 +48,7 @@ impl Client { }) } - fn get_params_from_config(config: Option) -> Result<(Url, String)> { + fn get_params_from_config(config: Option) -> Result<(Url, String)> { Ok(match config { Some(config) => { let base_url = config @@ -158,7 +161,7 @@ mod tests { .with_status(200) .with_header("content-type", "application/json") .create(); - let config = Config { + let config = RemoteSettingsConfig { server_url: Some(mockito::server_url()), bucket_name: None, }; diff --git a/nimbus/src/lib.rs b/nimbus/src/lib.rs index a9ee11b0ba..07bd1151a2 100644 --- a/nimbus/src/lib.rs +++ b/nimbus/src/lib.rs @@ -14,7 +14,7 @@ mod sampling; pub use evaluator::filter_enrolled; use ::uuid::Uuid; -pub use config::Config; +pub use config::RemoteSettingsConfig; use http_client::{Client, SettingsClient}; pub use matcher::AppContext; use persistence::Database; @@ -48,7 +48,7 @@ impl NimbusClient { collection_name: String, app_context: AppContext, db_path: P, - config: Option, + config: Option, available_randomization_units: AvailableRandomizationUnits, ) -> Result { let client = Client::new(&collection_name, config.clone())?; diff --git a/nimbus/src/nimbus.idl b/nimbus/src/nimbus.idl index 890f7c8598..1a53ad06e1 100644 --- a/nimbus/src/nimbus.idl +++ b/nimbus/src/nimbus.idl @@ -20,7 +20,7 @@ dictionary EnrolledExperiment { string branch_slug; }; -dictionary Config { +dictionary RemoteSettingsConfig { string? server_url; string? bucket_name; }; @@ -43,7 +43,7 @@ interface NimbusClient { string collection_name, AppContext app_ctx, string dbpath, - Config? config, + RemoteSettingsConfig? remote_settings_config, AvailableRandomizationUnits available_randomization_units );