Gathering detailed insights and metrics for plan
Gathering detailed insights and metrics for plan
Gathering detailed insights and metrics for plan
Gathering detailed insights and metrics for plan
@changesets/apply-release-plan
Takes a release plan and applies it to packages
redux-saga-test-plan
Test Redux Saga with an easy plan
@mui/x-data-grid
The Community plan edition of the Data Grid components (MUI X).
@mui/x-data-grid-pro
The Pro plan edition of the Data Grid components (MUI X).
npm install plan
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
20 Stars
52 Commits
2 Forks
3 Watching
1 Branches
1 Contributors
Updated on 14 Jun 2021
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-50%
1
Compared to previous day
Last week
-77.8%
4
Compared to previous week
Last month
58.3%
38
Compared to previous month
Last year
16%
362
Compared to previous year
Execute a complicated dependency graph of tasks with smooth progress events.
Here are some examples:
In this example, we will download a song from s3, generate a waveform image and preview audio, and upload each generated thing to s3, all the while reporting smooth and accurate processing progress to the end user.
1var Plan = require('plan') 2 , WaveformTask = require('plan-waveform') 3 , TranscodeTask = require('plan-transcode') 4 , UploadS3Task = require('plan-s3-upload') 5 , DownloadS3Task = require('plan-s3-download') 6 7var downloadTask = Plan.createTask(DownloadS3Task, "download", { 8 s3Key: '...', 9 s3Bucket: '...', 10 s3Secret: '...', 11}) 12var waveformTask = Plan.createTask(WaveformTask, "waveform", { 13 width: 1000, 14 height: 200, 15}); 16var previewTask = Plan.createTask(TranscodeTask, "preview", { 17 format: 'mp3' 18}); 19var uploadWaveformTask = Plan.createTask(UploadS3Task, "upload-waveform", { 20 url: "/{uuid}/waveform{ext}" 21 s3Key: '...', 22 s3Bucket: '...', 23 s3Secret: '...', 24}) 25var uploadPreviewTask = Plan.createTask(UploadS3Task, "upload-preview", { 26 s3Key: '...', 27 s3Bucket: '...', 28 s3Secret: '...', 29}) 30 31// planId is used to index progress statistics. Same with the 2nd parameter 32// to `Plan.createTask` above. Next time we run the same planId, node-plan 33// uses the gathered stats to inform the progress events, so that they will 34// be much more accurate and smooth. 35var planId = "process-audio"; 36 37var plan = new Plan(planId); 38plan.addTask(uploadPreviewTask); 39plan.addDependency(uploadPreviewTask, previewTask); 40plan.addDependency(previewTask, downloadTask); 41plan.addTask(uploadWaveformTask); 42plan.addDependency(uploadWaveformTask, waveformTask); 43plan.addDependency(waveformTask, downloadTask); 44plan.on('error', function(err, task) { 45 console.log("task", task.name, "error", err); 46}); 47plan.on('progress', function(amountDone, amountTotal) { 48 console.log("progress", amountDone, amountTotal); 49}); 50plan.on('update', function(task) { 51 console.log("update", task.exports); 52}); 53plan.on('end', function(context) { 54 console.log("done", context); 55}); 56var context = { 57 s3Url: '/the/file/to/download', 58 makeTemp: require('temp').path 59}; 60plan.start(context);
Creating a service such as TransloadIt.
Mediablast is an open source service such as this running on node-plan.
1var TaskDefinition = {};
1TaskDefinition.start = function(done) {
2 ...
3};
start
is your main entry point. When you are finished processing, call
done
. In this scope, this
points to the task instance.
If your task encounters an error, call done with the error object as the first parameter.
context
acts as your input as well as your output. Sometimes it makes
sense to delete the parameter that you are using; sometimes it does not.
Access context
via this.context
in the start
function.
exports
is output that is tied to the task instance and is not passed to
the next task in the dependency graph.
There are some special fields on exports
that you should be wary of:
Fields you should write to:
exports.amountTotal
- as soon as you find out how long executing this
task is going to take, set amountTotal
. If the task is unable to emit
progress, node-plan will guess based on previous statistics.exports.amountDone
- this number will change based on progress whereas
amountTotal
should not.Whenever you update amountDone
or amountTotal
, you should emit a
progress
event: this.emit('progress')
. Don't worry about emitting
an update
event for this case.
Fields you should not write to:
exports.startDate
- the date the task instance startedexports.endDate
- the date the task instance completedexports.state
- one of ['queued', 'skipped', 'processing', 'complete']
queued
- this task has not yet been startedskipped
- this task has been skipped, because one or more of its
dependencies emitted an error, and ignoreDependencyErrors
is not
set to true
.processing
- this task is currently in progresscomplete
- this task has completed, possibly unsuccessfully.You are free to add as many other exports
fields as you wish.
Whenever you change something in exports
, you should emit a update
event: this.emit('update')
.
Access exports
via this.exports
in the start
function.
options
are per-task-instance configuration values. It is the third
parameter of Plan.createTask(definition, name, options)
.
Access options
via this.options
in the start
function.
If your task spawns a CPU-intensive process and waits for it to complete,
you should mark your task as cpuBound
:
1TaskDefinition.cpuBound = true;
node-plan pools all cpuBound
tasks, defaulting to a worker count equal
to the number of CPU cores on your machine.
planId
is used for the progress heuristics. when you're building a
similar plan, use the same planId
and progress events will use
past statistics for accuracy and smoothness.
Set this to limit the number of simultaneous CPU-bound tasks.
definition
- task definition described abovename
- a string, used to store statistics data. If you're doing a similar
task, use the same name.options
- an object which is passed to the task instance to configure it.
In addition to the options which the task definition recognizes, all tasks
have these additional built-in options:
ignoreDependencyErrors
- if set to true, the task will execute even if
one or more of its dependencies did not suceed. default false.This adds a root node to the dependency graph. If you imagine a tree, where
the plan instance itself is the root node, addTask
adds a task to the root node.
This is how you specify dependencies. dependencyTask
becomes a leaf node of
targetTask
.
Executes the plan. context
is cloned and passed to all leaf nodes. Task
instances modify context
and pass a clone to the next task in the tree.
The plan has completed executing successfully. context
is a merged result
object of the tasks that were added with addTask
.
One or more tasks returned an error. err
is the error object.
Tells you how far along the execution of the plan is.
Occurs when a task instance's exports
have updated.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More