You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ro...@apache.org on 2023/02/28 08:19:19 UTC
[couchdb] 01/01: Deno Test
This is an automated email from the ASF dual-hosted git repository.
ronny pushed a commit to branch couchdb-deno
in repository https://gitbox.apache.org/repos/asf/couchdb.git
commit 6ca99634620ecc04d259f41391a2646ca3076707
Author: Ronny Berndt <ro...@apache.org>
AuthorDate: Tue Nov 29 15:37:04 2022 +0100
Deno Test
Simple test branch with work from Jan.
---
dev/run | 4 ++++
src/couch_index/src/couch_index_updater.erl | 10 ++++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/dev/run b/dev/run
index df1a0b105..a0dd5b380 100755
--- a/dev/run
+++ b/dev/run
@@ -604,14 +604,18 @@ def set_boot_env(ctx):
# fudge default query server paths
couchjs = os.path.join(ctx["rootdir"], "src", "couch", "priv", "couchjs")
mainjs = os.path.join(ctx["rootdir"], "share", "server", "main.js")
+ denojs = os.path.join(ctx["rootdir"], "share", "server", "main-deno.js")
coffeejs = os.path.join(ctx["rootdir"], "share", "server", "main-coffee.js")
qs_javascript = toposixpath("%s %s" % (couchjs, mainjs))
qs_coffescript = toposixpath("%s %s" % (couchjs, coffeejs))
+ qs_deno = toposixpath("%s %s" % ("deno run --allow-write", denojs))
+
os.environ["COUCHDB_QUERY_SERVER_JAVASCRIPT"] = qs_javascript
os.environ["COUCHDB_QUERY_SERVER_COFFEESCRIPT"] = qs_coffescript
+ os.environ["COUCHDB_QUERY_SERVER_DENO"] = qs_deno
@log("Start node {node}")
def boot_node(ctx, node):
diff --git a/src/couch_index/src/couch_index_updater.erl b/src/couch_index/src/couch_index_updater.erl
index fe2150505..e77d7bfed 100644
--- a/src/couch_index/src/couch_index_updater.erl
+++ b/src/couch_index/src/couch_index_updater.erl
@@ -28,7 +28,8 @@
-record(st, {
idx,
mod,
- pid = nil
+ pid = nil,
+ start_ts = 0
}).
start_link(Index, Module) ->
@@ -60,7 +61,7 @@ handle_call({update, IdxState}, _From, #st{idx = Idx, mod = Mod} = State) ->
Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
couch_log:info("Starting index update for db: ~s idx: ~s", Args),
Pid = spawn_link(?MODULE, update, [Idx, Mod, IdxState]),
- {reply, ok, State#st{pid = Pid}};
+ {reply, ok, State#st{pid = Pid, start_ts = erlang:system_time(seconds)}};
handle_call({restart, IdxState}, _From, #st{idx = Idx, mod = Mod} = State) ->
Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
couch_log:info("Restarting index update for db: ~s idx: ~s", Args),
@@ -88,8 +89,9 @@ handle_cast(_Mesg, State) ->
handle_info({'EXIT', _, {updated, Pid, IdxState}}, #st{pid = Pid} = State) ->
Mod = State#st.mod,
- Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState)],
- couch_log:info("Index update finished for db: ~s idx: ~s", Args),
+ Index_time = erlang:system_time(seconds) - State#st.start_ts,
+ Args = [Mod:get(db_name, IdxState), Mod:get(idx_name, IdxState), Index_time],
+ couch_log:info("Index update finished for db: ~s idx: ~s time: ~p s", Args),
ok = gen_server:cast(State#st.idx, {updated, IdxState}),
{noreply, State#st{pid = undefined}};
handle_info({'EXIT', _, {reset, Pid}}, #st{idx = Idx, pid = Pid} = State) ->