Skip to content

Commit

Permalink
Merge pull request #111 from mozilla-services/chore/110
Browse files Browse the repository at this point in the history
chore: update deps minus hyper 0.12
  • Loading branch information
pjenvey authored Aug 2, 2019
2 parents bf150f3 + 1086de7 commit a3adfd8
Show file tree
Hide file tree
Showing 9 changed files with 797 additions and 679 deletions.
1,317 changes: 724 additions & 593 deletions Cargo.lock

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions autopush-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,34 @@ edition = "2018"
name = "autopush_common"

[dependencies]
cadence = "0.16.0"
chrono = "0.4.6"
config = "0.9.2"
error-chain = "0.12.0"
futures = "0.1.25"
cadence = "0.17.1"
chrono = "0.4.7"
config = "0.9.3"
error-chain = "0.12.1"
futures = "0.1.28"
futures-backoff = "0.1.0"
httparse = "1.3.3"
httparse = "1.3.4"
# XXX: pin to hyper 0.11 for now: 0.12 has many changes..
hyper = "0.11.27"
lazy_static = "1.2.0"
mozsvc-common = "0.1.0"
rand = "0.6.3"
regex = "1.1.0"
reqwest = "0.9.5"
rusoto_core = "0.36.0"
rusoto_credential = "0.15.0"
rusoto_dynamodb = "0.36.0"
sentry = { version = "0.13.0", features = ["with_error_chain"] }
serde = "1.0.84"
serde_derive = "1.0.84"
serde_dynamodb = "0.2.1"
serde_json = "1.0.34"
slog = { version = "2.4.1", features = ["max_level_trace", "release_max_level_info"] }
lazy_static = "1.3.0"
mozsvc-common = "0.1.1"
rand = "0.7.0"
regex = "1.2.0"
reqwest = "0.9.19"
rusoto_core = "0.40.0"
rusoto_credential = "0.40.0"
rusoto_dynamodb = "0.40.0"
sentry = { version = "0.15.5", features = ["with_error_chain"] }
serde = "1.0.97"
serde_derive = "1.0.97"
serde_dynamodb = "0.3.2"
serde_json = "1.0.40"
slog = { version = "2.5.2", features = ["max_level_trace", "release_max_level_info"] }
slog-async = "2.3.0"
slog-term = "2.4.0"
slog-term = "2.4.1"
slog-mozlog-json = "0.1.0"
slog-scope = "4.1.1"
slog-stdlog = "3.0.2"
slog-scope = "4.1.2"
slog-stdlog = "3.0.5"
tokio-core = "0.1.17"
tungstenite = { version = "0.6.1", default-features = false }
uuid = { version = "0.7.1", features = ["serde", "v4"] }
tungstenite = { version = "0.8.1", default-features = false }
uuid = { version = "0.7.4", features = ["serde", "v4"] }
8 changes: 4 additions & 4 deletions autopush-common/src/db/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use cadence::{Counted, StatsdClient};
use chrono::Utc;
use futures::{future, Future};
use futures_backoff::retry_if;
use rusoto_core::RusotoError;
use rusoto_dynamodb::{
AttributeValue, BatchWriteItemError, DeleteItemError, DeleteItemInput, DeleteItemOutput,
DynamoDb, GetItemError, GetItemInput, GetItemOutput, ListTablesInput, ListTablesOutput,
Expand All @@ -25,11 +26,10 @@ use crate::util::timing::sec_since_epoch;

macro_rules! retryable_error {
($name:ident, $type:ty, $property:ident) => {
pub fn $name(err: &$type) -> bool {
pub fn $name(err: &RusotoError<$type>) -> bool {
match err {
$property::InternalServerError(_) | $property::ProvisionedThroughputExceeded(_) => {
true
}
RusotoError::Service($property::InternalServerError(_))
| RusotoError::Service($property::ProvisionedThroughputExceeded(_)) => true,
_ => false,
}
}
Expand Down
1 change: 0 additions & 1 deletion autopush-common/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ impl DynamoStorage {
channel_id: &Uuid,
message_month: &str,
endpoint: &str,
key: Option<String>,
) -> MyFuture<RegisterResponse> {
let ddb = self.ddb.clone();
let mut chids = HashSet::new();
Expand Down
55 changes: 27 additions & 28 deletions autopush/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,43 +15,42 @@ path = "src/main.rs"

[dependencies]
autopush_common = { path = "../autopush-common" }
base64 = "0.10.0"
bytes = "0.4.11"
cadence = "0.16.0"
base64 = "0.10.1"
bytes = "0.4.12"
cadence = "0.17.1"
chan-signal = "0.3.2"
config = "0.9.2"
docopt = "1.0.2"
error-chain = "0.12.0"
config = "0.9.3"
docopt = "1.1.0"
error-chain = "0.12.1"
fernet = "0.1.0"
futures = "0.1.25"
futures = "0.1.28"
hex = "0.3.2"
httparse = "1.3.3"
httparse = "1.3.4"
# XXX: pin to hyper 0.11 for now: 0.12 has many changes..
hyper = "0.11.27"
lazy_static = "1.2.0"
mozsvc-common = "0.1.0"
openssl = "0.10.16"
reqwest = "0.9.5"
rusoto_dynamodb = "0.36.0"
sentry = { version = "0.13.0", features = ["with_error_chain"] }
serde = "1.0.84"
serde_derive = "1.0.84"
serde_dynamodb = "0.2.1"
serde_json = "1.0.34"
slog = { version = "2.4.1", features = ["max_level_trace", "release_max_level_info"] }
lazy_static = "1.3.0"
mozsvc-common = "0.1.1"
openssl = "0.10.24"
reqwest = "0.9.19"
rusoto_dynamodb = "0.40.0"
sentry = { version = "0.15.5", features = ["with_error_chain"] }
serde = "1.0.97"
serde_derive = "1.0.97"
serde_dynamodb = "0.3.2"
serde_json = "1.0.40"
slog = { version = "2.5.2", features = ["max_level_trace", "release_max_level_info"] }
slog-async = "2.3.0"
slog-term = "2.4.0"
slog-term = "2.4.1"
slog-mozlog-json = "0.1.0"
slog-scope = "4.1.1"
slog-scope = "4.1.2"
# state_machine_future = { version = "0.1.6", features = ["debug_code_generation"] }
state_machine_future = "0.2.0"
time = "0.1.41"
time = "0.1.42"
tokio-core = "0.1.17"
tokio-io = "0.1.10"
tokio-io = "0.1.12"
tokio-openssl = "0.3.0"
tokio-service = "0.1.0"
tokio-tungstenite = { version = "0.6.0", default-features = false }
tungstenite = { version = "0.6.1", default-features = false }
uuid = { version = "0.7.1", features = ["serde", "v4"] }
# XXX: pin woothee until >= 0.8.1
woothee = "0.7.3"
tokio-tungstenite = { version = "0.8.0", default-features = false }
tungstenite = { version = "0.8.1", default-features = false }
uuid = { version = "0.7.4", features = ["serde", "v4"] }
woothee = "0.10.0"
16 changes: 6 additions & 10 deletions autopush/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use std::rc::Rc;
use std::time::Duration;
use tokio_core::reactor::Timeout;
use uuid::Uuid;
use woothee::parser::Parser;

use autopush_common::db::{CheckStorageResponse, HelloResponse, RegisterResponse};
use autopush_common::errors::*;
Expand Down Expand Up @@ -489,8 +488,7 @@ where
}
let now = ms_since_epoch();
let elapsed = (now - webpush.connected_at) / 1_000;
let parser = Parser::new();
let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&parser, &user_agent);
let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&user_agent);
// dogstatsd doesn't support timers: use histogram instead
srv.metrics
.time_with_tags("ua.connection.lifespan", elapsed)
Expand Down Expand Up @@ -553,7 +551,7 @@ where
"connection_type" => &stats.connection_type,
"ua_name" => ua_result.name,
"ua_os_family" => metrics_os,
"ua_os_ver" => ua_result.os_version,
"ua_os_ver" => ua_result.os_version.into_owned(),
"ua_browser_family" => metrics_browser,
"ua_browser_ver" => ua_result.version,
"ua_category" => ua_result.category,
Expand Down Expand Up @@ -858,13 +856,11 @@ where

let uaid = webpush.uaid;
let message_month = webpush.message_month.clone();
let srv = data.srv.clone();
let srv = &data.srv;
let fut = match srv.make_endpoint(&uaid, &channel_id, key.clone()) {
Ok(endpoint) => {
data.srv
.ddb
.register(&uaid, &channel_id, &message_month, &endpoint, key)
}
Ok(endpoint) => srv
.ddb
.register(&uaid, &channel_id, &message_month, &endpoint),
Err(_) => Box::new(future::ok(RegisterResponse::Error {
error_msg: "Failed to generate endpoint".to_string(),
status: 400,
Expand Down
1 change: 0 additions & 1 deletion autopush/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[macro_use]
extern crate slog;
#[macro_use]
extern crate slog_scope;
Expand Down
4 changes: 3 additions & 1 deletion autopush/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use tokio_core::reactor::{Core, Handle, Timeout};
use tokio_io;
use tokio_tungstenite::{accept_hdr_async, WebSocketStream};
use tungstenite::handshake::server::Request;
use tungstenite::Message;
use tungstenite::{self, Message};
use uuid::Uuid;

use autopush_common::db::DynamoStorage;
Expand Down Expand Up @@ -919,6 +919,8 @@ where
self.ws_pong_timeout = false;
task::current().notify();
}

Message::Close(_) => return Err(tungstenite::Error::ConnectionClosed.into()),
}
}
}
Expand Down
24 changes: 8 additions & 16 deletions autopush/src/user_agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ const VALID_UA_BROWSER: &[&str] = &["Chrome", "Firefox", "Safari", "Opera"];
// field). Windows has many values and we only care that its Windows
const VALID_UA_OS: &[&str] = &["Firefox OS", "Linux", "Mac OSX"];

pub fn parse_user_agent<'a>(
parser: &'a Parser,
agent: &str,
) -> (WootheeResult<'a>, &'a str, &'a str) {
pub fn parse_user_agent(agent: &str) -> (WootheeResult, &str, &str) {
let parser = Parser::new();
let wresult = parser.parse(&agent).unwrap_or_else(|| WootheeResult {
name: "",
category: "",
os: "",
os_version: "".to_string(),
os_version: "".into(),
browser_type: "",
version: "".to_string(),
version: "",
vendor: "",
});

Expand All @@ -43,15 +41,12 @@ pub fn parse_user_agent<'a>(

#[cfg(test)]
mod tests {
use woothee::parser::Parser;

use super::parse_user_agent;

#[test]
fn test_linux() {
let agent = r#"Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/20090807 Mandriva Linux/1.9.1.2-1.1mud2009.1 (2009.1) Firefox/3.5.2 FirePHP/0.3,gzip(gfe),gzip(gfe)"#;
let parser = Parser::new();
let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&parser, &agent);
let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&agent);
assert_eq!(metrics_os, "Linux");
assert_eq!(ua_result.os, "Linux");
assert_eq!(metrics_browser, "Firefox");
Expand All @@ -60,8 +55,7 @@ mod tests {
#[test]
fn test_windows() {
let agent = r#"Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)"#;
let parser = Parser::new();
let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&parser, &agent);
let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&agent);
assert_eq!(metrics_os, "Windows");
assert_eq!(ua_result.os, "Windows 7");
assert_eq!(metrics_browser, "Firefox");
Expand All @@ -71,8 +65,7 @@ mod tests {
fn test_osx() {
let agent =
r#"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.5; rv:2.1.1) Gecko/ Firefox/5.0.1"#;
let parser = Parser::new();
let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&parser, &agent);
let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&agent);
assert_eq!(metrics_os, "Mac OSX");
assert_eq!(ua_result.os, "Mac OSX");
assert_eq!(metrics_browser, "Firefox");
Expand All @@ -82,8 +75,7 @@ mod tests {
fn test_other() {
let agent =
r#"BlackBerry9000/4.6.0.167 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/102"#;
let parser = Parser::new();
let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&parser, &agent);
let (ua_result, metrics_os, metrics_browser) = parse_user_agent(&agent);
assert_eq!(metrics_os, "Other");
assert_eq!(ua_result.os, "BlackBerry");
assert_eq!(metrics_browser, "Other");
Expand Down

0 comments on commit a3adfd8

Please sign in to comment.