Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Service and module options only in maps #3625

Merged
merged 19 commits into from
Apr 8, 2022
Merged

Conversation

chrzaszcz
Copy link
Member

@chrzaszcz chrzaszcz commented Apr 6, 2022

The main change is to accept only lists for module and service options. There are multiple related small corrections and fixes as well:

  • Use mongoose_config more directly in gen_mod, add lookup_module_opts to encourage using it instead of adding undefined as the default value
  • Remove all usage of gen_mod:get_* for anything different than module options - use proplists or maps depending on the data structure
  • Add missing options, remove unused config options
  • Clean up small tests, add missing tests
  • Remove gen_mod:start_backend_module/3 and use backend_module directly in the last unconverted module, which is mod_pubsub. There is no benefit in using gen_mod here.
  • Remove the function for obtaining module metrics with custom defaults.

Also: pass a map to mongoose_backend
@mongoose-im

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Apr 6, 2022

Codecov Report

Merging #3625 (d539679) into master (cc1c119) will decrease coverage by 4.74%.
The diff coverage is 95.45%.

@@            Coverage Diff             @@
##           master    #3625      +/-   ##
==========================================
- Coverage   81.00%   76.26%   -4.75%     
==========================================
  Files         427      427              
  Lines       32126    32098      -28     
==========================================
- Hits        26025    24479    -1546     
- Misses       6101     7619    +1518     
Impacted Files Coverage Δ
src/config/mongoose_config_spec.erl 99.21% <ø> (-0.01%) ⬇️
src/ejabberd_sm_backend.erl 90.00% <ø> (ø)
src/ejabberd_sm_mnesia.erl 96.55% <ø> (ø)
src/ejabberd_sm_redis.erl 94.64% <ø> (ø)
src/event_pusher/mod_event_pusher_push.erl 94.79% <ø> (-0.06%) ⬇️
src/gen_mod_deps.erl 97.10% <ø> (+1.38%) ⬆️
src/mam/mod_mam_meta.erl 92.20% <ø> (-5.20%) ⬇️
src/mam/mod_mam_muc.erl 74.76% <ø> (ø)
src/mod_caps.erl 75.34% <ø> (ø)
src/mod_dynamic_domains_test.erl 0.00% <0.00%> (ø)
... and 65 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40d41ee...d539679. Read the comment docs.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

mod_websockets is actually not a gen_mod. It could be renamed.
This module is used for modules that are not gen_mod's,
thus maps are more appropriate.
Make the option-less modules use an empty map
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

- Add lookup_module_opts to gen_mod
  It is less error-prone than plugging in 'undefined' as default

- Use mongoose_config directly in gen_mod getters

Also:
  - improve test coverage
  - use the already existing check for is_exported
Remove the default and use maps - done for simple cases,
as some pubsub logic is obtaining options for non-existing hosts.
This would require more substantial rework.
mod_pubsub is the last module to use the dynamic compilation,
and it is doing so in a direct way.
Previously defaults were used even if MUC(Light) was not enabled.
@mongoose-im

This comment was marked as outdated.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Apr 7, 2022

small_tests_24 / small_tests / 840ee05
Reports root / small


small_tests_23 / small_tests / 840ee05
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 840ee05
Reports root/ big
OK: 2858 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 840ee05
Reports root/ big
OK: 2840 / Failed: 1 / User-skipped: 150 / Auto-skipped: 0

