This commit is contained in:
anlicheng 2025-05-08 11:16:49 +08:00
parent 58756c3280
commit 1855d632c5
4 changed files with 10 additions and 10 deletions

View File

@ -7,7 +7,7 @@
%%% @end %%% @end
%%% Created : 18. 4 2025 16:50 %%% Created : 18. 4 2025 16:50
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(efka_micro_service). -module(efka_service).
-author("anlicheng"). -author("anlicheng").
-include("efka_tables.hrl"). -include("efka_tables.hrl").

View File

@ -6,7 +6,7 @@
%%% @end %%% @end
%%% Created : 18. 4 2025 16:42 %%% Created : 18. 4 2025 16:42
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(efka_micro_service_sup). -module(efka_service_sup).
-author("anlicheng"). -author("anlicheng").
-include("efka_tables.hrl"). -include("efka_tables.hrl").
@ -47,7 +47,7 @@ start_link() ->
init([]) -> init([]) ->
SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600}, SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600},
micro_service_model:insert(#micro_service{ service_model:insert(#micro_service{
service_id = <<"test1234">>, service_id = <<"test1234">>,
%% %%
root_dir = <<"/usr/local/code/tmp/test/">>, root_dir = <<"/usr/local/code/tmp/test/">>,
@ -57,7 +57,7 @@ init([]) ->
status = 1 status = 1
}), }),
MicroServiceIds = micro_service_model:get_all_service_ids(), MicroServiceIds = service_model:get_all_service_ids(),
Specs = lists:map(fun(ServiceId) -> child_spec(ServiceId) end, MicroServiceIds), Specs = lists:map(fun(ServiceId) -> child_spec(ServiceId) end, MicroServiceIds),
{ok, {SupFlags, [Specs]}}. {ok, {SupFlags, [Specs]}}.
@ -79,17 +79,17 @@ start_service(ServiceId) when is_binary(ServiceId) ->
-spec delete_service(ServiceId :: binary()) -> ok. -spec delete_service(ServiceId :: binary()) -> ok.
delete_service(ServiceId) when is_binary(ServiceId) -> delete_service(ServiceId) when is_binary(ServiceId) ->
ChildId = efka_micro_service:get_name(ServiceId), ChildId = efka_service:get_name(ServiceId),
ok = supervisor:terminate_child(?MODULE, ChildId), ok = supervisor:terminate_child(?MODULE, ChildId),
supervisor:delete_child(?MODULE, ChildId). supervisor:delete_child(?MODULE, ChildId).
child_spec(ServiceId) when is_binary(ServiceId) -> child_spec(ServiceId) when is_binary(ServiceId) ->
Name = efka_micro_service:get_name(ServiceId), Name = efka_service:get_name(ServiceId),
#{ #{
id => Name, id => Name,
start => {efka_micro_service, start_link, [Name, ServiceId]}, start => {efka_service, start_link, [Name, ServiceId]},
restart => permanent, restart => permanent,
shutdown => 2000, shutdown => 2000,
type => worker, type => worker,
modules => ['efka_micro_service'] modules => ['efka_service']
}. }.

View File

@ -6,7 +6,7 @@
%%% @end %%% @end
%%% Created : 04. 7 2023 12:31 %%% Created : 04. 7 2023 12:31
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(micro_cache_model). -module(cache_model).
-author("aresei"). -author("aresei").
-include("efka_tables.hrl"). -include("efka_tables.hrl").
-include_lib("stdlib/include/qlc.hrl"). -include_lib("stdlib/include/qlc.hrl").

View File

@ -6,7 +6,7 @@
%%% @end %%% @end
%%% Created : 04. 7 2023 12:31 %%% Created : 04. 7 2023 12:31
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
-module(micro_service_model). -module(service_model).
-author("aresei"). -author("aresei").
-include("efka_tables.hrl"). -include("efka_tables.hrl").
-include_lib("stdlib/include/qlc.hrl"). -include_lib("stdlib/include/qlc.hrl").