Email queue count

This commit is contained in:
Fabio Salvini 2017-10-25 04:34:41 +02:00
parent e5cc4cd95e
commit b9a57d0054

View File

@ -17,6 +17,7 @@
%% API
-export([start_link/0]).
-export([queue/0]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
@ -38,6 +39,16 @@
start_link() ->
gen_server:start_link(?MODULE, [], []).
%%--------------------------------------------------------------------
%% @doc
%% Get the number of emails to send.
%%
%% @spec queue() -> {ok, Count}
%% @end
%%--------------------------------------------------------------------
queue() ->
gen_server:call(mailer, {queue_count}).
%%%===================================================================
%%% gen_server callbacks
%%%===================================================================
@ -72,6 +83,10 @@ init([]) ->
%% {stop, Reason, State}
%% @end
%%--------------------------------------------------------------------
handle_call({queue_count}, _From, State) ->
Count = length(emails_to_send()),
{reply, Count, State};
handle_call(_Request, _From, State) ->
Reply = ok,
{reply, Reply, State}.