-
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
Mongoose service #1792
Mongoose service #1792
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1792 +/- ##
==========================================
- Coverage 74.48% 74.35% -0.14%
==========================================
Files 290 291 +1
Lines 26996 27061 +65
==========================================
+ Hits 20109 20122 +13
- Misses 6887 6939 +52
Continue to review full report at Codecov.
|
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.
- Missing documentation
- I'd transform logs into
?[level]("event='something_happened',...", [...])
format
%% See the License for the specific language governing permissions and | ||
%% limitations under the License. | ||
%%============================================================================== | ||
-module(mongoose_service_big_SUITE). |
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.
Duplicate in old directory.
src/mod_admin_extra.erl
Outdated
@@ -27,9 +27,9 @@ | |||
-module(mod_admin_extra). |
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 think it should be renamed, so it would be clear it's no longer a module. E.g. service_admin_extra
or srv_admin_extra
%% See the License for the specific language governing permissions and | ||
%% limitations under the License. | ||
%%============================================================================== | ||
-module(mongoose_service_big_SUITE). |
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'm not sure if we need such suite. If ejabberdctl_SUITE
works, then admin extra as a service works. For mongoose_service
alone there is a dedicated small test.
src/mongoose_service.erl
Outdated
|
||
-spec loaded_services_with_opts() -> [{service(), options()}]. | ||
loaded_services_with_opts() -> | ||
[Z || [Z] <- ets:match(?ETAB, '$1')]. |
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.
ets:tab2list
?
src/gen_mod.erl
Outdated
@@ -115,6 +116,7 @@ start_module_for_host(Host, Module, Opts0) -> | |||
Opts = clear_opts(Module, Opts0), | |||
set_module_opts_mnesia(Host, Module, Opts), | |||
ets:insert(ejabberd_modules, #ejabberd_module{module_host = {Module, Host}, opts = Opts}), | |||
lists:map(fun mongoose_service:assert_loaded/1, get_required_services(Host, Module, Opts)), |
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'd put it inside try..catch
- nicer error handling.
9b74608
to
668054e
Compare
### Module Description | ||
This module significantly extends `mongooseimctl` script capabilities. New functionalities appear as additional commands. For detailed description, just run `mongooseimctl` script with no parameters. | ||
Some functionalities in MongooseIM are provided by "services". | ||
A service is similar to a module, only it is started only globally, while a module can be global or host-specific. |
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.
Module may have global configuration.
A wide range of options includes authentication, privacy, storage, backend integration and mobile optimisations. | ||
See '[Extension Modules](../advanced-configuration/Modules.md)' for a full list. | ||
|
||
Modules can be configured and started either globally (for all virutal hosts served by the instance) or individually for each host. |
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.
Modules can be configured and started either for all virtual hosts served by the instance or with individual configuration for only some of them.
|
||
Modules can be configured and started either globally (for all virutal hosts served by the instance) or individually for each host. | ||
Modules may include dependencies on services and on other modules. | ||
If a module depends on other modules, required modules are started automatically. |
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.
... started automatically with a default configuration provided by dependent module.
|
||
Some functionalities which are not related to virtual hosts but rather are provided for the whole instance or for modules started for various hosts are provided by "services". | ||
Services are configured globally launched on startup, before modules, so that dependencies are satisfied. | ||
A service can require other services to be operational; required services are started automatically. |
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.
Wat? TBH I haven't noticed it in the code. Why should service be started as a dependency (with empty config!) by another service but we deny the same for modules?
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.
The service will not be started with empty config, it will be started with the config from the config file. Since services are singletond you cant give your own config at runtime. We do this for convenience, so that you can start a service without complete knowledge about the whole dependency tree.why we do not allow modules start required services lm not sure, it was decided on tech meeting.
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.
Actually the main advantage of it is that you can define services in the config file in any order and they will resolve their dependencies themselves.
…is now started as a service
* single callback for module dependencies and requirements * unified vocabulary (no requirements, only deps) * fail module start if required services not loaded (a.k.a. no lazy service startup) * Extend error on circular services dependency
1040fe7
to
2437ace
Compare
catch | ||
Class:Reason -> | ||
ets:delete(?ETAB, Service), | ||
Template = "event=service_startup,status=error,service=~p,options=~p,class=~p,reason=~p~n~p", |
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.
According to Elvis:
Line 131 is too long: Template = "event=service_startup,status=error,service=~p,options=~p,class=
p,reason=p",.pn
### Module Description | ||
This module significantly extends `mongooseimctl` script capabilities. New functionalities appear as additional commands. For detailed description, just run `mongooseimctl` script with no parameters. | ||
Some functionalities in MongooseIM are provided by "services". | ||
A service is similar to a module, only it is started only once with a global configuration, while a module is started for every virtual host and may have global or host-specific configuration. |
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.
A service is similar to a module, but while a module is started for every virtual host and may have global or host-specific configuration, a service is started only once with global configuration.
## Service list | ||
|
||
As of version 2.2, only one module is a "service provider". | ||
Over time, part of modules which are not host-specific will be refactored to be services. |
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.
Eventually the modules which are not host-specific will be refactored to be services.
?
|
||
Modules can be configured and started either for all virutal hosts served by the instance or with individual configuration for only some of them. | ||
Modules may include dependencies on services and on other modules. | ||
If a module depends on other modules, required modules are started automatically with configuration provided by the dependent module.. |
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.
If a module depends on other modules, required modules are started automatically with configuration provided by the dependent module.
|
||
### Services | ||
|
||
Some functionalities which are not related to virtual hosts but rather are provided for the whole instance or for modules started for various hosts are provided by "services". |
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.
Services provide certain fuctionalities not specific to virtual hosts but rather applied to the whole instance or to modules started for various hosts.
?
### Services | ||
|
||
Some functionalities which are not related to virtual hosts but rather are provided for the whole instance or for modules started for various hosts are provided by "services". | ||
Services are configured globally launched on startup, before modules, so that dependencies are satisfied. |
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.
They are configured globally and launched on startup, before modules, so that dependencies are satisfied.
This PR addresses feature #18914
Introduces mongoose_service behaviour, with dependencies between services and modules requiring certain services.
There will be another PR with slightly modified interface.