<commit_before>%%% ocs_sup.erl
%%% vim: ts=3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% @copyright 2016 - 2021 SigScale Global Inc.
%%% @end
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
%%% You may obtain a copy of the License at
%%%
%%%     http://www.apache.org/licenses/LICENSE-2.0
%%%
%%% Unless required by applicable law or agreed to in writing, software
%%% distributed under the License is distributed on an "AS IS" BASIS,
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%%% See the License for the specific language governing permissions and
%%% limitations under the License.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% @docfile "{@docsrc supervision.edoc}"
%%%
-module(ocs_sup).
-copyright('Copyright (c) 2016 - 2021 SigScale Global Inc.').

-behaviour(supervisor).

%% export the callback needed for supervisor behaviour
-export([init/1]).

-dialyzer({no_match, init/1}).
-ifdef(OTP_RELEASE).
	-define(PG,
		case ?OTP_RELEASE of
			OtpRelease when OtpRelease >= 23 ->
				StartMod = pg,
				StartFunc = {StartMod, start_link, [pg_scope_ocs]},
				[{StartMod, StartFunc, permanent, 4000, worker, [StartMod]}];
			OtpRelease when OtpRelease < 23 ->
				[]
		end).
-else.
	-define(PG, []).
-endif.

%%----------------------------------------------------------------------
%%  The supervisor callback
%%----------------------------------------------------------------------

-spec init(Args) -> Result
	when
		Args :: [term()],
		Result :: {ok, {{supervisor:strategy(), non_neg_integer(), pos_integer()},
			[supervisor:child_spec()]}} | ignore.
%% @doc Initialize the {@module} supervisor.
%% @see //stdlib/supervisor:init/1
%% @private
%%
init([LogRotateTime, LogRotateInterval] = _Args) ->
	ChildSpecs = ?PG ++ [supervisor(ocs_radius_acct_top_sup, []),
			supervisor(ocs_radius_auth_sup, []),
			supervisor(ocs_diameter_auth_sup, []),
			supervisor(ocs_diameter_acct_top_sup, []),
			log_server(ocs_log_rotate_server,
					[voip, LogRotateTime, LogRotateInterval]),
			log_server(ocs_log_rotate_server,
					[wlan, LogRotateTime, LogRotateInterval]),
			supervisor(ocs_statistics_sup,
					ocs_statistics_sup, []),
			supervisor(ocs_rest_pagination_sup,
					ocs_rest_pagination_sup, []),
			supervisor(ocs_rest_hub_sup,
					ocs_rest_hub_sup, []),
			server(ocs_server, [self()]),
			event(ocs_event)],
	{ok, {{one_for_one, 10, 60}, ChildSpecs}}.

%%----------------------------------------------------------------------
%%  internal functions
%%----------------------------------------------------------------------

-spec supervisor(StartMod, Args) -> Result
	when
		StartMod :: atom(),
		Args :: [term()],
		Result :: supervisor:child_spec().
%% @doc Build a supervisor child specification for a
%% 	{@link //stdlib/supervisor. supervisor} behaviour.
%% @private
%%
supervisor(StartMod, Args) ->
	StartArgs = [StartMod, Args],
	StartFunc = {supervisor, start_link, StartArgs},
	{StartMod, StartFunc, permanent, infinity, supervisor, [StartMod]}.<commit_msg>register ocs_event_log_sup and ocs_event_log under main supervisor<commit_after>%%% ocs_sup.erl
%%% vim: ts=3
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% @copyright 2016 - 2021 SigScale Global Inc.
%%% @end
%%% Licensed under the Apache License, Version 2.0 (the "License");
%%% you may not use this file except in compliance with the License.
%%% You may obtain a copy of the License at
%%%
%%%     http://www.apache.org/licenses/LICENSE-2.0
%%%
%%% Unless required by applicable law or agreed to in writing, software
%%% distributed under the License is distributed on an "AS IS" BASIS,
%%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
%%% See the License for the specific language governing permissions and
%%% limitations under the License.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% @docfile "{@docsrc supervision.edoc}"
%%%
-module(ocs_sup).
-copyright('Copyright (c) 2016 - 2021 SigScale Global Inc.').

-behaviour(supervisor).

%% export the callback needed for supervisor behaviour
-export([init/1]).

-dialyzer({no_match, init/1}).
-ifdef(OTP_RELEASE).
	-define(PG,
		case ?OTP_RELEASE of
			OtpRelease when OtpRelease >= 23 ->
				StartMod = pg,
				StartFunc = {StartMod, start_link, [pg_scope_ocs]},
				[{StartMod, StartFunc, permanent, 4000, worker, [StartMod]}];
			OtpRelease when OtpRelease < 23 ->
				[]
		end).
-else.
	-define(PG, []).
-endif.

%%----------------------------------------------------------------------
%%  The supervisor callback
%%----------------------------------------------------------------------

-spec init(Args) -> Result
	when
		Args :: [term()],
		Result :: {ok, {{supervisor:strategy(), non_neg_integer(), pos_integer()},
			[supervisor:child_spec()]}} | ignore.
%% @doc Initialize the {@module} supervisor.
%% @see //stdlib/supervisor:init/1
%% @private
%%
init([LogRotateTime, LogRotateInterval] = _Args) ->
	ChildSpecs = ?PG ++ [supervisor(ocs_radius_acct_top_sup, []),
			supervisor(ocs_radius_auth_sup, []),
			supervisor(ocs_diameter_auth_sup, []),
			supervisor(ocs_diameter_acct_top_sup, []),
			log_server(ocs_log_rotate_server,
					[voip, LogRotateTime, LogRotateInterval]),
			log_server(ocs_log_rotate_server,
					[wlan, LogRotateTime, LogRotateInterval]),
			supervisor(ocs_statistics_sup,
					ocs_statistics_sup, []),
			supervisor(ocs_rest_pagination_sup,
					ocs_rest_pagination_sup, []),
			supervisor(ocs_rest_hub_sup,
					ocs_rest_hub_sup, []),
			server(ocs_server, [self()]),
			event(ocs_event),
			supervisor(ocs_event_log_sup,
					ocs_event_log_sup, []),
			event(ocs_event_log)],
	{ok, {{one_for_one, 10, 60}, ChildSpecs}}.

%%----------------------------------------------------------------------
%%  internal functions
%%----------------------------------------------------------------------

-spec supervisor(StartMod, Args) -> Result
	when
		StartMod :: atom(),
		Args :: [term()],
		Result :: supervisor:child_spec().
%% @doc Build a supervisor child specification for a
%% 	{@link //stdlib/supervisor. supervisor} behaviour.
%% @private
%%
supervisor(StartMod, Args) ->
	StartArgs = [StartMod, Args],
	StartFunc = {supervisor, start_link, StartArgs},
	{StartMod, StartFunc, permanent, infinity, supervisor, [StartMod]}.
{'fraction_non_alphanumeric': 0.2632716049382716, 'fraction_numerical': 0.011111111111111112, 'mean_word_length': 3.2084415584415584, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '1597354', 'n_tokens_mistral': 2190, 'n_tokens_neox': 1903, 'n_words': 480}