stasis: Add internal filtering of messages.

This change adds the ability for subscriptions to indicate
which message types they are interested in accepting. By
doing so the filtering is done before being dispatched
to the subscriber, reducing the amount of work that has
to be done.

This is optional and if a subscriber does not add
message types they wish to accept and set the subscription
to selective filtering the previous behavior is preserved
and they receive all messages.

There is also the ability to explicitly force the reception
of all messages for cases such as AMI or ARI where a large
number of messages are expected that are then generically
converted into a different format.

ASTERISK-28103

Change-Id: I99bee23895baa0a117985d51683f7963b77aa190
This commit is contained in:
Joshua Colp
2018-09-23 17:50:01 -03:00
parent 915b80709d
commit 3077ad0c24
33 changed files with 457 additions and 17 deletions

View File

@@ -269,6 +269,9 @@ static struct mwi_stasis_subscription *mwi_stasis_subscription_alloc(const char
ao2_ref(mwi_sub, -1);
mwi_stasis_sub = NULL;
}
stasis_subscription_accept_message_type(mwi_stasis_sub->stasis_sub, ast_mwi_state_type());
stasis_subscription_accept_message_type(mwi_stasis_sub->stasis_sub, stasis_subscription_change_type());
stasis_subscription_set_filter(mwi_stasis_sub->stasis_sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);
return mwi_stasis_sub;
}
@@ -1364,7 +1367,11 @@ static int load_module(void)
if (ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)) {
ast_sip_push_task(NULL, send_initial_notify_all, NULL);
} else {
stasis_subscribe_pool(ast_manager_get_topic(), mwi_startup_event_cb, NULL);
struct stasis_subscription *sub;
sub = stasis_subscribe_pool(ast_manager_get_topic(), mwi_startup_event_cb, NULL);
stasis_subscription_accept_message_type(sub, ast_manager_get_generic_type());
stasis_subscription_set_filter(sub, STASIS_SUBSCRIPTION_FILTER_SELECTIVE);
}
}