-
Notifications
You must be signed in to change notification settings - Fork 428
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
Prepare mod_disco for dynamic domains #3128
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3128 +/- ##
==========================================
+ Coverage 79.47% 79.52% +0.05%
==========================================
Files 396 397 +1
Lines 32419 32325 -94
==========================================
- Hits 25764 25708 -56
+ Misses 6655 6617 -38
Continue to review full report at Codecov.
|
80160eb
to
1bb13e5
Compare
It is added in a separate module to avoid calling mod_disco from other extension modules (module decoupling).
Also: add missing 'drop' condition to the AMP features.
They are already registered by ejabberd_local with the IQ handler.
It was already registered with the IQ handler. There was a double bug as well that caused the tests to pass: - Wrong group name caused extdisco NOT to start - Wrong IQ handler module caused extdisco NOT to stop correctly
It was already registered with the IQ handler.
It was already registered with the IQ handler.
It will be used by modules that need to get registered features and are not returning IQ errors. Error handling can be changed in the future if needed.
Rework feature discovery to use the hooks for disco. Additional features are added in place, as adding hooks brings no benefits in custom handlers. Also: - Use the disco hook in mod_muc (required for mod_mam_muc features) - Move 'features_to_xml' to a helper module Note: This commit breaks MUC Light tests because of the change in mod_mam_muc.
This commit fixes big tests.
Instead: register only the necessary IQ handler directly This makes the module responsible for its IQ handlers, as it should be.
Use the hooks instead. New ETS table is used for efficient lookup of the NS list.
They are unused, hooks are used instead.
- Remove unnecessary error handling (no errors are returned form handlers anymore) - Remove unnecessary support for feature tuples (no tuples are returned from handlers anymore) - Add type specs
Update the interface and the helperes in mongoose_disco. A map is used to guarantee unique JID's in the result. This commit breaks tests as the modules need to be updated.
Also: - Fix a bug in get_module_opt - Fix the tests to detect the bug
Also: - use add_features as well - add missing disco tests - remove nested hook with only one handler %adhoc fix
Change the test to check that the name is included.
This commit fixes the tests as all modules are reworked now.
1bb13e5
to
612fa3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like these changes, special thanks for SUITEs extension.
@@ -688,7 +695,8 @@ config_metrics(HostType) -> | |||
|
|||
-spec hooks(jid:lserver()) -> [ejabberd_hooks:hook()]. | |||
hooks(HostType) -> | |||
[{user_send_packet, HostType, ?MODULE, user_send_packet, 60}, | |||
[{disco_local_features, HostType, ?MODULE, add_local_features, 99}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe {disco_local_features, HostType, ?MODULE, disco_local_features, 99}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name would be consistent with the hook, but on the other hand add_local_features
is more descriptive as the features are added to the list... Anyway, I can make the handler names more consistent in part 2 (there is more of them and they are mostly called add_local_features
).
still LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love these changes! 😄
gen_iq_handler:add_iq_handler(ejabberd_local, Host, | ||
?NS_EXTDISCO, ?MODULE, process_iq, IQDisc). | ||
|
||
-spec stop(jid:server()) -> ok. | ||
stop(Host) -> | ||
mod_disco:unregister_feature(Host, ?NS_EXTDISCO), | ||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_EXTDISCO). | ||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_EXTDISCO). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good one!
Untangle the service discovery logic according to the following rules:
mod_disco
. In general, a module shouldn't call other extension modules unless they are connected withdeps
.register_feature
.mod_disco
shouldn't keep its state in ETS tables. There is no need for state when the hooks are used.Common logic for handling the hooks is extracted to
mongoose_disco
. It has helpers fordisco_local_features
anddisco_local_items
right now.A lot of new tests for service discovery are added as well.
To do:
disco_local_identity
anddisco_sm_*
consistent with the functions already changed.mod_disco
andmongoose_disco
.Both changes can be done in one PR.