From 3e56ab94735fd284f1814fe4df98591acd27137a Mon Sep 17 00:00:00 2001 From: Ilya Averyanov Date: Mon, 6 Nov 2023 15:24:08 +0200 Subject: [PATCH] fix: do not start dependant apps lazily --- src/client/grpc_client_sup.erl | 2 - src/grpc.appup.src | 85 +++++++++++++++++++++++---------- src/grpc.erl | 2 - test/grpc_SUITE.erl | 4 +- test/grpc_performance_SUITE.erl | 4 +- test/grpc_test2_SUITE.erl | 5 +- 6 files changed, 68 insertions(+), 34 deletions(-) diff --git a/src/client/grpc_client_sup.erl b/src/client/grpc_client_sup.erl index 62d4794..a5eb387 100644 --- a/src/client/grpc_client_sup.erl +++ b/src/client/grpc_client_sup.erl @@ -39,8 +39,6 @@ -spec create_channel_pool(term(), uri_string:uri_string(), options()) -> supervisor:startchild_ret(). create_channel_pool(Name, URL, Opts) -> - _ = application:ensure_all_started(grpc), - _ = application:ensure_all_started(gproc), case uri_string:parse(URL) of #{scheme := Scheme, host := Host, port := Port} -> Server = {Scheme, Host, Port}, diff --git a/src/grpc.appup.src b/src/grpc.appup.src index 1f4948b..db76852 100644 --- a/src/grpc.appup.src +++ b/src/grpc.appup.src @@ -1,53 +1,86 @@ %% -*- mode: erlang -*- -{"0.6.11", - [{"0.6.10", - [{load_module, grpc_client, brutal_purge, soft_purge, []}]}, +{"0.6.12", + [{"0.6.11", + [{load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, + {"0.6.10", + [{load_module, grpc_client, brutal_purge, soft_purge, []}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.9", - [{load_module, grpc_client, brutal_purge, soft_purge, []}]}, + [{load_module, grpc_client, brutal_purge, soft_purge, []}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.8", - [{load_module, grpc_client, brutal_purge, soft_purge, []}]}, + [{load_module, grpc_client, brutal_purge, soft_purge, []}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.7", - [{load_module, grpc_client, brutal_purge, soft_purge, []}]}, + [{load_module, grpc_client, brutal_purge, soft_purge, []}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.6", - [{update, grpc_client, {advanced, ["0.6.6"]}}]}, + [{update, grpc_client, {advanced, ["0.6.6"]}}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.5", - [{update, grpc_client, {advanced, ["0.6.5"]}}]}, + [{update, grpc_client, {advanced, ["0.6.5"]}}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.4", [{update, grpc_client, {advanced, ["0.6.4"]}}, - {load_module, grpc_client_sup, brutal_purge, soft_purge, []}]}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.3", [{update, grpc_client, {advanced, ["0.6.3"]}}, - {load_module, grpc_client_sup, brutal_purge, soft_purge, []}]}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.2", [{add_module, grpc_utils}, {update, grpc_client, {advanced, ["0.6.2"]}}, {load_module, grpc_stream, brutal_purge, soft_purge, []}, - {load_module, grpc_client_sup, brutal_purge, soft_purge, []}]}, - {<<".*">>, []} - ], - [{"0.6.10", - [{load_module, grpc_client, brutal_purge, soft_purge, []}]}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, + {<<".*">>, []}], + [{"0.6.11", + [{load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, + {"0.6.10", + [{load_module, grpc_client, brutal_purge, soft_purge, []}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.9", - [{load_module, grpc_client, brutal_purge, soft_purge, []}]}, + [{load_module, grpc_client, brutal_purge, soft_purge, []}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.8", - [{load_module, grpc_client, brutal_purge, soft_purge, []}]}, + [{load_module, grpc_client, brutal_purge, soft_purge, []}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.7", - [{load_module, grpc_client, brutal_purge, soft_purge, []}]}, + [{load_module, grpc_client, brutal_purge, soft_purge, []}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.6", - [{update, grpc_client, {advanced, ["0.6.6"]}}]}, + [{update, grpc_client, {advanced, ["0.6.6"]}}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.5", - [{update, grpc_client, {advanced, ["0.6.5"]}}]}, + [{update, grpc_client, {advanced, ["0.6.5"]}}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.4", [{update, grpc_client, {advanced, ["0.6.4"]}}, - {load_module, grpc_client_sup, brutal_purge, soft_purge, []}]}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.3", [{update, grpc_client, {advanced, ["0.6.3"]}}, - {load_module, grpc_client_sup, brutal_purge, soft_purge, []}]}, + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, {"0.6.2", [{delete_module, grpc_utils}, {update, grpc_client, {advanced, ["0.6.2"]}}, {load_module, grpc_stream, brutal_purge, soft_purge, []}, - {load_module, grpc_client_sup, brutal_purge, soft_purge, []}]}, - {<<".*">>, []} - ] -}. + {load_module, grpc_client_sup, brutal_purge, soft_purge, []}, + {load_module, grpc, brutal_purge, soft_purge, []}]}, + {<<".*">>, []}]}. diff --git a/src/grpc.erl b/src/grpc.erl index b72882f..5aac280 100644 --- a/src/grpc.erl +++ b/src/grpc.erl @@ -53,8 +53,6 @@ start_server(Name, ListenOn, Services) -> -> {ok, pid()} | {error, term()}. %% @doc Start a gRPC server start_server(Name, ListenOn, Services, Options) -> - _ = application:ensure_all_started(grpc), - Services1 = enable_default_services( proplists:get_value(enable_default_services, Options, all), Services), diff --git a/test/grpc_SUITE.erl b/test/grpc_SUITE.erl index 6e98a49..ed03caa 100644 --- a/test/grpc_SUITE.erl +++ b/test/grpc_SUITE.erl @@ -39,6 +39,7 @@ groups() -> [{http, Tests}, {https,Tests}]. init_per_group(GrpName, Cfg) -> + _ = application:ensure_all_started(grpc), DataDir = proplists:get_value(data_dir, Cfg), TestDir = re:replace(DataDir, "/grpc_SUITE_data", "", [{return, list}]), CA = filename:join([TestDir, "certs", "ca.pem"]), @@ -74,7 +75,8 @@ init_per_group(GrpName, Cfg) -> end_per_group(_GrpName, _Cfg) -> _ = grpc_client_sup:stop_channel_pool(?CHANN_NAME), - _ = grpc:stop_server(?SERVER_NAME). + _ = grpc:stop_server(?SERVER_NAME), + _ = application:stop(grpc). %%-------------------------------------------------------------------- %% Tests diff --git a/test/grpc_performance_SUITE.erl b/test/grpc_performance_SUITE.erl index 431de5f..e3a1651 100644 --- a/test/grpc_performance_SUITE.erl +++ b/test/grpc_performance_SUITE.erl @@ -36,6 +36,7 @@ all() -> [t_performance]. init_per_suite(Cfg) -> + _ = application:ensure_all_started(grpc), Services = #{protos => [grpc_greeter_pb], services => #{'Greeter' => greeter_svr} }, @@ -45,7 +46,8 @@ init_per_suite(Cfg) -> end_per_suite(_Cfg) -> _ = grpc_client_sup:stop_channel_pool(?CHANN_NAME), - _ = grpc:stop_server(?SERVER_NAME). + _ = grpc:stop_server(?SERVER_NAME), + _ = application:stop(grpc). %%-------------------------------------------------------------------- %% Test cases diff --git a/test/grpc_test2_SUITE.erl b/test/grpc_test2_SUITE.erl index ddd2768..e359afd 100644 --- a/test/grpc_test2_SUITE.erl +++ b/test/grpc_test2_SUITE.erl @@ -35,6 +35,7 @@ all() -> [t_deadline]. init_per_suite(Cfg) -> + _ = application:ensure_all_started(grpc), Services = #{protos => [grpc_test_pb], services => #{'Test' => test_svr} }, @@ -43,10 +44,10 @@ init_per_suite(Cfg) -> {ok, _} = grpc_client_sup:create_channel_pool(?CHANN_NAME, SvrAddr, #{}), Cfg. -end_per_suite(Cfg) -> +end_per_suite(_Cfg) -> _ = grpc_client_sup:stop_channel_pool(?CHANN_NAME), _ = grpc:stop_server(?SERVER_NAME), - Cfg. + _ = application:stop(grpc). %%-------------------------------------------------------------------- %% Tests