You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ga...@apache.org on 2020/04/23 12:05:15 UTC

[couchdb] branch prototype/fdb-layer updated: Add after_interactive_write plugin to couch_views_updater

This is an automated email from the ASF dual-hosted git repository.

garren pushed a commit to branch prototype/fdb-layer
in repository https://gitbox.apache.org/repos/asf/couchdb.git


The following commit(s) were added to refs/heads/prototype/fdb-layer by this push:
     new 3895223  Add after_interactive_write plugin to couch_views_updater
3895223 is described below

commit 38952237def3d6f6390ed5a0f201d580ca27db14
Author: Garren Smith <ga...@gmail.com>
AuthorDate: Thu Apr 23 12:10:07 2020 +0200

    Add after_interactive_write plugin to couch_views_updater
---
 src/couch_views/src/couch_views_epi.erl     |  4 ++-
 src/couch_views/src/couch_views_plugin.erl  | 40 +++++++++++++++++++++++++++++
 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 6d39d9a..127b09f 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 0000000..f816917
--- /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 f405123..30dfac3 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