summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Sun <tony.sun427@gmail.com>2020-07-24 09:47:09 -0700
committerTony Sun <tony.sun427@gmail.com>2020-07-24 09:48:16 -0700
commit0a444461920c2b95d9ef8ef3c6512ee37f9af351 (patch)
tree18fabc1a1ec3b3d4eef9b9d4b4ffacf195422549
parentf811f3f56cef4527e75ae591fcb4dbfeb69636f5 (diff)
downloadcouchdb-0a444461920c2b95d9ef8ef3c6512ee37f9af351.tar.gz
add get_active_job_ids and get_types
We expose get_types in couch_jobs and also add get_active_jobs_ids to get the active job ids given a certain type.
-rw-r--r--src/couch_jobs/src/couch_jobs.erl19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/couch_jobs/src/couch_jobs.erl b/src/couch_jobs/src/couch_jobs.erl
index 88b4bf470..f6fb62664 100644
--- a/src/couch_jobs/src/couch_jobs.erl
+++ b/src/couch_jobs/src/couch_jobs.erl
@@ -19,6 +19,8 @@
remove/3,
get_job_data/3,
get_job_state/3,
+ get_active_jobs_ids/2,
+ get_types/1,
% Job processing
accept/1,
@@ -104,6 +106,23 @@ get_job_state(Tx, Type, JobId) when is_binary(JobId) ->
end).
+-spec get_active_jobs_ids(jtx(), job_type()) -> [job_id()] | {error,
+ any()}.
+get_active_jobs_ids(Tx, Type) ->
+ couch_jobs_fdb:tx(couch_jobs_fdb:get_jtx(Tx), fun(JTx) ->
+ Since = couch_jobs_fdb:get_active_since(JTx, Type,
+ {versionstamp, 0, 0}),
+ maps:keys(Since)
+ end).
+
+
+-spec get_types(jtx()) -> [job_type()] | {error, any()}.
+get_types(Tx) ->
+ couch_jobs_fdb:tx(couch_jobs_fdb:get_jtx(Tx), fun(JTx) ->
+ couch_jobs_fdb:get_types(JTx)
+ end).
+
+
%% Job processor API
-spec accept(job_type()) -> {ok, job(), job_data()} | {error, any()}.