-
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
Mod last remove dynamic backend module #3339
Changes from 2 commits
8c36279
c579418
926579c
3a3261f
c46fa10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,12 +55,6 @@ | |
|
||
-define(MOD_LAST_BACKEND, mod_last_backend). | ||
-ignore_xref([ | ||
{?MOD_LAST_BACKEND, init, 2}, | ||
{?MOD_LAST_BACKEND, get_last, 3}, | ||
{?MOD_LAST_BACKEND, count_active_users, 3}, | ||
{?MOD_LAST_BACKEND, set_last_info, 5}, | ||
{?MOD_LAST_BACKEND, remove_user, 3}, | ||
{?MOD_LAST_BACKEND, remove_domain, 2}, | ||
behaviour_info/1, on_presence_update/5, process_local_iq/4, | ||
process_sm_iq/4, remove_user/3, session_cleanup/5, remove_domain/3 | ||
]). | ||
|
@@ -73,34 +67,15 @@ | |
%% ------------------------------------------------------------------ | ||
%% Backend callbacks | ||
|
||
-export_type([host_type/0, timestamp/0, status/0]). | ||
|
||
-type host_type() :: mongooseim:host_type(). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this makes much sense in the new code - it is exported but |
||
-type timestamp() :: non_neg_integer(). | ||
-type status() :: binary(). | ||
|
||
-export_type([host_type/0, timestamp/0, status/0]). | ||
|
||
-callback init(host_type(), gen_mod:module_opts()) -> ok. | ||
|
||
-callback get_last(host_type(), jid:luser(), jid:lserver()) -> | ||
{ok, timestamp(), status()} | {error, term()} | not_found. | ||
|
||
-callback count_active_users(host_type(), jid:lserver(), timestamp()) -> | ||
non_neg_integer(). | ||
|
||
-callback set_last_info(host_type(), jid:luser(), jid:lserver(), timestamp(), status()) -> | ||
ok | {error, term()}. | ||
|
||
-callback remove_user(host_type(), jid:luser(), jid:lserver()) -> | ||
ok | {error, term()}. | ||
|
||
-callback remove_domain(host_type(), jid:lserver()) -> | ||
ok | {error, term()}. | ||
|
||
-spec start(mongooseim:host_type(), list()) -> 'ok'. | ||
JanuszJakubiec marked this conversation as resolved.
Show resolved
Hide resolved
|
||
start(HostType, Opts) -> | ||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue), | ||
|
||
gen_mod:start_backend_module(?MODULE, Opts, [get_last, set_last_info]), | ||
mod_last_backend:init(HostType, Opts), | ||
|
||
[gen_iq_handler:add_iq_handler_for_domain(HostType, ?NS_LAST, Component, Fn, #{}, IQDisc) || | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
%% Just a proxy interface module between the main mod_last module and | ||
%% the backend modules (i.e. mod_last_rdbms, mod_last_mnesia...). | ||
-module(mod_last_backend). | ||
|
||
-export([init/2, | ||
get_last/3, | ||
count_active_users/3, | ||
set_last_info/5, | ||
remove_user/3, | ||
remove_domain/2]). | ||
|
||
-define(MAIN_MODULE, mod_last). | ||
|
||
-callback init(mod_last:host_type(), gen_mod:module_opts()) -> ok. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use
|
||
|
||
-callback get_last(mod_last:host_type(), jid:luser(), jid:lserver()) -> | ||
{ok, mod_last:timestamp(), mod_last:status()} | {error, term()} | not_found. | ||
|
||
-callback count_active_users(mod_last:host_type(), jid:lserver(), mod_last:timestamp()) -> | ||
non_neg_integer(). | ||
|
||
-callback set_last_info( | ||
mod_last:host_type(), | ||
jid:luser(), | ||
jid:lserver(), | ||
mod_last:timestamp(), | ||
mod_last:status()) -> ok | {error, term()}. | ||
|
||
-callback remove_user(mod_last:host_type(), jid:luser(), jid:lserver()) -> | ||
ok | {error, term()}. | ||
|
||
-callback remove_domain(mod_last:host_type(), jid:lserver()) -> | ||
ok | {error, term()}. | ||
|
||
-spec init(mod_last:host_type(), gen_mod:module_opts()) -> ok. | ||
init(HostType, Opts) -> | ||
Args = [HostType, Opts], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There has to be a call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remember to pass tracked functions to it - these will have automatic metrics created by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can I use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah yes, if the default backend is mnesia - from what I see that's the case. |
||
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). | ||
|
||
-spec get_last(mod_last:host_type(), jid:luser(), jid:lserver()) -> | ||
{ok, mod_last:timestamp(), mod_last:status()} | {error, term()} | not_found. | ||
get_last(HostType, LUser, LServer) -> | ||
Args = [HostType, LUser, LServer], | ||
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it should be |
||
|
||
-spec count_active_users(mod_last:host_type(), jid:lserver(), mod_last:timestamp()) -> | ||
non_neg_integer(). | ||
count_active_users(HostType, LServer, Timestamp) -> | ||
Args = [HostType, LServer, Timestamp], | ||
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). | ||
|
||
-spec set_last_info( | ||
mod_last:host_type(), | ||
jid:luser(), | ||
jid:lserver(), | ||
mod_last:timestamp(), | ||
mod_last:status()) -> ok | {error, term()}. | ||
set_last_info(HostType, LUser, LServer, Timestamp, Status) -> | ||
Args = [HostType, LUser, LServer, Timestamp, Status], | ||
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to |
||
|
||
-spec remove_user(mod_last:host_type(), jid:luser(), jid:lserver()) -> | ||
ok | {error, term()}. | ||
remove_user(HostType, LUser, LServer) -> | ||
Args = [HostType, LUser, LServer], | ||
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). | ||
|
||
-spec remove_domain(mod_last:host_type(), jid:lserver()) -> | ||
ok | {error, term()}. | ||
remove_domain(HostType, LServer) -> | ||
Args = [HostType, LServer], | ||
mongoose_backend:call(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please put a newline at the end of the file. |
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 could be deleted now.