diff options
author | Garren Smith <garren.smith@gmail.com> | 2020-04-23 12:10:07 +0200 |
---|---|---|
committer | garren smith <garren.smith@gmail.com> | 2020-04-23 14:05:06 +0200 |
commit | 38952237def3d6f6390ed5a0f201d580ca27db14 (patch) | |
tree | 1abc955ab16fcdc8f49a7904a97e7887ef3e2de2 | |
parent | 8554329cd19765f7b187899cb12442464fca6ead (diff) | |
download | couchdb-38952237def3d6f6390ed5a0f201d580ca27db14.tar.gz |
Add after_interactive_write plugin to couch_views_updater
-rw-r--r-- | src/couch_views/src/couch_views_epi.erl | 4 | ||||
-rw-r--r-- | src/couch_views/src/couch_views_plugin.erl | 40 | ||||
-rw-r--r-- | src/couch_views/src/couch_views_updater.erl | 5 |
3 files changed, 47 insertions, 2 deletions
diff --git a/src/couch_views/src/couch_views_epi.erl b/src/couch_views/src/couch_views_epi.erl index 6d39d9a5e..127b09f13 100644 --- a/src/couch_views/src/couch_views_epi.erl +++ b/src/couch_views/src/couch_views_epi.erl @@ -39,7 +39,9 @@ providers() -> services() -> - []. + [ + {couch_views, couch_views_plugin} + ]. data_subscriptions() -> diff --git a/src/couch_views/src/couch_views_plugin.erl b/src/couch_views/src/couch_views_plugin.erl new file mode 100644 index 000000000..f8169179a --- /dev/null +++ b/src/couch_views/src/couch_views_plugin.erl @@ -0,0 +1,40 @@ +% 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_views_plugin). + + +-export([ + after_interactive_write/4 +]). + + +-define(SERVICE_ID, couch_views). + + +after_interactive_write(Db, Mrst, Result, DocNumber) -> + with_pipe(after_interactive_write, [Db, Mrst, Result, DocNumber]), + ok. + + +%% ------------------------------------------------------------------ +%% Internal Function Definitions +%% ------------------------------------------------------------------ + +with_pipe(Func, Args) -> + do_apply(Func, Args, [pipe]). + + +do_apply(Func, Args, Opts) -> + Handle = couch_epi:get_handle(?SERVICE_ID), + couch_epi:apply(Handle, ?SERVICE_ID, Func, Args, Opts).
\ No newline at end of file diff --git a/src/couch_views/src/couch_views_updater.erl b/src/couch_views/src/couch_views_updater.erl index f405123fa..30dfac326 100644 --- a/src/couch_views/src/couch_views_updater.erl +++ b/src/couch_views/src/couch_views_updater.erl @@ -86,7 +86,10 @@ write_doc(Db, #doc{deleted = Deleted} = Doc) -> case should_index_doc(Doc, Mrst) of true -> {Mrst1, Result1} = couch_views_indexer:map_docs(Mrst, Result0), - couch_views_indexer:write_docs(Db, Mrst1, Result1, State), + DocNumber = couch_views_indexer:write_docs(Db, Mrst1, + Result1, State), + couch_views_plugin:after_interactive_write(Db, Mrst1, + Result1, DocNumber), couch_eval:release_map_context(Mrst1#mrst.qserver); false -> ok |