Skip to content

Commit

Permalink
fix settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan Donowitz committed Jul 22, 2021
1 parent 3e5c2a1 commit c1ec820
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl Server {
max_size: settings.database_pool_max_size,
..Default::default()
}));
let tokenserver_state = if settings.enable_tokenserver {
let tokenserver_state = if settings.tokenserver.enabled {
Some(tokenserver::ServerState::from_settings(
&settings.tokenserver,
)?)
Expand Down
11 changes: 3 additions & 8 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ pub struct Settings {

/// Settings specific to Tokenserver
pub tokenserver: TokenserverSettings,

// XXX: This is a temporary setting used to enable Tokenserver-related features. In
// the future, Tokenserver will always be enabled, and this setting will be
// removed.
pub enable_tokenserver: bool,
}

impl Default for Settings {
Expand Down Expand Up @@ -114,7 +109,6 @@ impl Default for Settings {
enforce_quota: false,
spanner_emulator_host: None,
tokenserver: TokenserverSettings::default(),
enable_tokenserver: false,
}
}
}
Expand Down Expand Up @@ -168,9 +162,10 @@ impl Settings {
s.set_default("enforce_quota", false)?;

// Set Tokenserver defaults
s.set_default("enable_tokenserver", false)?;
s.set_default("tokenserver.fxa_metrics_hash_secret", "secret")?;
s.set_default("tokenserver.database_url", "mysql://[email protected]/tokenserver")?;
s.set_default("tokenserver.enabled", false)?;
s.set_default("tokenserver.fxa_email_domain", "test.com")?;
s.set_default("tokenserver.fxa_metrics_hash_secret", "secret")?;

// Merge the config file if supplied
if let Some(config_filename) = filename {
Expand Down
10 changes: 10 additions & 0 deletions src/tokenserver/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ use serde::Deserialize;
#[derive(Clone, Debug, Deserialize)]
pub struct Settings {
pub database_url: String,

pub database_pool_max_size: Option<u32>,

// NOTE: Not supported by deadpool!
pub database_pool_min_idle: Option<u32>,

/// Pool timeout when waiting for a slot to become available, in seconds
pub database_pool_connection_timeout: Option<u32>,

// XXX: This is a temporary setting used to enable Tokenserver-related features. In
// the future, Tokenserver will always be enabled, and this setting will be
// removed.
pub enabled: bool,

pub fxa_metrics_hash_secret: String,

/// The email domain for users' FxA accounts. This should be set according to the
Expand All @@ -25,6 +34,7 @@ impl Default for Settings {
database_pool_max_size: None,
database_pool_min_idle: None,
database_pool_connection_timeout: Some(30),
enabled: false,
fxa_email_domain: "api.accounts.firefox.com".to_owned(),
fxa_metrics_hash_secret: "secret".to_owned(),
fxa_oauth_server_url: None,
Expand Down

0 comments on commit c1ec820

Please sign in to comment.