couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kxe...@apache.org
Subject [15/32] git commit: updated refs/heads/1781-reorganize-and-improve-docs to 11fd32a
Date Fri, 14 Jun 2013 08:25:12 GMT
Describe native_query_servers config section.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/77906b34
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/77906b34
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/77906b34

Branch: refs/heads/1781-reorganize-and-improve-docs
Commit: 77906b3488119cdc6bba4eec91b57c246b66fb0f
Parents: e9d07a6
Author: Alexander Shorin <kxepal@apache.org>
Authored: Wed Jun 12 14:01:40 2013 +0400
Committer: Alexander Shorin <kxepal@apache.org>
Committed: Wed Jun 12 16:06:29 2013 +0400

----------------------------------------------------------------------
 share/doc/build/Makefile.am                   |  3 +
 share/doc/src/config/index.rst                |  1 +
 share/doc/src/config/native-query-servers.rst | 66 ++++++++++++++++++++++
 share/doc/src/query-servers.rst               | 24 +-------
 4 files changed, 73 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/77906b34/share/doc/build/Makefile.am
----------------------------------------------------------------------
diff --git a/share/doc/build/Makefile.am b/share/doc/build/Makefile.am
index 932ee37..07bea38 100644
--- a/share/doc/build/Makefile.am
+++ b/share/doc/build/Makefile.am
@@ -63,6 +63,7 @@ html_files = \
     html/_sources/config/daemons.txt \
     html/_sources/config/httpd.txt \
     html/_sources/config/index.txt \
+    html/_sources/config/native-query-servers.txt \
     html/_sources/config/os-daemons.txt \
     html/_sources/config/ssl.txt \
     html/_sources/config/stats.txt \
@@ -123,6 +124,7 @@ html_files = \
     html/config/daemons.html \
     html/config/httpd.html \
     html/config/index.html \
+    html/config/native-query-servers.html \
     html/config/os-daemons.html \
     html/config/ssl.html \
     html/config/stats.html \
@@ -181,6 +183,7 @@ src_files = \
     ../src/config/daemons.rst \
     ../src/config/httpd.rst \
     ../src/config/index.rst \
+    ../src/config/native-query-servers.rst \
     ../src/config/os-daemons.rst \
     ../src/config/ssl.rst \
     ../src/config/stats.rst \

http://git-wip-us.apache.org/repos/asf/couchdb/blob/77906b34/share/doc/src/config/index.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/config/index.rst b/share/doc/src/config/index.rst
index 3552de1..ae787e1 100644
--- a/share/doc/src/config/index.rst
+++ b/share/doc/src/config/index.rst
@@ -56,6 +56,7 @@ Content:
    couchdb
    daemons
    httpd
+   native-query-servers
    os-daemons
    ssl
    stats

http://git-wip-us.apache.org/repos/asf/couchdb/blob/77906b34/share/doc/src/config/native-query-servers.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/config/native-query-servers.rst b/share/doc/src/config/native-query-servers.rst
new file mode 100644
index 0000000..2d59474
--- /dev/null
+++ b/share/doc/src/config/native-query-servers.rst
@@ -0,0 +1,66 @@
+.. 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.
+
+.. highlight:: ini
+
+.. _config/native_query_servers:
+
+``[native_query_servers]`` :: Native Erlang Query Server
+========================================================
+
+.. warning::
+
+   Due to security restrictions, the Erlang query server is disabled by
+   default.
+
+   Unlike the JavaScript query server, the Erlang one does not runs in a sandbox
+   mode. This means that Erlang code has full access to your OS,
+   filesystem and network, which may lead to security issues. While Erlang
+   functions are faster than JavaScript ones, you need to be careful
+   about running them, especially if they were written by someone else.
+
+CouchDB has a native Erlang query server, allowing you to write your map/reduce
+functions in Erlang. There is need no longer to manually install `erlview`_,
+unless you are running an old version (pre 0.10) of CouchDB.
+
+First, you'll need to edit your `local.ini` to include a
+``[native_query_servers]`` section::
+
+  [native_query_servers]
+  erlang = {couch_native_process, start_link, []}
+
+To see these changes you will also need to restart the server.
+To test out using :ref:`Erlang views <queryserver_erlang>`, visit the
+`Futon` admin interface, create a new database and open a temporary view.
+You should now be able to select ``erlang`` from the language drop-down.
+
+Let's try an example of map/reduce functions which count the total documents at
+each number of revisions (there are x many documents at version "1", and y
+documents at "2"... etc). Add a few documents to the database, then enter the
+following functions as a temporary view:
+
+.. code-block:: erlang
+
+  %% Map Function
+  fun({Doc}) ->
+    <<K,_/binary>> = proplists:get_value(<<"_rev">>, Doc, null),
+    V = proplists:get_value(<<"_id">>, Doc, null),
+    Emit(<<K>>, V)
+  end.
+
+  %% Reduce Function
+  fun(Keys, Values, ReReduce) -> length(Values) end.
+
+If all has gone well, after running the view you should see a list of the total
+number of documents at each revision number.
+
+.. _erlview: https://github.com/mmcdanie/erlview

http://git-wip-us.apache.org/repos/asf/couchdb/blob/77906b34/share/doc/src/query-servers.rst
----------------------------------------------------------------------
diff --git a/share/doc/src/query-servers.rst b/share/doc/src/query-servers.rst
index a3ca59e..82a3c0e 100644
--- a/share/doc/src/query-servers.rst
+++ b/share/doc/src/query-servers.rst
@@ -296,29 +296,11 @@ storing view functions at e.g. ``views.lib.map``, ``views.lib.reduce``,
etc.
 Erlang
 ======
 
-.. warning::
-
-   Unlike the JavaScript query server, the Erlang query server does not
-   run in a sandbox. This means Erlang code has full access to your OS,
-   filesystem and network, which may lead to security issues. While Erlang
-   functions are faster than JavaScript ones, you need to be careful
-   about running them, especially if they were written by someone else.
-
-
 .. note::
 
-   Due to security restrictions, the Erlang query server is disabled by
-   default. To enable it, you need to edit your `local.ini` to include a
-   ``native_query_servers`` section:
-
-   .. code-block:: ini
-
-      [native_query_servers]
-      erlang = {couch_native_process, start_link, []}
-
-   Don't forget to restart CouchDB after updating the configuration, and
-   use the ``language: "erlang"`` property in your Erlang design documents.
-
+   The Erlang query server is disabled by default.
+   Read :ref:`configuration guide <config/native_query_servers>` about
+   reasons why and how to enable it.
 
 .. function:: Emit(Id, Value)
 


Mime
View raw message