make the couch_replicator a full Erlang application
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/commit/cad68988 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/tree/cad68988 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/diff/cad68988 Branch: refs/heads/1994-merge-rcouch Commit: cad689889a72f80f1a59668d4949430b422cd4b5 Parents: 05cdb34 Author: benoitc <[email protected]> Authored: Tue Jan 7 00:15:26 2014 +0100 Committer: Paul J. Davis <[email protected]> Committed: Wed Feb 12 18:16:57 2014 -0600 ---------------------------------------------------------------------- src/couch_replicator.app.src | 23 +++++------- src/couch_replicator_app.erl | 29 +++++++++++++++ src/couch_replicator_manager_sup.erl | 47 ++++++++++++++++++++++++ src/couch_replicator_sup.erl | 59 +++++++++++++++++++++++++++++++ 4 files changed, 144 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/cad68988/src/couch_replicator.app.src ---------------------------------------------------------------------- diff --git a/src/couch_replicator.app.src b/src/couch_replicator.app.src index 750eaad..1e62edf 100644 --- a/src/couch_replicator.app.src +++ b/src/couch_replicator.app.src @@ -13,21 +13,16 @@ {application, couch_replicator, [ {description, "CouchDB replicator"}, {vsn, "%version%"}, - {modules, [ - couch_replicator_api_wrap, - couch_replicator_httpc, - couch_replicator_httpd, - couch_replicator_job_sup, - couch_replicator_notifier, - couch_replicator_manager, - couch_replicator_httpc_pool, - couch_replicator_utils, - couch_replicator_worker, - couch_replicator - ]}, + {modules, []}, {registered, [ - couch_replicator_job_sup + couch_replicator_manager_sup, + couch_replicator_job_sup, + couch_replicator_sup ]}, - {applications, [kernel, stdlib]} + {applications, [kernel, stdlib, crypto, sasl, inets, oauth, ibrowse, + couch]}, + + {mod, { couch_replicator_app, []}}, + {env, []} ]}. http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/cad68988/src/couch_replicator_app.erl ---------------------------------------------------------------------- diff --git a/src/couch_replicator_app.erl b/src/couch_replicator_app.erl new file mode 100644 index 0000000..4083db6 --- /dev/null +++ b/src/couch_replicator_app.erl @@ -0,0 +1,29 @@ +% 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. + +-module(couch_replicator_app). + +-behaviour(application). + +%% Application callbacks +-export([start/2, stop/1]). + +%% =================================================================== +%% Application callbacks +%% =================================================================== + +start(_StartType, _StartArgs) -> + couch_util:start_app_deps(couch_replicator), + couch_replicator_sup:start_link(). + +stop(_State) -> + ok. http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/cad68988/src/couch_replicator_manager_sup.erl ---------------------------------------------------------------------- diff --git a/src/couch_replicator_manager_sup.erl b/src/couch_replicator_manager_sup.erl new file mode 100644 index 0000000..f292546 --- /dev/null +++ b/src/couch_replicator_manager_sup.erl @@ -0,0 +1,47 @@ + +% 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. + +-module(couch_replicator_manager_sup). + +-behaviour(supervisor). + +%% API +-export([start_link/0]). + +%% Supervisor callbacks +-export([init/1]). + +%% Helper macro for declaring children of supervisor +-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}). + +%% =================================================================== +%% API functions +%% =================================================================== + +start_link() -> + supervisor:start_link({local, ?MODULE}, ?MODULE, []). + +%% =================================================================== +%% Supervisor callbacks +%% =================================================================== + +init([]) -> + Children = [ + {couch_replicator_manager, + {couch_replicator_manager, start_link, []}, + permanent, + brutal_kill, + worker, + [couch_replicator_manager]} + ], + {ok, { {one_for_one, 10, 3600}, Children} }. http://git-wip-us.apache.org/repos/asf/couchdb-couch-replicator/blob/cad68988/src/couch_replicator_sup.erl ---------------------------------------------------------------------- diff --git a/src/couch_replicator_sup.erl b/src/couch_replicator_sup.erl new file mode 100644 index 0000000..905e2cf --- /dev/null +++ b/src/couch_replicator_sup.erl @@ -0,0 +1,59 @@ + +% 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. + +-module(couch_replicator_sup). + +-behaviour(supervisor). + +%% API +-export([start_link/0]). + +%% Supervisor callbacks +-export([init/1]). + +%% Helper macro for declaring children of supervisor +-define(CHILD(I, Type), {I, {I, start_link, []}, permanent, 5000, Type, [I]}). + +%% =================================================================== +%% API functions +%% =================================================================== + +start_link() -> + supervisor:start_link({local, ?MODULE}, ?MODULE, []). + +%% =================================================================== +%% Supervisor callbacks +%% =================================================================== + +init([]) -> + Children = [ + {couch_replication_event, + {gen_event, start_link, [{local, couch_replication}]}, + permanent, + brutal_kill, + worker, + dynamic}, + {couch_replicator_job_sup, + {couch_replicator_job_sup, start_link, []}, + permanent, + infinity, + supervisor, + [couch_replicator_job_sup]}, + {couch_replicator_manager_sup, + {couch_replicator_manager_sup, start_link, []}, + permanent, + infinity, + supervisor, + [couch_replicator_manager_sup]} + ], + {ok, { {one_for_one, 10, 3600}, Children} }.
