You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2019/06/03 14:09:31 UTC

[GitHub] [couchdb-documentation] nickva edited a comment on issue #409: RFC for CouchDB background workers

nickva edited a comment on issue #409: RFC for CouchDB background workers
URL: https://github.com/apache/couchdb-documentation/pull/409#issuecomment-497515890
 
 
   Latest update:
   
   https://github.com/apache/couchdb/commit/62f786ea5eae777c58444a297240d41def3ed11a
   
   The basics now seem to work.
   
   This is an example of subscribing to a job status and waiting for to finished.
   
   ```erlang
   > couch_jobs:add(<<"t1">>, <<"j1">>, #{<<"data">> => #{my_data => blah}}).
   ok
   
   > f(Lock1), {ok, _, Lock1} = couch_jobs:accept(<<"t1">>).
   {ok,<<"j1">>,<<"2be00fa90ec3ef5caaedb4d22d9d7f59">>}
   
   > fabric2_fdb:transactional(fun(Tx) -> couch_jobs:update(Tx, <<"t1">>, <<"j1">>, #{data => #{my_data => <<"xyzc">>}}, Lock1) end).
   ok
   
   > fabric2_fdb:transactional(fun(Tx) -> couch_jobs:finish(Tx, <<"t1">>, <<"j1">>, #{}, Lock1) end).
   ok
   ```
   
   In a separate terminal
   
   ```erlang
   
   > {ok, SubRef, InitState} = couch_jobs:subscribe(<<"t1">>, <<"j1">>).
   {ok,{<0.1271.0>,#Ref<0.2568083611.2369781761.6545>},pending}
   
   > couch_jobs:wait_job_state(SubRef, finished, infinity).
   {<<"t1">>,<<"j1">>,finished}
   ```
   
   Also 90% test coverage
   
   ```
   $ make eunit apps=couch_jobs
         couch_jobs_tests:96: add_remove_pending...[0.038 s] ok
         couch_jobs_tests:109: add_remove_errors...[0.017 s] ok
         couch_jobs_tests:123: get_jobs...[0.038 s] ok
         couch_jobs_tests:148: resubmit_as_job_creator...[0.042 s] ok
         couch_jobs_tests:169: type_timeouts_and_server...[0.020 s] ok
         couch_jobs_tests:197: dead_notifier_restarts_jobs_server...[0.013 s] ok
         couch_jobs_tests:210: worker_accept_and_finish...[0.034 s] ok
         couch_jobs_tests:230: worker_update...[0.056 s] ok
         couch_jobs_tests:263: resubmit_enqueues_job...[0.055 s] ok
         couch_jobs_tests:290: add_custom_priority...[0.037 s] ok
         couch_jobs_tests:301: resubmit_custom_priority...[0.037 s] ok
         couch_jobs_tests:316: accept_max_priority...[0.033 s] ok
         couch_jobs_tests:326: subscribe...[0.666 s] ok
         couch_jobs_tests:367: subscribe_callback...[0.048 s] ok
         couch_jobs_tests:391: enqueue_inactive...[4.030 s] ok
         couch_jobs_tests:419: cancel_running_job...[0.037 s] ok
         couch_jobs_tests:439: stop_and_remove_running_job...[0.084 s] ok
   
   Cover analysis: /Users/nvatama/asf/src/couch_jobs/.eunit/index.html
   
   Code Coverage:
   couch_jobs                      :  83%
   couch_jobs_activity_monitor     :  78%
   couch_jobs_activity_monitor_sup : 100%
   couch_jobs_app                  : 100%
   couch_jobs_fdb                  :  94%
   couch_jobs_notifier             :  87%
   couch_jobs_notifier_sup         : 100%
   couch_jobs_pending              :  91%
   couch_jobs_server               :  84%
   couch_jobs_sup                  : 100%
   couch_jobs_type_monitor         :  94%
   
   Total                           : 90%
   ```

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services