Struct autoendpoint::routers::webpush::WebPushRouter
source · pub struct WebPushRouter {
pub db: Box<dyn DbClient>,
pub metrics: Arc<StatsdClient>,
pub http: Client,
pub endpoint_url: Url,
}
Expand description
The router for desktop user agents.
These agents are connected via an Autopush connection server. The correct server is located via the database routing table. If the server is busy or not available, the notification is stored in the database.
Fields§
§db: Box<dyn DbClient>
§metrics: Arc<StatsdClient>
§http: Client
§endpoint_url: Url
Implementations§
source§impl WebPushRouter
impl WebPushRouter
sourcefn handle_error(
&self,
error: ApiErrorKind,
vapid: Option<VapidHeaderWithKey>,
) -> ApiError
fn handle_error( &self, error: ApiErrorKind, vapid: Option<VapidHeaderWithKey>, ) -> ApiError
Use the same sort of error chokepoint that all the mobile clients use.
sourceasync fn send_notification(
&self,
notification: &Notification,
node_id: &str,
) -> Result<Response, ApiError>
async fn send_notification( &self, notification: &Notification, node_id: &str, ) -> Result<Response, ApiError>
Send the notification to the node
sourceasync fn trigger_notification_check(
&self,
uaid: &Uuid,
node_id: &str,
) -> Result<Response, Error>
async fn trigger_notification_check( &self, uaid: &Uuid, node_id: &str, ) -> Result<Response, Error>
Notify the node to check for notifications for the user
sourceasync fn store_notification(
&self,
notification: &Notification,
) -> Result<(), ApiError>
async fn store_notification( &self, notification: &Notification, ) -> Result<(), ApiError>
Store a notification in the database
sourceasync fn remove_node_id(
&self,
user: &User,
node_id: &str,
) -> Result<(), ApiError>
async fn remove_node_id( &self, user: &User, node_id: &str, ) -> Result<(), ApiError>
Remove the node ID from a user. This is done if the user is no longer connected to the node.
sourcefn make_delivered_response(&self, notification: &Notification) -> RouterResponse
fn make_delivered_response(&self, notification: &Notification) -> RouterResponse
Update metrics and create a response for when a notification has been directly forwarded to an autopush server.
sourcefn make_stored_response(&self, notification: &Notification) -> RouterResponse
fn make_stored_response(&self, notification: &Notification) -> RouterResponse
Update metrics and create a response for when a notification has been stored in the database for future transmission.
sourcefn make_response(
&self,
notification: &Notification,
destination_tag: &str,
status: StatusCode,
) -> RouterResponse
fn make_response( &self, notification: &Notification, destination_tag: &str, status: StatusCode, ) -> RouterResponse
Update metrics and create a response after routing a notification
Trait Implementations§
source§impl Router for WebPushRouter
impl Router for WebPushRouter
source§fn register(
&self,
_router_input: &RouterDataInput,
_app_id: &str,
) -> Result<HashMap<String, Value, RandomState>, RouterError>
fn register( &self, _router_input: &RouterDataInput, _app_id: &str, ) -> Result<HashMap<String, Value, RandomState>, RouterError>
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,
Auto Trait Implementations§
impl Freeze for WebPushRouter
impl !RefUnwindSafe for WebPushRouter
impl Send for WebPushRouter
impl Sync for WebPushRouter
impl Unpin for WebPushRouter
impl !UnwindSafe for WebPushRouter
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