mapbox/tm2 — pull request #492 by yhahn (2014-07-01 04:41:08+00:00)
Title: Direct upload task API

Refactors copytask concept from master into a more generic task api. Part of https://github.com/mapbox/tm2/issues/472

- source mbtiles export moves from tm lib to `source.mbtilesExport`.
- task API exposes `task.get()`, `task.set()`, `task.del()` for handling of the active task. These are synchronous.
- to create a task, use the `task.Task` class which enforces that the task has all the right properties. A task must have:
- id: the id of the job, in this case the source id (`tmsource:/// ... `)
- type: either `export` or `upload`, maybe more in the future
- read: a readable stream that will be piped in the future
- progress: a progress stream that will be piped in the future
- to represent the final result of a task there is a `task.Done` class. A done object must have:
- id: the id of the job that's complete, in this case the source id (`tmsource:/// ... `)
- type: either `export` or `upload`, maybe more in the future
- url: the url of where to find the goods
- size: file size (??? **TODO** should this be optional ...)

### Remaining tasks

- Finish some tests, esp restore some testing of pause/cancel functionality
- Is `Task#read` necessary? Could we just unpipe the progress stream to cancel a task instead? ...

cc @camilleanne