autopush.router.interface

Router interface

class autopush.router.interface.RouterResponse(status_code=200, response_body='', router_data=None, headers=None, errno=None, logged_status=None)[source]

Router response if routing has succeeded.

If the router data needs to change as a result of this message, either the router got invalidated, or needs updating, then the router_data should be set.

__init__(status_code=200, response_body='', router_data=None, headers=None, errno=None, logged_status=None)[source]

Create a new RouterResponse

class autopush.router.interface.IRouter(conf, router_conf, **kwargs)[source]
__init__(conf, router_conf, **kwargs)[source]

Initialize the Router to handle notifications and registrations with the given conf and router conf.

register(uaid, router_data, app_id, *args, **kwargs)[source]

Register the uaid with router_data however is preferred prior to storing router_data for this user.

Parameters:
  • uaid – User Agent Identifier
  • router_data – Route specific configuration info
  • app_id – Application identifier from URI
Raises:

RouterException if data supplied is invalid.

amend_endpoint_response(response, router_data)[source]

Modify an outbound Endpoint registration response to include router info.

Some routers require additional info to be returned to clients.

Parameters:
  • response – The response data to be sent to the client
  • router_data – Route specific configuration info
route_notification(notification, uaid_data)[source]

Route a notification

Parameters:
  • notification – A Notificaiton instance.
  • uaid_data – A dict of the full user item from the db record.
Returns:

A response object upon successful routing.

Return type:

RouterResponse

Raises:

RouterException if routing fails.

This function runs in the main reactor, if a yield is needed then a deferred must be returned for the callback chain.