-
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 4 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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
%% 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) -> | ||
TrackedFuns = [get_last, set_last_info], | ||
mongoose_backend:init_per_host_type(HostType, ?MAIN_MODULE, TrackedFuns, Opts), | ||
Args = [HostType, Opts], | ||
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_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). | ||
|
||
-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_tracked(HostType, ?MAIN_MODULE, ?FUNCTION_NAME, Args). | ||
|
||
-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.
I don't think this makes much sense in the new code - it is exported but
mongooseim:host_type
is exported as well. IMO we should either usehost_type()
instead ofmongooseim:host_type()
in this whole module or delete this line.