-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea8afc2
commit 5140b15
Showing
6 changed files
with
71 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
-module(mod_pubsub_cache_backend). | ||
|
||
-export([start/2, | ||
stop/1, | ||
upsert_last_item/5, | ||
delete_last_item/2, | ||
get_last_item/2]). | ||
|
||
-ignore_xref([stop/1]). | ||
|
||
-define(MAIN_MODULE, mod_pubsub_cache). | ||
|
||
%%==================================================================== | ||
%% Behaviour callbacks | ||
%%==================================================================== | ||
|
||
%% ------------------------ Backend start/stop ------------------------ | ||
|
||
-callback start(jid:lserver()) -> ok. | ||
|
||
-callback stop() -> ok. | ||
|
||
-callback upsert_last_item(ServerHost :: binary(), | ||
Nidx :: mod_pubsub:nodeIdx(), | ||
ItemID :: mod_pubsub:itemId(), | ||
Publisher :: jid:jid(), | ||
Payload :: mod_pubsub:payload()) -> ok | {error, Reason :: term()}. | ||
|
||
-callback delete_last_item(ServerHost :: binary(), | ||
Nidx :: mod_pubsub:nodeIdx()) -> ok | {error, Reason :: term()}. | ||
|
||
-callback get_last_item(ServerHost :: binary(), | ||
Nidx :: mod_pubsub:nodeIdx()) -> | ||
{ok, LastItem :: mod_pubsub:pubsubLastItem()} | {error, Reason :: term()}. | ||
|
||
-spec start(jid:lserver(), gen_mod:module_opts()) -> ok. | ||
start(ServerHost, Opts) -> | ||
TrackedFuns = [upsert_last_item, delete_last_item, get_last_item], | ||
mongoose_backend:init_per_host_type(ServerHost, ?MAIN_MODULE, TrackedFuns, Opts), | ||
Args = [ServerHost], | ||
mongoose_backend:call(ServerHost, ?MAIN_MODULE, ?FUNCTION_NAME, Args). | ||
|
||
-spec stop(jid:lserver()) -> ok. | ||
stop(ServerHost) -> | ||
mongoose_backend:call(ServerHost, ?MAIN_MODULE, ?FUNCTION_NAME, []). | ||
|
||
-spec upsert_last_item(ServerHost :: binary(), | ||
Nidx :: mod_pubsub:nodeIdx(), | ||
ItemID :: mod_pubsub:itemId(), | ||
Publisher :: jid:jid(), | ||
Payload :: mod_pubsub:payload()) -> ok | {error, Reason :: term()}. | ||
upsert_last_item(ServerHost, Nidx, ItemID, Publisher, Payload) -> | ||
Args = [ServerHost, Nidx, ItemID, Publisher, Payload], | ||
mongoose_backend:call_tracked(ServerHost, ?MAIN_MODULE, ?FUNCTION_NAME, Args). | ||
|
||
-spec delete_last_item(ServerHost :: binary(), | ||
Nidx :: mod_pubsub:nodeIdx()) -> ok | {error, Reason :: term()}. | ||
delete_last_item(ServerHost, Nidx) -> | ||
Args = [ServerHost, Nidx], | ||
mongoose_backend:call_tracked(ServerHost, ?MAIN_MODULE, ?FUNCTION_NAME, Args). | ||
|
||
-spec get_last_item(ServerHost :: binary(), | ||
Nidx :: mod_pubsub:nodeIdx()) -> | ||
{ok, LastItem :: mod_pubsub:pubsubLastItem()} | {error, Reason :: term()}. | ||
get_last_item(ServerHost, Nidx) -> | ||
Args = [ServerHost, Nidx], | ||
mongoose_backend:call_tracked(ServerHost, ?MAIN_MODULE, ?FUNCTION_NAME, Args). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters