Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
feat: track nack's with metrics
Browse files Browse the repository at this point in the history
Closes #1063
  • Loading branch information
bbangert committed Nov 30, 2017
1 parent 5871294 commit 35770ae
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions autopush_rs/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ enum Call {
message_month: String,
messages: Vec<protocol::Notification>,
},

}

#[derive(Deserialize)]
Expand Down
10 changes: 10 additions & 0 deletions autopush_rs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,11 @@ where
ClientMessage::Unregister { channel_id, code } => {
self.data.process_unregister(channel_id, code)
}
ClientMessage::Nack { .. } => {
self.data.srv.metrics.incr("ua.command.nack").ok();
self.data.webpush.as_mut().unwrap().stats.nacks += 1;
ClientState::WaitingForAcks
}
ClientMessage::Ack { updates } => self.data.process_acks(updates),
_ => return Err("Invalid state transition".into()),
}
Expand All @@ -435,6 +440,11 @@ where
Either::A(ClientMessage::Unregister { channel_id, code }) => {
self.data.process_unregister(channel_id, code)
}
Either::A(ClientMessage::Nack { .. }) => {
self.data.srv.metrics.incr("ua.command.nack").ok();
self.data.webpush.as_mut().unwrap().stats.nacks += 1;
ClientState::WaitingForAcks
}
Either::B(ServerNotification::Notification(notif)) => {
let webpush = self.data.webpush.as_mut().unwrap();
webpush.unacked_direct_notifs.push(notif.clone());
Expand Down
6 changes: 6 additions & 0 deletions autopush_rs/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ pub enum ClientMessage {
},

Ack { updates: Vec<ClientAck> },

Nack {
code: Option<i32>,
version: String,
},

}

#[derive(Deserialize)]
Expand Down

0 comments on commit 35770ae

Please sign in to comment.