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 10:10:50 UTC

[couchdb] branch add-couch-views-updater-plugin created (now c69ad1d)

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

garren pushed a change to branch add-couch-views-updater-plugin
in repository https://gitbox.apache.org/repos/asf/couchdb.git.


      at c69ad1d  Add after_interactive_write plugin to couch_views_updater

This branch includes the following new commits:

     new c69ad1d  Add after_interactive_write plugin to couch_views_updater

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: Add after_interactive_write plugin to couch_views_updater

Posted by ga...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

garren pushed a commit to branch add-couch-views-updater-plugin
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit c69ad1d1ade89e1d77de8ce24b51ee04c0caf979
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