pub struct ApnsRouter {
clients: HashMap<String, ApnsClientData>,
settings: ApnsSettings,
endpoint_url: Url,
metrics: Arc<StatsdClient>,
db: Box<dyn DbClient>,
}
Expand description
Apple Push Notification Service router
Fields§
§clients: HashMap<String, ApnsClientData>
A map from release channel to APNS client
settings: ApnsSettings
§endpoint_url: Url
§metrics: Arc<StatsdClient>
§db: Box<dyn DbClient>
Implementations§
source§impl ApnsRouter
impl ApnsRouter
sourcepub async fn new(
settings: ApnsSettings,
endpoint_url: Url,
metrics: Arc<StatsdClient>,
db: Box<dyn DbClient>,
) -> Result<Self, ApnsError>
pub async fn new( settings: ApnsSettings, endpoint_url: Url, metrics: Arc<StatsdClient>, db: Box<dyn DbClient>, ) -> Result<Self, ApnsError>
Create a new APNS router. APNS clients will be initialized for each channel listed in the settings.
sourceasync fn create_client(
name: String,
settings: ApnsChannel,
) -> Result<(String, ApnsClientData), ApnsError>
async fn create_client( name: String, settings: ApnsChannel, ) -> Result<(String, ApnsClientData), ApnsError>
Create an APNS client for the channel
sourcefn default_aps<'a>() -> DefaultNotificationBuilder<'a>
fn default_aps<'a>() -> DefaultNotificationBuilder<'a>
The default APS data for a notification
sourceasync fn handle_error(
&self,
error: Error,
uaid: Uuid,
channel: &str,
) -> ApiError
async fn handle_error( &self, error: Error, uaid: Uuid, channel: &str, ) -> ApiError
Handle an error by logging, updating metrics, etc
sourcefn derive_aps<'a>(
&self,
replacement: Value,
holder: &'a mut ApsAlertHolder,
) -> Result<DefaultNotificationBuilder<'a>, ApnsError>
fn derive_aps<'a>( &self, replacement: Value, holder: &'a mut ApsAlertHolder, ) -> Result<DefaultNotificationBuilder<'a>, ApnsError>
Derive an APS message from the replacement JSON block.
This requires an external “holder” that contains the data that APS will refer to.
The holder should live in the same context as the aps.build()
method.
Trait Implementations§
source§impl Router for ApnsRouter
impl Router for ApnsRouter
source§fn register(
&self,
router_input: &RouterDataInput,
app_id: &str,
) -> Result<HashMap<String, Value>, RouterError>
fn register( &self, router_input: &RouterDataInput, app_id: &str, ) -> Result<HashMap<String, Value>, RouterError>
Validate that the user can use this router, and return data to be stored in
the user’s
router_data
field.source§fn route_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
notification: &'life1 Notification,
) -> Pin<Box<dyn Future<Output = Result<RouterResponse, ApiError>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn route_notification<'life0, 'life1, 'async_trait>(
&'life0 self,
notification: &'life1 Notification,
) -> Pin<Box<dyn Future<Output = Result<RouterResponse, ApiError>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Route a notification to the user
Auto Trait Implementations§
impl Freeze for ApnsRouter
impl !RefUnwindSafe for ApnsRouter
impl Send for ApnsRouter
impl Sync for ApnsRouter
impl Unpin for ApnsRouter
impl !UnwindSafe for ApnsRouter
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
Mutably borrows from an owned value. Read more
§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>
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 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>
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