-
Notifications
You must be signed in to change notification settings - Fork 0
feat(core): simple active tasks implementation #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| return this.tasks; | ||
| }; | ||
|
|
||
| ActiveTasks.prototype.add = function (task) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API naming nitpick, pairing add with get feels a bit off to me, how about create maybe.
I have no super strong feelings about this, or research to back this up, but add conveys to me “append to an existing list” which is an implementation detail from behind the API, whereas create conveys more “I need a new task” from the user-side of the API.
There is probably an equally strong linguistic argument for going the other way around, so the is more taste than a required change.
One thing that would be nice, but doesn’t quite fit would be to mirror the PouchDB API for doc, but that mirrors the HTTP verbs used by CouchDB and I think that is taking it a little too far (we’d use .post() to update.
0c0c60e to
903fe7c
Compare
4a95fae to
887ee4a
Compare
5ff2d89 to
c76d531
Compare
7dad3a4 to
7d2f323
Compare
|
|
||
| var task = src.activeTasks.get(taskId); | ||
| if (task) { | ||
| src.info().then(function (info) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might there a different way of updating total_items here for continuous replication other than regularly fetching the database info? we've had a bug where this callback ran into an error due to currentBatch being set to undefined—it was clearly defined before src.info() was called, so this happened in the meantime.
7239322 to
bcaeecc
Compare
afc3644 to
6e003f3
Compare
6e003f3 to
55099b1
Compare
8c9daed to
58fc42b
Compare
Quick first implementation in line with apache#8422.
Covered long-running tasks:
abstract-mapreducewhen not using theindexeddbadapter)indexeddbadapter brings its own find indexing/querying implementation based on native IDB indexes, which don't support precise progress monitoringTests
Run tests for this feature:
$ GREP="active_tasks" && npm testDemo
We've built a demo application for trying out (and visualizing) the activeTasks API for monitoring long-running tasks: https://github.com/neighbourhoodie/pouchdb-activetasks-demo
Real-time logging
Real-time logging of activeTasks via Proxies
At the top of the
<script>tag in the file above, add:This traps the method calls, runs console logs and then the original target methods. It can be extended to become an event emitter or whatever.