You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by va...@apache.org on 2024/04/23 20:05:32 UTC
(couchdb) branch modernize-couch-replicator-sup created (now 60276057c)
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a change to branch modernize-couch-replicator-sup
in repository https://gitbox.apache.org/repos/asf/couchdb.git
at 60276057c Modernize couch replicator supervisor
This branch includes the following new commits:
new 60276057c Modernize couch replicator supervisor
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(couchdb) 01/01: Modernize couch replicator supervisor
Posted by va...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
vatamane pushed a commit to branch modernize-couch-replicator-sup
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 60276057cc422488f7ba3f9f8e5d56b32d8a2616
Author: Nick Vatamaniuc <va...@gmail.com>
AuthorDate: Tue Apr 23 16:02:58 2024 -0400
Modernize couch replicator supervisor
Use maps and a few helper function to make it less verbose.
Otherwise it should be the exact same specs as before.
References:
https://www.erlang.org/doc/design_principles/sup_princ.html
https://www.erlang.org/doc/man/supervisor
https://www.erlang.org/docs/17/man/supervisor.html
---
src/couch_replicator/src/couch_replicator_sup.erl | 41 +++++++++++++----------
1 file changed, 23 insertions(+), 18 deletions(-)
diff --git a/src/couch_replicator/src/couch_replicator_sup.erl b/src/couch_replicator/src/couch_replicator_sup.erl
index 1cf973f71..f6b549a7b 100644
--- a/src/couch_replicator/src/couch_replicator_sup.erl
+++ b/src/couch_replicator/src/couch_replicator_sup.erl
@@ -20,22 +20,27 @@ start_link() ->
init(_Args) ->
Children = [
- {couch_replication_event, {gen_event, start_link, [{local, couch_replication}]}, permanent,
- brutal_kill, worker, dynamic},
- {couch_replicator_pg, {couch_replicator_pg, start_link, []}, permanent, 1000, worker, [pg]},
- {couch_replicator_clustering, {couch_replicator_clustering, start_link, []}, permanent,
- brutal_kill, worker, [couch_replicator_clustering]},
- {couch_replicator_connection, {couch_replicator_connection, start_link, []}, permanent,
- brutal_kill, worker, [couch_replicator_connection]},
- {couch_replicator_rate_limiter, {couch_replicator_rate_limiter, start_link, []}, permanent,
- brutal_kill, worker, [couch_replicator_rate_limiter]},
- {couch_replicator_scheduler_sup, {couch_replicator_scheduler_sup, start_link, []},
- permanent, infinity, supervisor, [couch_replicator_scheduler_sup]},
- {couch_replicator_scheduler, {couch_replicator_scheduler, start_link, []}, permanent,
- brutal_kill, worker, [couch_replicator_scheduler]},
- {couch_replicator_doc_processor, {couch_replicator_doc_processor, start_link, []},
- permanent, brutal_kill, worker, [couch_replicator_doc_processor]},
- {couch_replicator_db_changes, {couch_replicator_db_changes, start_link, []}, permanent,
- brutal_kill, worker, [couch_multidb_changes]}
+ event_listener(couch_replication_event, [{local, couch_replication}]),
+ worker(couch_replicator_pg, 1000),
+ worker(couch_replicator_clustering, brutal_kill),
+ worker(couch_replicator_connection, brutal_kill),
+ worker(couch_replicator_rate_limiter, brutal_kill),
+ sup(couch_replicator_scheduler_sup),
+ worker(couch_replicator_scheduler, brutal_kill),
+ worker(couch_replicator_doc_processor, brutal_kill),
+ custom_behavior(couch_replicator_db_changes, [couch_multidb_changes])
],
- {ok, {{rest_for_one, 10, 1}, Children}}.
+ SupFlags = #{strategy => rest_for_one, intensity => 10, period => 1},
+ {ok, {SupFlags, Children}}.
+
+worker(Mod, Shutdown) ->
+ #{id => Mod, start => {Mod, start_link, []}, shutdown => Shutdown}.
+
+sup(Mod) ->
+ #{id => Mod, type => supervisor, start => {Mod, start_link, []}, shutdown => infinity}.
+
+event_listener(Mod, Args) ->
+ #{id => Mod, type => worker, start => {gen_event, start_link, Args}, modules => dynamic}.
+
+custom_behavior(Mod, Modules) ->
+ #{id => Mod, type => worker, start => {Mod, start_link, []}, modules => Modules}.