Skip to content

Commit

Permalink
move configs into apns settings
Browse files Browse the repository at this point in the history
  • Loading branch information
taddes committed Jul 29, 2024
1 parent b01363a commit 22c3440
Showing 3 changed files with 13 additions and 16 deletions.
9 changes: 4 additions & 5 deletions autoendpoint/src/routers/apns/router.rs
Original file line number Diff line number Diff line change
@@ -9,7 +9,6 @@ use crate::routers::common::{
build_message_data, incr_error_metric, incr_success_metrics, message_size_check,
};
use crate::routers::{Router, RouterError, RouterResponse};
use crate::settings::Settings;
use a2::{
self,
request::payload::{Payload, PayloadLike},
@@ -154,15 +153,15 @@ impl ApnsRouter {
} else {
settings.key.as_bytes().to_vec()
};
// Timeouts defined in autoendpoint settings.rs config and can be modified.
// Timeouts defined in ApnsSettings settings.rs config and can be modified.
// We define them to prevent possible a2 library changes that could
// create unexpected behavior if timeouts are altered.
// They currently map to values matching the detaults in the a2 lib v0.10.
let autoendpoint_settings = Settings::default();
let apns_settings = ApnsSettings::default();
let config = a2::ClientConfig {
endpoint,
request_timeout_secs: autoendpoint_settings.request_timeout_secs,
pool_idle_timeout_secs: autoendpoint_settings.pool_idle_timeout_secs,
request_timeout_secs: apns_settings.request_timeout_secs,
pool_idle_timeout_secs: apns_settings.pool_idle_timeout_secs,
};
let client = ApnsClientData {
client: Box::new(
11 changes: 9 additions & 2 deletions autoendpoint/src/routers/apns/settings.rs
Original file line number Diff line number Diff line change
@@ -10,6 +10,11 @@ pub struct ApnsSettings {
pub channels: String,
/// The max size of notification data in bytes
pub max_data: usize,
// These values correspond to the a2 library ClientConfig struct.
// https://github.com/WalletConnect/a2/blob/master/src/client.rs#L65-L71.
// Utilized by apns router config in creating the client.
pub request_timeout_secs: Option<u64>,
pub pool_idle_timeout_secs: Option<u64>,
}

/// Settings for a specific APNS release channel
@@ -27,10 +32,12 @@ pub struct ApnsChannel {
}

impl Default for ApnsSettings {
fn default() -> Self {
Self {
fn default() -> ApnsSettings {
ApnsSettings {
channels: "{}".to_string(),
max_data: 4096,
request_timeout_secs: Some(20),
pool_idle_timeout_secs: Some(600),
}
}
}
9 changes: 0 additions & 9 deletions autoendpoint/src/settings.rs
Original file line number Diff line number Diff line change
@@ -45,13 +45,6 @@ pub struct Settings {

pub fcm: FcmSettings,
pub apns: ApnsSettings,

// These values correspond to the a2 library ClientConfig struct.
// https://github.com/WalletConnect/a2/blob/master/src/client.rs#L65-L71.
// Utilized by autoendpoint router config in creating the client.
pub request_timeout_secs: Option<u64>,
pub pool_idle_timeout_secs: Option<u64>,

#[cfg(feature = "stub")]
pub stub: StubSettings,
}
@@ -86,8 +79,6 @@ impl Default for Settings {
statsd_label: "autoendpoint".to_string(),
fcm: FcmSettings::default(),
apns: ApnsSettings::default(),
request_timeout_secs: Some(20),
pool_idle_timeout_secs: Some(600),
#[cfg(feature = "stub")]
stub: StubSettings::default(),
}

0 comments on commit 22c3440

Please sign in to comment.