Skip to content

Conversation

@chrzaszcz
Copy link
Member

@chrzaszcz chrzaszcz commented Nov 21, 2025

The main goal is to allow injecting extra data into the generated push notifications for RabbitMQ as requested by @niecore.

I replaced the iteration over backend modules with a new hook push_event. By using a hook with handlers, one can implement a module that would insert some metadata in its handler to push_event. Such metadata would be later merged with the notification in the handler of mod_event_pusher_rabbit. If needed, the key-value pairs from metadata could event override existing event properties, but this is not recommended.

A module could also act as a filter, dropping selected events. An example of a module combining metadata with filtering is implemented as mod_event_pusher_filter.

I added tests in mod_event_pusher_rabbit_SUITE.

Note: Although only the Rabbit backend supports metadata, we could follow with other backends later - when there is need. Other backends simply ignore metadata for now.

@mongoose-im

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Nov 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.00%. Comparing base (b8fff1f) to head (a12ce09).
⚠️ Report is 13 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4578      +/-   ##
==========================================
+ Coverage   85.97%   86.00%   +0.02%     
==========================================
  Files         565      565              
  Lines       33880    33887       +7     
==========================================
+ Hits        29130    29144      +14     
+ Misses       4750     4743       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mongoose-im

This comment was marked as outdated.

This hook will replace the iteration over all push backends
- push_event_acc() is the hook acc containing mongoose_acc
  and a map of extensible metadata.
- push_event_params() are the hook params containing only the event.

Hook handlers can modify the acc and metadata, but not the event.
Metadata modified by a hook can be utilized by the subsequent hooks.
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

Currently, rabbit is the only one using metadata.
All handlers have the same priority, because there is no specific
ordering that would make sense here.
It demonstrates how the hook-and-handlers mechanism can be used to:
  - Filter events.
  - Insert additional metadata.
The example module mod_event_pusher_filter can be used to veridy if
both functions work as expected.
@mongoose-im

This comment was marked as outdated.

- Delete functions having calls now
- Add delete_handler/5 because mod_event_pusher_push is no longer
  using this.
  Sadly ejabberd_sm uses add_handler but not delete_handler...
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

Also:
- Restructure the docs
  - Start with a simple introduction
  - Follow with configuration
  - Only then provide developer's info
- Update migration guide
@mongoose-im
Copy link
Collaborator

mongoose-im commented Nov 24, 2025

elasticsearch_and_cassandra_28 / elasticsearch_and_cassandra_mnesia / a12ce09
Reports root/ big
OK: 683 / Failed: 0 / User-skipped: 72 / Auto-skipped: 0


small_tests_28 / small_tests / a12ce09
Reports root / small


small_tests_27 / small_tests / a12ce09
Reports root / small


small_tests_28_arm64 / small_tests / a12ce09
Reports root / small


ldap_mnesia_28 / ldap_mnesia / a12ce09
Reports root/ big
OK: 2348 / Failed: 0 / User-skipped: 1359 / Auto-skipped: 0


ldap_mnesia_27 / ldap_mnesia / a12ce09
Reports root/ big
OK: 2348 / Failed: 0 / User-skipped: 1359 / Auto-skipped: 0


dynamic_domains_mysql_redis_28 / mysql_redis / a12ce09
Reports root/ big
OK: 5179 / Failed: 0 / User-skipped: 154 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_27 / pgsql_mnesia / a12ce09
Reports root/ big
OK: 5214 / Failed: 0 / User-skipped: 119 / Auto-skipped: 0


internal_mnesia_28 / internal_mnesia / a12ce09
Reports root/ big
OK: 2489 / Failed: 0 / User-skipped: 1218 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_28 / pgsql_mnesia / a12ce09
Reports root/ big
OK: 5214 / Failed: 0 / User-skipped: 119 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_28 / odbc_mssql_mnesia / a12ce09
Reports root/ big
OK: 5209 / Failed: 0 / User-skipped: 124 / Auto-skipped: 0


pgsql_cets_28 / pgsql_cets / a12ce09
Reports root/ big
OK: 5301 / Failed: 0 / User-skipped: 195 / Auto-skipped: 0


cockroachdb_cets_28 / cockroachdb_cets / a12ce09
Reports root/ big
OK: 5303 / Failed: 1 / User-skipped: 195 / Auto-skipped: 0

