Skip to content

Commit

Permalink
bug: use sentry 0.19 to match our backend server (#276)
Browse files Browse the repository at this point in the history
Closes #275
  • Loading branch information
jrconlin committed Jun 2, 2021
1 parent d8b7ca8 commit 44c85c0
Show file tree
Hide file tree
Showing 13 changed files with 470 additions and 464 deletions.
845 changes: 422 additions & 423 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion autoendpoint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ reqwest = "0.10.6" # 0.11+ requires futures 0.3+
rusoto_core = "0.45.0" # 0.46+ requires futures 0.3+
rusoto_dynamodb = "0.45.0" # 0.46+ requires futures 0.3+
# Using debug-logs avoids https://github.com/getsentry/sentry-rust/issues/237
sentry = { version = "0.20", features = ["debug-logs"] } # 0.22+ requires tokio 1.1+
sentry = { version = "0.19", features = ["debug-logs"] } # Keep on 0.19 in order to work with our backend
serde = { version = "1.0", features = ["derive"] }
serde_dynamodb = "0.6" # 0.7+ requires rusoto_dynamodb 0.46+
serde_json = "1.0"
Expand Down
1 change: 1 addition & 0 deletions autoendpoint/src/extractors/routers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use std::sync::Arc;

/// Valid `DynamoDbUser::router_type` values
#[derive(Copy, Clone, Debug, PartialEq)]
#[allow(clippy::upper_case_acronyms)]
pub enum RouterType {
WebPush,
FCM,
Expand Down
1 change: 0 additions & 1 deletion autoendpoint/src/extractors/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ mod tests {
use crate::extractors::subscription::repad_base64;
use crate::headers::vapid::{VapidError, VapidHeader, VapidHeaderWithKey, VapidVersionData};
use autopush_common::util::sec_since_epoch;
use base64;
use std::str::FromStr;
use url::Url;

Expand Down
2 changes: 1 addition & 1 deletion autoendpoint/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ impl Settings {
panic_msg: &'static str,
) -> impl Iterator<Item = &'list str> {
if !(list_str.starts_with('[') && list_str.ends_with(']')) {
panic!(panic_msg);
panic!("{}", panic_msg);
}

let items = &list_str[1..list_str.len() - 1];
Expand Down
6 changes: 3 additions & 3 deletions autoendpoint/src/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ impl FromRequest for Tags {
}
}

impl Into<BTreeMap<String, String>> for Tags {
fn into(self) -> BTreeMap<String, String> {
impl From<Tags> for BTreeMap<String, String> {
fn from(tags: Tags) -> BTreeMap<String, String> {
let mut result = BTreeMap::new();

for (k, v) in self.tags {
for (k, v) in tags.tags {
result.insert(k.clone(), v.clone());
}

Expand Down
45 changes: 24 additions & 21 deletions autopush-common/src/db/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,30 @@ macro_rules! key_schema {

#[macro_export]
macro_rules! val {
(B => $val:expr) => {{
let mut attr = AttributeValue::default();
attr.b = Some($val);
attr
}};
(S => $val:expr) => {{
let mut attr = AttributeValue::default();
attr.s = Some($val.to_string());
attr
}};
(SS => $val:expr) => {{
let mut attr = AttributeValue::default();
let vals: Vec<String> = $val.iter().map(|v| v.to_string()).collect();
attr.ss = Some(vals);
attr
}};
(N => $val:expr) => {{
let mut attr = AttributeValue::default();
attr.n = Some($val.to_string());
attr
}};
(B => $val:expr) => {
AttributeValue {
b: Some($val),
..Default::default()
}
};
(S => $val:expr) => {
AttributeValue {
s: Some($val.to_string()),
..Default::default()
}
};
(SS => $val:expr) => {
AttributeValue {
ss: Some($val.iter().map(|v| v.to_string()).collect()),
..Default::default()
}
};
(N => $val:expr) => {
AttributeValue {
n: Some($val.to_string()),
..Default::default()
}
};
}

/// Create a **HashMap** from a list of key-value pairs
Expand Down
4 changes: 2 additions & 2 deletions autopush-common/src/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ impl DynamoStorage {
self.metrics.clone(),
table_name,
uaid,
11 as u32,
11,
))
} else {
Box::new(future::ok(Default::default()))
Expand Down Expand Up @@ -446,7 +446,7 @@ impl DynamoStorage {
table_name.as_ref(),
&uaid,
timestamp,
10 as u32,
10,
))
} else {
Box::new(future::ok(Default::default()))
Expand Down
2 changes: 1 addition & 1 deletion autopush-common/src/db/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ mod tests {

#[test]
fn test_parse_sort_key_bad_values() {
for val in vec!["02j3i2o", "03:ffas:wef", "01::mytopic", "02:oops:ohnoes"] {
for val in &["02j3i2o", "03:ffas:wef", "01::mytopic", "02:oops:ohnoes"] {
let key = DynamoDbNotification::parse_sort_key(val);
assert!(key.is_err());
}
Expand Down
2 changes: 1 addition & 1 deletion autopush/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ where
// only metric codes expected from the client (or 0)
let mcode = code
.and_then(|code| {
if code >= 301 && code <= 303 {
if (301..=303).contains(&code) {
Some(code)
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion autopush/src/megaphone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ mod tests {
let delta = tracker
.subscribe_to_broadcasts(
&mut broadcast_subs,
&vec![Broadcast {
&[Broadcast {
broadcast_id: String::from("bcastc"),
version: String::from("revision_alpha"),
}],
Expand Down
4 changes: 2 additions & 2 deletions autopush/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ impl Server {
}
}

#[allow(clippy::single_char_push_str)]
#[allow(clippy::single_char_add_str)]
fn new(opts: &Arc<ServerOptions>) -> Result<(Rc<Server>, Core)> {
let core = Core::new()?;
let broadcaster = if let Some(ref megaphone_url) = opts.megaphone_api_url {
Expand Down Expand Up @@ -714,7 +714,7 @@ impl Future for PingManager {
loop {
match self.client {
CloseState::Exchange(ref mut client) => try_ready!(client.poll()),
CloseState::Closing => return Ok(self.socket.borrow_mut().close()?),
CloseState::Closing => return self.socket.borrow_mut().close(),
}

self.client = CloseState::Closing;
Expand Down
18 changes: 11 additions & 7 deletions autopush/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ mod tests {

#[test]
fn test_router_url() {
let mut settings: Settings = Default::default();
settings.router_hostname = Some("testname".to_string());
settings.router_port = 80;
let mut settings = Settings {
router_hostname: Some("testname".to_string()),
router_port: 80,
..Default::default()
};
let url = settings.router_url();
assert_eq!("http://testname", url);

Expand All @@ -164,10 +166,12 @@ mod tests {

#[test]
fn test_endpoint_url() {
let mut settings: Settings = Default::default();
settings.endpoint_hostname = "testname".to_string();
settings.endpoint_port = 80;
settings.endpoint_scheme = "http".to_string();
let mut settings = Settings {
endpoint_hostname: "testname".to_string(),
endpoint_port: 80,
endpoint_scheme: "http".to_string(),
..Default::default()
};
let url = settings.endpoint_url();
assert_eq!("http://testname", url);

Expand Down

0 comments on commit 44c85c0

Please sign in to comment.