diff options
author | Tony Sun <tony.sun427@gmail.com> | 2020-07-24 09:47:09 -0700 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2020-09-09 09:44:58 -0500 |
commit | cc37f4278043cd4d21c9b7ffd3160b937cee57bc (patch) | |
tree | c772f8dfade53062b528e6dcb0f5de5c286a1860 | |
parent | bef183170ebc4faa549d3692423e5b510ce92d63 (diff) | |
download | couchdb-cc37f4278043cd4d21c9b7ffd3160b937cee57bc.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.erl | 19 |
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()}. |