sm_SUITE:parallel_manual_ack_freq_1:resume_session_state_send_message_without_ack
{error,
  {{assertion_failed,assert,is_presence,
     {xmlel,<<"message">>,
       [{<<"from">>,
         <<"bOb_resume_session_state_send_message_without_ack_1926@domain.example.com/escalus-default-resource">>},
        {<<"to">>,
         <<"alicE_resume_session_state_send_message_without_ack_1935@domain.example.com">>},
        {<<"xml:lang">>,<<"en">>},
        {<<"type">>,<<"chat">>}],
       [{xmlel,<<"body">>,[],[{xmlcdata,<<"msg-3">>}]},
        {xmlel,<<"delay">>,
          [{<<"xmlns">>,<<"urn:xmpp:delay">>},
           {<<"stamp">>,<<"2022-04-07T12:20:40.754781Z">>},
           {<<"from">>,<<"domain.example.com">>}],
          [{xmlcdata,<<"Offline Storage">>}]}]},
     "<message from='bOb_resume_session_state_send_message_without_ack_1926@domain.example.com/escalus-default-resource' to='alicE_resume_session_state_send_message_without_ack_1935@domain.example.com' xml:lang='en' type='chat'><body>msg-3</body><delay xmlns='urn:xmpp:delay' stamp='2022-04-07T12:20:40.754781Z' from='domain.example.com'>Offline Storage</delay></message>"},
   [{escalus_new_assert,assert_true,2,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_new_assert.erl"},
       {line,84}]},
    {sm_helper,initial_presence_step,2,
      [{file,"/home/circleci/project/big_tests/tests/sm_helper.erl"},
       {line,133}]},
    {escalus_connection,connection_step,2,
      [{file,
         "/home/circleci/project/big_tests/_build/default/lib/escalus/src/escal...

Report log


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 840ee05
Reports root/ big
OK: 2858 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 840ee05
Reports root/ big
OK: 2858 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 840ee05
Reports root/ big
OK: 1506 / Failed: 0 / User-skipped: 401 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 840ee05
Reports root/ big
OK: 1506 / Failed: 0 / User-skipped: 401 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 840ee05
Reports root/ big
OK: 1547 / Failed: 0 / User-skipped: 360 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 840ee05
Reports root/ big
OK: 3232 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 840ee05
Reports root/ big
OK: 1854 / Failed: 0 / User-skipped: 368 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 840ee05
Reports root/ big
OK: 3232 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 840ee05
Reports root/ big
OK: 3227 / Failed: 0 / User-skipped: 147 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 840ee05
Reports root/ big
OK: 3232 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 840ee05
Reports root/ big
OK: 1697 / Failed: 0 / User-skipped: 367 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 840ee05
Reports root/ big
OK: 2841 / Failed: 0 / User-skipped: 150 / Auto-skipped: 0

@chrzaszcz chrzaszcz marked this pull request as ready for review April 7, 2022 12:43
@mongoose-im
Copy link
Collaborator

mongoose-im commented Apr 7, 2022

small_tests_24 / small_tests / d539679
Reports root / small


small_tests_23 / small_tests / d539679
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / d539679
Reports root/ big
OK: 2858 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / d539679
Reports root/ big
OK: 2841 / Failed: 0 / User-skipped: 150 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / d539679
Reports root/ big
OK: 2858 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / d539679
Reports root/ big
OK: 1506 / Failed: 0 / User-skipped: 401 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / d539679
Reports root/ big
OK: 1506 / Failed: 0 / User-skipped: 401 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / d539679
Reports root/ big
OK: 1547 / Failed: 0 / User-skipped: 360 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / d539679
Reports root/ big
OK: 3232 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / d539679
Reports root/ big
OK: 2858 / Failed: 0 / User-skipped: 133 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / d539679
Reports root/ big
OK: 3232 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / d539679
Reports root/ big
OK: 3227 / Failed: 0 / User-skipped: 147 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / d539679
Reports root/ big
OK: 1854 / Failed: 0 / User-skipped: 368 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / d539679
Reports root/ big
OK: 3232 / Failed: 0 / User-skipped: 142 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / d539679
Reports root/ big
OK: 1697 / Failed: 0 / User-skipped: 367 / Auto-skipped: 0

Copy link
Contributor

@Premwoik Premwoik 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 to me. I am not experienced in this area though, but I tried to keep up with the changes :) I have one small comment.

src/wpool/mongoose_wpool_rdbms.erl Show resolved Hide resolved
@Premwoik Premwoik merged commit 5d9089b into master Apr 8, 2022
@Premwoik Premwoik deleted the options-only-in-maps branch April 8, 2022 06:44
@Premwoik Premwoik added this to the 5.1.0 milestone May 25, 2022
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.

3 participants