-
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
Multi tenancy hooks #3089
Multi tenancy hooks #3089
Conversation
49fe2cd
to
c54c66f
Compare
Codecov Report
@@ Coverage Diff @@
## multi-tenancy-phase-1 #3089 +/- ##
=========================================================
+ Coverage 78.09% 78.74% +0.64%
=========================================================
Files 374 387 +13
Lines 31219 31691 +472
=========================================================
+ Hits 24382 24954 +572
+ Misses 6837 6737 -100
Continue to review full report at Codecov.
|
…are wrapped in mongoose_hooks module. hint: all inderect calls to ejabberd_hooks found using 'ejabberd_hooks[^:]' search regex
2150d7f
to
159e5c4
Compare
159e5c4
to
d14cbcc
Compare
a22f2e4
to
4b3eec4
Compare
4b3eec4
to
2bb821f
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 appreciate the huge amount of good work, especially putting the defaults in mongoose_hooks
. I have a few comments:
- Are you planning to use
mongoose_acc:get_host_type
inside the hooks to get rid of thehost_type
argument for each of them? For me it looks like a natural follow-up. - Please revise the line breaks in
mongoose_hooks
to break the comments so that expressions likea server
,the client
,should be
,client jid
etc remain in one line. I think it's good practice to do so.
The idea was to reduce calls to mongoose_acc:get_host_type/1 as much as possible. Ideally it should be limited to just one call per incoming message (to identify receiver's host_type, if required), we don't want it to become a bottleneck. |
We could always ask for acc argument, that would have host_type field. But it's more lines of code to change :D And after that we could pass Acc everywhere, even into the backend functions. |
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.
One minor comment, please tell me whether you are correcting it or if I should merge.
%% new with 'undefined' host type | ||
Acc2 = mongoose_acc:new(AccParams#{lserver => <<"unknown.host1">>}), | ||
%% host type changes from <<"host 1">> to 'undefined' | ||
Acc2 = mongoose_acc:strip(StripParams#{lserver => <<"unknown.host1">>},Acc1), |
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.
Minor: missing commas before Acc1
, this happens a few times below.
this PR reworks
ejabberd_hooks
in the following way:mongoose_hooks
module.mongoose_hooks
module. It should not be possible to run the hook with another initial acc value.mongoose_acc:t()
type is extended withhost_type
field, this allows to reduce the number of calls tomongoose_domain_api:get_host_type/1
function.host_type
, note that only hooks execution is updated. if some hook was expecting a domain name as one of the parameters, it still receives a domain name. we may need to change it in the future, but it requires updates of the hook handlers (which are mostly in the MIM modules).remove_domain
hook handler implementation forejaberd_auth
Another big generic module that triggers hooks is
ejabberd_sm
(13 calls tomongoose_hook
). But it should be reworked in a separate PR, and probably after switching back to the master branch.