Notification

Struct Notification 

Source
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: String

Unique message_id for this notification

§subscription: Subscription

The subscription information block

§headers: NotificationHeaders

Set of associated crypto headers

§timestamp: u64

UNIX timestamp in seconds

§sort_key_timestamp: u64

UNIX 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

Source

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)
Source

pub fn has_topic(&self) -> bool

Source

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.

Source

pub async fn record_reliability( &mut self, reliability: &PushReliability, state: ReliabilityState, )

Trait Implementations§

Source§

impl Debug for Notification

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Notification

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<&Notification> for Notification

Source§

fn from(notification: &Notification) -> Self

Converts to this type from the input type.
Source§

impl From<Notification> for Notification

Source§

fn from(notification: Notification) -> Self

Converts to this type from the input type.
Source§

impl FromRequest for Notification

Source§

type Error = ApiError

The associated error which can be returned.
Source§

type Future = Pin<Box<dyn Future<Output = Result<Notification, <Notification as FromRequest>::Error>>>>

Future that resolves to a Self. Read more
Source§

fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future

Create a Self from request parts asynchronously.
§

fn extract(req: &HttpRequest) -> Self::Future

Create a Self from request head asynchronously. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Any for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

§

fn type_name(&self) -> &'static str

§

impl<T> AnySync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> SendSyncUnwindSafe for T
where T: Send + Sync + UnwindSafe + ?Sized,