stasis / manager / ari: Better filter messages.

Previously both AMI and ARI used a default route on
their stasis message router to handle some of the
messages for publishing out their respective
connection. This caused messages to be given to
their subscription that could not be formatted
into AMI or JSON.

This change adds an API call to the stasis message
router which allows a default route to be set as well
as formatters that the default route is expecting.
This allows both AMI and ARI to specify that their
default route only wants messages of their given
formatter. By doing so stasis can more intelligently
filter at publishing time so that they do not receive
messages which will not be turned into AMI or JSON.

ASTERISK-28244

Change-Id: I65272819a53ce99f869181d1d370da559a7d1703
This commit is contained in:
Joshua C. Colp
2019-01-10 15:34:32 -04:00
parent 44a862fb57
commit fcd07c34fb
5 changed files with 68 additions and 16 deletions

View File

@@ -238,7 +238,7 @@ void stasis_message_router_remove_cache_update(
* \brief Sets the default route of a router.
*
* \param router Router to set the default route of.
* \param callback Callback to forard messages which otherwise have no home.
* \param callback Callback to forward messages which otherwise have no home.
* \param data Data pointer to pass to \a callback.
*
* \retval 0 on success
@@ -254,6 +254,27 @@ int stasis_message_router_set_default(struct stasis_message_router *router,
stasis_subscription_cb callback,
void *data);
/*!
* \brief Sets the default route of a router with formatters.
*
* \param router Router to set the default route of.
* \param callback Callback to forward messages which otherwise have no home.
* \param data Data pointer to pass to \a callback.
* \param formatters A bitmap of \ref stasis_subscription_message_formatters we wish to receive.
*
* \since 13.26.0
* \since 16.3.0
*
* \note If formatters are specified then the message router will remain in a selective
* filtering state. Any explicit routes will receive messages of their message type and
* the default callback will only receive messages that have one of the given formatters.
* Explicit routes will not be filtered according to the given formatters.
*/
void stasis_message_router_set_formatters_default(struct stasis_message_router *router,
stasis_subscription_cb callback,
void *data,
enum stasis_subscription_message_formatters formatters);
/*!
* \brief Indicate to a message router that we are interested in messages with one or more formatters.
*