Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
iambriccardo committed Aug 27, 2024
1 parent 357602c commit c694bc7
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
48 changes: 24 additions & 24 deletions relay-config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ trait ConfigObject: DeserializeOwned + Serialize {
pub struct OverridableConfig {
/// The operation mode of this relay.
pub mode: Option<String>,
/// The deployment of this relay.
pub deployment: Option<String>,
/// The instance type of this relay.
pub instance: Option<String>,
/// The log level of this relay.
pub log_level: Option<String>,
/// The upstream relay or sentry instance.
Expand Down Expand Up @@ -354,40 +354,40 @@ impl fmt::Display for RelayMode {
}
}

/// The deployment type of Relay.
/// The instance type of Relay.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub enum RelayDeployment {
/// This Relay is run in a default deployment.
pub enum RelayInstance {
/// This Relay is run as a default instance.
Default,

/// This Relay is run in a canary deployment where experiments can be run.
/// This Relay is run as a canary instance where experiments can be run.
Canary,
}

impl RelayDeployment {
/// Returns `true` if the [`RelayDeployment`] is of type [`RelayDeployment::Canary`].
impl RelayInstance {
/// Returns `true` if the [`RelayInstance`] is of type [`RelayInstance::Canary`].
pub fn is_canary(&self) -> bool {
matches!(self, RelayDeployment::Canary)
matches!(self, RelayInstance::Canary)
}
}

impl fmt::Display for RelayDeployment {
impl fmt::Display for RelayInstance {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
RelayDeployment::Default => write!(f, "default"),
RelayDeployment::Canary => write!(f, "canary"),
RelayInstance::Default => write!(f, "default"),
RelayInstance::Canary => write!(f, "canary"),
}
}
}

impl FromStr for RelayDeployment {
impl FromStr for RelayInstance {
type Err = fmt::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"canary" => Ok(RelayDeployment::Canary),
_ => Ok(RelayDeployment::Default),
"canary" => Ok(RelayInstance::Canary),
_ => Ok(RelayInstance::Default),
}
}
}
Expand Down Expand Up @@ -476,8 +476,8 @@ impl Default for ReadinessCondition {
pub struct Relay {
/// The operation mode of this relay.
pub mode: RelayMode,
/// The deployment of this relay.
pub deployment: RelayDeployment,
/// The instance type of this relay.
pub instance: RelayInstance,
/// The upstream relay or sentry instance.
pub upstream: UpstreamDescriptor<'static>,
/// The host the relay should bind to (network interface).
Expand Down Expand Up @@ -505,7 +505,7 @@ impl Default for Relay {
fn default() -> Self {
Relay {
mode: RelayMode::Managed,
deployment: RelayDeployment::Default,
instance: RelayInstance::Default,
upstream: "https://sentry.io/".parse().unwrap(),
host: default_host(),
port: 3000,
Expand Down Expand Up @@ -1650,9 +1650,9 @@ impl Config {
.with_context(|| ConfigError::field("mode"))?;
}

if let Some(deployment) = overrides.deployment {
relay.deployment = deployment
.parse::<RelayDeployment>()
if let Some(deployment) = overrides.instance {
relay.instance = deployment
.parse::<RelayInstance>()
.with_context(|| ConfigError::field("deployment"))?;
}

Expand Down Expand Up @@ -1869,9 +1869,9 @@ impl Config {
self.values.relay.mode
}

/// Returns the relay deployment.
pub fn relay_deployment(&self) -> RelayDeployment {
self.values.relay.deployment
/// Returns the instance type of relay.
pub fn relay_instance(&self) -> RelayInstance {
self.values.relay.instance
}

/// Returns the upstream target as descriptor.
Expand Down
4 changes: 2 additions & 2 deletions relay/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub fn extract_config_args(matches: &ArgMatches) -> OverridableConfig {
secret_key: matches.get_one("secret_key").cloned(),
outcome_source: matches.get_one("source_id").cloned(),
shutdown_timeout: matches.get_one("shutdown_timeout").cloned(),
deployment: matches.get_one("deployment").cloned(),
instance: matches.get_one("instance").cloned(),
}
}

Expand All @@ -118,7 +118,7 @@ pub fn extract_config_env_vars() -> OverridableConfig {
secret_key: env::var("RELAY_SECRET_KEY").ok(),
outcome_source: None, //already extracted in params
shutdown_timeout: env::var("SHUTDOWN_TIMEOUT").ok(),
deployment: env::var("RELAY_DEPLOYMENT").ok(),
instance: env::var("RELAY_INSTANCE").ok(),
}
}

Expand Down
6 changes: 3 additions & 3 deletions relay/src/cliapp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ pub fn make_app() -> Command {
),
)
.arg(
Arg::new("deployment")
.long("deployment")
.help("The deployment type of this Relay.")
Arg::new("instance")
.long("instance")
.help("The instance type of this Relay.")
)
)
.subcommand(
Expand Down

0 comments on commit c694bc7

Please sign in to comment.