diff options
author | Robert Newson <rnewson@apache.org> | 2021-02-09 14:11:15 +0000 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2021-02-12 13:17:52 +0000 |
commit | d10eda223da6097d7587fe85e72d1e2c2e358c45 (patch) | |
tree | 0504f176fd7e534df780bdef4a9ac1f0db75bc4b | |
parent | e089b029a754763ccec1ac889ce912627cec480a (diff) | |
download | couchdb-d10eda223da6097d7587fe85e72d1e2c2e358c45.tar.gz |
encapsulate db_updated call in a function
-rw-r--r-- | src/couch/src/couch_db_engine.erl | 2 | ||||
-rw-r--r-- | src/couch/src/couch_db_updater.erl | 16 | ||||
-rw-r--r-- | src/couch/src/couch_server.erl | 5 |
3 files changed, 14 insertions, 9 deletions
diff --git a/src/couch/src/couch_db_engine.erl b/src/couch/src/couch_db_engine.erl index 9adc9929d..918dabcca 100644 --- a/src/couch/src/couch_db_engine.erl +++ b/src/couch/src/couch_db_engine.erl @@ -1073,7 +1073,7 @@ finish_compaction(Db, CompactInfo) -> compactor_pid = CompactorPid } end, - ok = gen_server:call(couch_server, {db_updated, NewDb}, infinity), + ok = couch_server:db_updated(NewDb), {ok, NewDb}. diff --git a/src/couch/src/couch_db_updater.erl b/src/couch/src/couch_db_updater.erl index 1ca804c05..535acfad6 100644 --- a/src/couch/src/couch_db_updater.erl +++ b/src/couch/src/couch_db_updater.erl @@ -79,7 +79,7 @@ handle_call(cancel_compact, _From, #db{compactor_pid = Pid} = Db) -> exit(Pid, kill), couch_server:delete_compaction_files(Db#db.name), Db2 = Db#db{compactor_pid = nil}, - ok = gen_server:call(couch_server, {db_updated, Db2}, infinity), + ok = couch_server:db_updated(Db2), {reply, ok, Db2, idle_limit()}; handle_call({set_security, NewSec}, _From, #db{} = Db) -> @@ -87,18 +87,18 @@ handle_call({set_security, NewSec}, _From, #db{} = Db) -> NewSecDb = commit_data(NewDb#db{ security = NewSec }), - ok = gen_server:call(couch_server, {db_updated, NewSecDb}, infinity), + ok = couch_server:db_updated(NewSecDb), {reply, ok, NewSecDb, idle_limit()}; handle_call({set_revs_limit, Limit}, _From, Db) -> {ok, Db2} = couch_db_engine:set_revs_limit(Db, Limit), Db3 = commit_data(Db2), - ok = gen_server:call(couch_server, {db_updated, Db3}, infinity), + ok = couch_server:db_updated(Db3), {reply, ok, Db3, idle_limit()}; handle_call({set_purge_infos_limit, Limit}, _From, Db) -> {ok, Db2} = couch_db_engine:set_purge_infos_limit(Db, Limit), - ok = gen_server:call(couch_server, {db_updated, Db2}, infinity), + ok = couch_server:db_updated(Db2), {reply, ok, Db2, idle_limit()}; handle_call({purge_docs, [], _}, _From, Db) -> @@ -130,7 +130,7 @@ handle_call(Msg, From, Db) -> handle_cast({load_validation_funs, ValidationFuns}, Db) -> Db2 = Db#db{validate_doc_funs = ValidationFuns}, - ok = gen_server:call(couch_server, {db_updated, Db2}, infinity), + ok = couch_server:db_updated(Db2), {noreply, Db2, idle_limit()}; handle_cast(start_compact, Db) -> case Db#db.compactor_pid of @@ -143,7 +143,7 @@ handle_cast(start_compact, Db) -> Args = [Db#db.name, UpdateSeq], couch_log:info("Starting compaction for db \"~s\" at ~p", Args), {ok, Db2} = couch_db_engine:start_compaction(Db), - ok = gen_server:call(couch_server, {db_updated, Db2}, infinity), + ok = couch_server:db_updated(Db2), {noreply, Db2, idle_limit()}; _ -> % compact currently running, this is a no-op @@ -175,7 +175,7 @@ handle_info({update_docs, Client, GroupedDocs, NonRepDocs, MergeConflicts}, NonRepDocs2 = [{Client, NRDoc} || NRDoc <- NonRepDocs], try update_docs_int(Db, GroupedDocs3, NonRepDocs2, MergeConflicts) of {ok, Db2, UpdatedDDocIds} -> - ok = gen_server:call(couch_server, {db_updated, Db2}, infinity), + ok = couch_server:db_updated(Db2), case {couch_db:get_update_seq(Db), couch_db:get_update_seq(Db2)} of {Seq, Seq} -> ok; _ -> couch_event:notify(Db2#db.name, updated) @@ -780,7 +780,7 @@ purge_docs(Db, PurgeReqs) -> {ok, Db1} = couch_db_engine:purge_docs(Db, Pairs, PInfos), Db2 = commit_data(Db1), - ok = gen_server:call(couch_server, {db_updated, Db2}, infinity), + ok = couch_server:db_updated(Db2), couch_event:notify(Db2#db.name, updated), {ok, Db2, Replies}. diff --git a/src/couch/src/couch_server.erl b/src/couch/src/couch_server.erl index 6db3f7448..f57bf3b81 100644 --- a/src/couch/src/couch_server.erl +++ b/src/couch/src/couch_server.erl @@ -27,6 +27,7 @@ -export([get_engine_extensions/0]). -export([get_engine_path/2]). -export([lock/2, unlock/1]). +-export([db_updated/1]). % config_listener api -export([handle_config_change/5, handle_config_terminate/3]). @@ -873,6 +874,10 @@ unlock(DbName) when is_binary(DbName) -> ok. +db_updated(Db) -> + gen_server:call(couch_server, {db_updated, Db}, infinity). + + -ifdef(TEST). -include_lib("eunit/include/eunit.hrl"). |