pub struct Notification {
pub message_id: String,
pub subscription: Subscription,
pub headers: NotificationHeaders,
pub timestamp: u64,
pub sort_key_timestamp: u64,
pub data: Option<String>,
pub reliable_state: Option<ReliabilityState>,
pub reliability_id: Option<String>,
pub(crate) in_process_counter: Arc<AtomicUsize>,
}Expand description
Extracts notification data from Subscription and request data
Fields§
§message_id: StringUnique message_id for this notification
subscription: SubscriptionThe subscription information block
headers: NotificationHeadersSet of associated crypto headers
timestamp: u64UNIX timestamp in seconds
sort_key_timestamp: u64UNIX timestamp in milliseconds
data: Option<String>The encrypted notification body
reliable_state: Option<ReliabilityState>The current state the message was in (if tracked)
reliability_id: Option<String>§in_process_counter: Arc<AtomicUsize>Internal reference to the appstate count of in process notifications. Note: This only tracks notifications that have been delivered from a subscription provider. This does not track notifications that may have been retrieved from storage. This counter is in response to an incident where a large number of valid, inbound notifications caused a cascade impact on our storage engine, which resulted in a node OOM error killing the process. This metric will be reported as part of the health check to allow the load balancer to make informed routing decisions.
Implementations§
Source§impl Notification
impl Notification
Sourcefn generate_message_id(
fernet: &MultiFernet,
uaid: Uuid,
channel_id: Uuid,
topic: Option<&str>,
timestamp: u64,
) -> String
fn generate_message_id( fernet: &MultiFernet, uaid: Uuid, channel_id: Uuid, topic: Option<&str>, timestamp: u64, ) -> String
Generate a message-id suitable for accessing the message
For topic messages, a sort_key version of 01 is used, and the topic is included for reference:
Encrypted('01' : uaid.hex : channel_id.hex : topic)For non-topic messages, a sort_key version of 02 is used:
Encrypted('02' : uaid.hex : channel_id.hex : timestamp)pub fn has_topic(&self) -> bool
Sourcepub fn serialize_for_delivery(
&self,
) -> Result<TransportNotification<'_>, ApiError>
pub fn serialize_for_delivery( &self, ) -> Result<TransportNotification<'_>, ApiError>
Serialize the notification for delivery to the connection server. Some
fields in autopush_common’s Notification are marked with
#[serde(skip_serializing)] so they are not shown to the UA. These
fields are still required when delivering to the connection server, so
we can’t simply convert this notification type to that one and serialize
via serde.
pub async fn record_reliability( &mut self, reliability: &PushReliability, state: ReliabilityState, )
Trait Implementations§
Source§impl Debug for Notification
impl Debug for Notification
Source§impl Drop for Notification
impl Drop for Notification
Source§impl From<&Notification> for Notification
impl From<&Notification> for Notification
Source§fn from(notification: &Notification) -> Self
fn from(notification: &Notification) -> Self
Source§impl From<Notification> for Notification
impl From<Notification> for Notification
Source§fn from(notification: Notification) -> Self
fn from(notification: Notification) -> Self
Source§impl FromRequest for Notification
impl FromRequest for Notification
Source§type Future = Pin<Box<dyn Future<Output = Result<Notification, <Notification as FromRequest>::Error>>>>
type Future = Pin<Box<dyn Future<Output = Result<Notification, <Notification as FromRequest>::Error>>>>
Self. Read moreSource§fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future
fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future
Self from request parts asynchronously.Auto Trait Implementations§
impl Freeze for Notification
impl RefUnwindSafe for Notification
impl Send for Notification
impl Sync for Notification
impl Unpin for Notification
impl UnwindSafe for Notification
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more