Skip to content

Commit

Permalink
Rename Config to RemoteSettingsConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
eoger committed Oct 9, 2020
1 parent 13184e3 commit ba43e00
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions nimbus/examples/experiment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()),
};
Expand Down
2 changes: 1 addition & 1 deletion nimbus/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,
pub bucket_name: Option<String>,
}
2 changes: 2 additions & 0 deletions nimbus/src/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 8 additions & 5 deletions nimbus/src/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -36,16 +36,19 @@ pub struct Client {

impl Client {
#[allow(unused)]
pub fn new(collection_name: &str, config: Option<Config>) -> Result<Self> {
let (base_url, bucket_name) = Self::get_params_from_config(config)?;
pub fn new(
collection_name: &str,
remote_settings_config: Option<RemoteSettingsConfig>,
) -> Result<Self> {
let (base_url, bucket_name) = Self::get_params_from_config(remote_settings_config)?;
Ok(Self {
base_url,
collection_name: collection_name.to_string(),
bucket_name,
})
}

fn get_params_from_config(config: Option<Config>) -> Result<(Url, String)> {
fn get_params_from_config(config: Option<RemoteSettingsConfig>) -> Result<(Url, String)> {
Ok(match config {
Some(config) => {
let base_url = config
Expand Down Expand Up @@ -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,
};
Expand Down
4 changes: 2 additions & 2 deletions nimbus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,7 +48,7 @@ impl NimbusClient {
collection_name: String,
app_context: AppContext,
db_path: P,
config: Option<Config>,
config: Option<RemoteSettingsConfig>,
available_randomization_units: AvailableRandomizationUnits,
) -> Result<Self> {
let client = Client::new(&collection_name, config.clone())?;
Expand Down
4 changes: 2 additions & 2 deletions nimbus/src/nimbus.idl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ dictionary EnrolledExperiment {
string branch_slug;
};

dictionary Config {
dictionary RemoteSettingsConfig {
string? server_url;
string? bucket_name;
};
Expand All @@ -43,7 +43,7 @@ interface NimbusClient {
string collection_name,
AppContext app_ctx,
string dbpath,
Config? config,
RemoteSettingsConfig? remote_settings_config,
AvailableRandomizationUnits available_randomization_units
);

Expand Down

0 comments on commit ba43e00

Please sign in to comment.