Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Amazon Device Messaging router #207

Merged
merged 12 commits into from
Aug 5, 2020
5 changes: 4 additions & 1 deletion autoendpoint/src/extractors/routers.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::routers::adm::router::AdmRouter;
use crate::routers::apns::router::ApnsRouter;
use crate::routers::fcm::router::FcmRouter;
use crate::routers::webpush::WebPushRouter;
Expand Down Expand Up @@ -51,6 +52,7 @@ pub struct Routers {
webpush: WebPushRouter,
fcm: Arc<FcmRouter>,
apns: Arc<ApnsRouter>,
adm: Arc<AdmRouter>,
}

impl FromRequest for Routers {
Expand All @@ -72,6 +74,7 @@ impl FromRequest for Routers {
},
fcm: state.fcm_router.clone(),
apns: state.apns_router.clone(),
adm: state.adm_router.clone(),
})
}
}
Expand All @@ -83,7 +86,7 @@ impl Routers {
RouterType::WebPush => &self.webpush,
RouterType::FCM => self.fcm.as_ref(),
RouterType::APNS => self.apns.as_ref(),
RouterType::ADM => unimplemented!(),
RouterType::ADM => self.adm.as_ref(),
}
}
}
5 changes: 1 addition & 4 deletions autoendpoint/src/logging.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
use std::io;

use crate::error::ApiResult;

use slog::{self, slog_o, Drain};
use slog_mozlog_json::MozLogJson;

// TODO: Merge back into common code? Removes hostname and adds envlogger
pub fn init_logging(json: bool) -> ApiResult<()> {
pub fn init_logging(json: bool) {
let logger = if json {
let drain = MozLogJson::new(io::stdout())
.logger_name(format!(
Expand All @@ -33,7 +31,6 @@ pub fn init_logging(json: bool) -> ApiResult<()> {
// https://github.com/slog-rs/slog/issues/169
slog_scope::set_global_logger(logger).cancel_reset();
slog_stdlog::init().ok();
AzureMarker marked this conversation as resolved.
Show resolved Hide resolved
Ok(())
}

pub fn reset_logging() {
Expand Down
2 changes: 1 addition & 1 deletion autoendpoint/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
.and_then(|d| d.deserialize())
.unwrap_or_else(|e| e.exit());
let settings = settings::Settings::with_env_and_config_file(&args.flag_config)?;
logging::init_logging(!settings.human_logs).expect("Logging failed to initialize");
logging::init_logging(!settings.human_logs);
debug!("Starting up...");

// Configure sentry error capture
Expand Down
Loading