pubsub_SUITE:tree+last_item_cache:send_last_published_item_no_items_test
{error,
  {timeout_when_waiting_for_stanza,
    [{escalus_client,wait_for_stanza,
       [{client,
          <<"alice_send_last_published_item_no_items_test_3712@localhost/res1">>,
          escalus_tcp,<0.116778.0>,
          [{event_manager,<0.116767.0>},
           {server,<<"localhost">>},
           {username,
             <<"alicE_send_last_published_item_no_items_test_3712">>},
           {resource,<<"res1">>}],
          [{event_client,
             [{event_manager,<0.116767.0>},
            {server,<<"localhost">>},
            {username,
              <<"alicE_send_last_published_item_no_items_test_3712">>},
            {resource,<<"res1">>}]},
           {resource,<<"res1">>},
           {username,
             <<"alice_send_last_published_item_no_items_test_3712">>},
           {server,<<"localhost">>},
           {host,<<"localhost">>},
           {port,5222},
           {auth,fun escalus_auth:auth_plain/2},
           {wspath,undefined},
           {username,
             <<"alicE_send_last_published_item_no_items_test_3712">>},
           {server,<<"localhost">>},
           {password,<<"matygrysa">>},
           {stream_id,<<"55ea4aef3cf3e2b3">>}]},
        5000],
       [{file,
          "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_client.erl"},
        {line,136}]},
     {pubsub_tools,receive_response,3,
       [{file,"/home/circleci/project/big_tests/tests/pubsub_tools.erl"},
        {line,444}]},
     {pubsub_tools,receive_and_c...

Report log


mysql_redis_28 / mysql_redis / a12ce09
Reports root/ big
OK: 5590 / Failed: 1 / User-skipped: 149 / Auto-skipped: 0

acc_e2e_SUITE:cache_and_strip:filter_local_packet_uses_recipient_values
{error,
  {timeout_when_waiting_for_stanza,
    [{escalus_client,wait_for_stanza,
       [{client,
          <<"bob_filter_local_packet_uses_recipient_values_20@localhost/res1">>,
          escalus_tcp,<0.827.0>,
          [{event_manager,<0.825.0>},
           {server,<<"localhost">>},
           {username,
             <<"bOb_filter_local_packet_uses_recipient_values_20">>},
           {resource,<<"res1">>}],
          [{event_client,
             [{event_manager,<0.825.0>},
            {server,<<"localhost">>},
            {username,
              <<"bOb_filter_local_packet_uses_recipient_values_20">>},
            {resource,<<"res1">>}]},
           {resource,<<"res1">>},
           {username,
             <<"bob_filter_local_packet_uses_recipient_values_20">>},
           {server,<<"localhost">>},
           {host,<<"localhost">>},
           {port,5222},
           {auth,fun escalus_auth:auth_plain/2},
           {wspath,undefined},
           {username,
             <<"bOb_filter_local_packet_uses_recipient_values_20">>},
           {server,<<"localhost">>},
           {password,<<"makrolika">>},
           {stream_id,<<"d65d8938b18bc0a2">>}]},
        5000],
       [{file,
          "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_client.erl"},
        {line,136}]},
     {acc_e2e_SUITE,
       '-filter_local_packet_uses_recipient_values/1-fun-0-',2,
       [{file,
          "/home/circleci/project/big_tests/tests/acc_e2e_SUITE.erl"},
        {l...

Report log


pgsql_mnesia_28 / pgsql_mnesia / a12ce09
Reports root/ big
OK: 5604 / Failed: 0 / User-skipped: 135 / Auto-skipped: 0


pgsql_mnesia_27 / pgsql_mnesia / a12ce09
Reports root/ big
OK: 5604 / Failed: 0 / User-skipped: 135 / Auto-skipped: 0


mssql_mnesia_28 / odbc_mssql_mnesia / a12ce09
Reports root/ big
OK: 5599 / Failed: 0 / User-skipped: 140 / Auto-skipped: 0

@chrzaszcz chrzaszcz marked this pull request as ready for review November 24, 2025 12:59
Copy link
Member

@telezynski telezynski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, useful mechanism to extend event processing!

@telezynski telezynski merged commit 8016f27 into master Nov 24, 2025
4 checks passed
@telezynski telezynski deleted the event-metadata branch November 24, 2025 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants