<commit_before>%% ===================================================================
%% @author <NAME> <<EMAIL>>
%% @copyright 2011-2012 <NAME>
%%
%% @doc e2 service behavior.
%%
%% e2 services are the base process type in e2.
%%
%% e2 services provide the same functionality as
%% [http://www.erlang.org/doc/man/gen_server.html gen_server] but with
%% a simplified interface.
%%
%% For more information see [http://e2project.org/services.html e2
%% services] documentation.
%% @end
%% ===================================================================

-module(e2_service).

-behaviour(gen_server).

-export([start_link/2, start_link/3, call/2, call/3, cast/2, reply/2]).

-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
         terminate/2, code_change/3]).

-export([behaviour_info/1]).

%% @private
behaviour_info(callbacks) -> [{handle_msg, 3}].

-record(state, {mod, mod_state, timeout_msg}).

%%%===================================================================
%%% API
%%%===================================================================

%%--------------------------------------------------------------------
%% @doc Starts an e2 service.
%% @equiv start_link(Module, Args)
%% @end
%%--------------------------------------------------------------------

start_link(Module, Args) ->
    start_link(Module, Args, []).

%%--------------------------------------------------------------------
%% @doc Starts an e2 service.
%%
%% Module is the service callback module.
%%
%% If `init/1' is exported, Args is the argument passed to the function
%% when the service is initialized. If `init/1' is not exported, Args
%% is the initial service state.
%%
%% If `register' or `{register, Name}' is provided as an option, the
%% service will be registered. If not specified, the registered name
%% defaults to Module.
%%
%% @spec start_link(Module, Args, Options) -> {ok, Pid} | {error, Reason}
%% Module = atom()
%% Args = term()
%% Options = [Option]
%% Option = registered | {registered, Name}
%% Name = atom()
%% @end
%%--------------------------------------------------------------------

start_link(Module, Args, Options) ->
    start_gen_server(server_name(Module, Options), Module, Args, Options).

%%--------------------------------------------------------------------
%% @doc Sends a message to a service and waits for a reply.
%% @equiv call(ServiceRef, Msg, infinity)
%% @end
%%--------------------------------------------------------------------

call(ServiceRef, Msg) ->
    call(ServiceRef, Msg, infinity).

%%--------------------------------------------------------------------
%% @doc Sends a message to a service and waits for a reply.
%% @spec (ServiceRef, Msg, Timeout) -> Reply<commit_msg>Typo - thanks <NAME><commit_after>%% ===================================================================
%% @author <NAME> <<EMAIL>>
%% @copyright 2011-2012 <NAME>
%%
%% @doc e2 service behavior.
%%
%% e2 services are the base process type in e2.
%%
%% e2 services provide the same functionality as
%% [http://www.erlang.org/doc/man/gen_server.html gen_server] but with
%% a simplified interface.
%%
%% For more information see [http://e2project.org/services.html e2
%% services] documentation.
%% @end
%% ===================================================================

-module(e2_service).

-behaviour(gen_server).

-export([start_link/2, start_link/3, call/2, call/3, cast/2, reply/2]).

-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
         terminate/2, code_change/3]).

-export([behaviour_info/1]).

%% @private
behaviour_info(callbacks) -> [{handle_msg, 3}].

-record(state, {mod, mod_state, timeout_msg}).

%%%===================================================================
%%% API
%%%===================================================================

%%--------------------------------------------------------------------
%% @doc Starts an e2 service.
%% @equiv start_link(Module, Args)
%% @end
%%--------------------------------------------------------------------

start_link(Module, Args) ->
    start_link(Module, Args, []).

%%--------------------------------------------------------------------
%% @doc Starts an e2 service.
%%
%% Module is the service callback module.
%%
%% If `init/1' is exported, Args is the argument passed to the function
%% when the service is initialized. If `init/1' is not exported, Args
%% is the initial service state.
%%
%% If `registered' or `{registered, Name}' is provided as an option, the
%% service will be registered. If not specified, the registered name
%% defaults to Module.
%%
%% @spec start_link(Module, Args, Options) -> {ok, Pid} | {error, Reason}
%% Module = atom()
%% Args = term()
%% Options = [Option]
%% Option = registered | {registered, Name}
%% Name = atom()
%% @end
%%--------------------------------------------------------------------

start_link(Module, Args, Options) ->
    start_gen_server(server_name(Module, Options), Module, Args, Options).

%%--------------------------------------------------------------------
%% @doc Sends a message to a service and waits for a reply.
%% @equiv call(ServiceRef, Msg, infinity)
%% @end
%%--------------------------------------------------------------------

call(ServiceRef, Msg) ->
    call(ServiceRef, Msg, infinity).

%%--------------------------------------------------------------------
%% @doc Sends a message to a service and waits for a reply.
%% @spec (ServiceRef, Msg, Timeout) -> Reply
{'fraction_non_alphanumeric': 0.3957913998170174, 'fraction_numerical': 0.012076852698993596, 'mean_word_length': 2.1871720116618074, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1311630', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1389, 'n_words': 423}