Skip to content

Commit e83634d

Browse files
authored
Merge pull request #48 from ccamel/copilot/refactor-es-kernel-sup
Migrate es_kernel_aggregate_sup from simple_one_for_one to one_for_one with explicit child specs
2 parents dd1cd59 + f2001cf commit e83634d

1 file changed

Lines changed: 12 additions & 13 deletions

File tree

apps/es_kernel/src/es_kernel_aggregate_sup.erl

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,16 @@ when
4343
snapshot_interval => non_neg_integer()
4444
}.
4545
start_aggregate(Aggregate, StoreContext, Id, Opts) ->
46-
supervisor:start_child(?SERVER, [Aggregate, StoreContext, Id, Opts]).
46+
ChildSpec =
47+
#{
48+
id => {es_kernel_aggregate, Aggregate, Id},
49+
start => {es_kernel_aggregate, start_link, [Aggregate, StoreContext, Id, Opts]},
50+
restart => temporary,
51+
shutdown => 5000,
52+
type => worker,
53+
modules => [es_kernel_aggregate]
54+
},
55+
supervisor:start_child(?SERVER, ChildSpec).
4756

4857
-doc """
4958
Initializes the supervisor with a dynamic strategy suitable for
@@ -53,20 +62,10 @@ on-demand aggregate processes.
5362
init([]) ->
5463
SupFlags =
5564
#{
56-
strategy => simple_one_for_one,
65+
strategy => one_for_one,
5766
intensity => 10,
5867
period => 5
5968
},
6069

61-
AggregateSpec =
62-
#{
63-
id => es_kernel_aggregate,
64-
start => {es_kernel_aggregate, start_link, []},
65-
restart => temporary,
66-
shutdown => 5000,
67-
type => worker,
68-
modules => [es_kernel_aggregate]
69-
},
70-
71-
ChildSpecs = [AggregateSpec],
70+
ChildSpecs = [],
7271
{ok, {SupFlags, ChildSpecs}}.

0 commit comments

Comments
 (0)