You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by "jiahuili430 (via GitHub)" <gi...@apache.org> on 2023/06/07 15:45:31 UTC

[GitHub] [couchdb] jiahuili430 commented on a diff in pull request #4627: Add QuickJS as a Javascript engine option

jiahuili430 commented on code in PR #4627:
URL: https://github.com/apache/couchdb/pull/4627#discussion_r1221825609


##########
src/couch_quickjs/src/couch_quickjs.erl:
##########
@@ -0,0 +1,52 @@
+% 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.
+
+% Reads CouchDB's ini file and gets queried for configuration parameters.
+% This module is initialized with a list of ini files that it consecutively
+% reads Key/Value pairs from and saves them in an ets table. If more an one
+% ini file is specified, the last one is used to write changes that are made
+% with store/2 back to that ini file.
+
+-module(couch_quickjs).
+
+-export([
+    mainjs_cmd/0,
+    coffee_cmd/0
+]).
+
+mainjs_cmd() ->
+    Path = filename:join([priv_dir(), "couchjs_mainjs"]),
+    check_path(Path),
+    apply_config(Path).
+
+coffee_cmd() ->
+    Path = filename:join([priv_dir(), "couchjs_coffee"]),
+    check_path(Path),
+    apply_config(Path).
+
+priv_dir() ->
+    case code:priv_dir(couch_quickjs) of
+        {error, bad_name} -> error({?MODULE, app_dir_not_found});
+        Dir when is_list(Dir) -> Dir
+    end.
+
+check_path(Path) ->
+    case filelib:is_file(Path) of
+        true -> ok;
+        false -> error({?MODULE, {missing, Path}})
+    end.
+
+apply_config(Path) ->
+    case config:get("quickjs", "memory_limit_bytes") of

Review Comment:
   Do we need a default setting here?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org