source: trip-planner-front/node_modules/qjobs/Readme.md@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.0 KB
Line 
1[![Build Status](https://secure.travis-ci.org/franck34/qjobs.png)](http://travis-ci.org/franck34/qjobs)
2
3**qjobs**
4==================
5***Efficient queue job manager module for nodejs.***
6
7Features
8--------------
9* Concurrency limiter
10* Dynamic queue, a job can be added while the queue is running
11* Optional delay before continuing after max concurrency has been reached
12* Support of pause/unpause
13* Events emitter based: start, end, sleep, continu, jobStart, jobEnd
14* Quick statistic function, so you can know where the queue is, at regular interval
15
16For what it can be usefull ?
17---------------------
18Jobs which needs to run in parallels, but in a controled maner, example:
19* Network scanners
20* Parallels monitoring jobs
21* Images/Videos related jobs
22
23
24Compatibility :
25------------------
26* not tested with nodejs < 0.10
27
28
29Examples
30--------------------
31
32(take a look at tests directory if you are looking for running samples)
33
34
35```
36var qjobs = new require('./qjobs');
37
38// My non blocking main job
39var myjob = function(args,next) {
40 setTimeout(function() {
41 console.log('Do something interesting here',args);
42 next();
43 },1000);
44}
45
46var q = new qjobs({maxConcurrency:10});
47
48// Let's add 30 job to the queue
49for (var i = 0; i<30; i++) {
50 q.add(myjob,[i,'test '+i]);
51}
52
53q.on('start',function() {
54 console.log('Starting ...');
55});
56
57q.on('end',function() {
58 console.log('... All jobs done');
59});
60
61q.on('jobStart',function(args) {
62 console.log('jobStart',args);
63});
64
65q.on('jobEnd',function(args) {
66
67 console.log('jobend',args);
68
69 // If i'm jobId 10, then make a pause of 5 sec
70
71 if (args._jobId == 10) {
72 q.pause(true);
73 setTimeout(function() {
74 q.pause(false);
75 },5000);
76 }
77});
78
79q.on('pause',function(since) {
80 console.log('in pause since '+since+' milliseconds');
81});
82
83q.on('unpause',function() {
84 console.log('pause end, continu ..');
85});
86
87q.run();
88
89//q.abort() will empty jobs list
90
91```
92
Note: See TracBrowser for help on using the repository browser.