<commit_before>%%%-------------------------------------------------------------------
%%% File    : rd_heartbeat.erl
%%% Author  : <NAME> 
%%% @doc This does an inform nodes at a specified time interval.
%%% @end
%%%-------------------------------------------------------------------
-module(rd_heartbeat).

-behaviour(gen_server).

%% External exports
-export([ start_link/1, start_link/0]).

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

-define(SERVER, ?MODULE).

-record(state, {frequency}).

%%====================================================================
%% External functions
%%====================================================================

%%--------------------------------------------------------------------
%% @doc Starts the server
%% <pre> 
%% Expects:
%%  Frequency - The frequency of heartbeats in milliseconds.
%% </pre>
%% @end
%%--------------------------------------------------------------------
-spec start_link(non_neg_integer()) -> {ok, pid()}.
start_link(Frequency) ->
    gen_server:start_link({local, ?SERVER}, ?MODULE, [Frequency], []).

%% @equiv start_link(0) 
start_link() ->
    %% The default value is 0 which indicates no heartbeating. 
    Frequency = rd_util:get_env(heartbeat_frequency, 0),
    start_link(Frequency).

%%====================================================================
%% Server functions
%%====================================================================

%%--------------------------------------------------------------------
%% Function: init/1
%% Description: Initiates the server<commit_msg>default config altered to 60000 for heartbeat<commit_after>%%%-------------------------------------------------------------------
%%% File    : rd_heartbeat.erl
%%% Author  : <NAME> 
%%% @doc This does an inform nodes at a specified time interval.
%%% @end
%%%-------------------------------------------------------------------
-module(rd_heartbeat).

-behaviour(gen_server).

%% External exports
-export([ start_link/1, start_link/0]).

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

-define(SERVER, ?MODULE).

-record(state, {frequency}).

%%====================================================================
%% External functions
%%====================================================================

%%--------------------------------------------------------------------
%% @doc Starts the server
%% <pre> 
%% Expects:
%%  Frequency - The frequency of heartbeats in milliseconds.
%% </pre>
%% @end
%%--------------------------------------------------------------------
-spec start_link(non_neg_integer()) -> {ok, pid()}.
start_link(Frequency) ->
    gen_server:start_link({local, ?SERVER}, ?MODULE, [Frequency], []).

%% @equiv start_link(0) 
start_link() ->
    %% The default value is 0 which indicates no heartbeating. 
    Frequency = rd_util:get_env(heartbeat_frequency, 60000),
    start_link(Frequency).

%%====================================================================
%% Server functions
%%====================================================================

%%--------------------------------------------------------------------
%% Function: init/1
%% Description: Initiates the server
{'fraction_non_alphanumeric': 0.47621914509331725, 'fraction_numerical': 0.009933774834437087, 'mean_word_length': 2.137865911237016, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4638731', 'n_tokens_mistral': 811, 'n_tokens_neox': 738, 'n_words': 177}