-
Notifications
You must be signed in to change notification settings - Fork 3
FTP.Queue
FTP. Queue
at the example below to see how we override the callback
function to perform additional actions before exiting
the queue and loading the next one.
Functions created with this provide a synchronized queue
that is asynchronous in itself, so items will be processed
in the order they are received, but this will happen
immediately. Meaning, if you make a dozen sequential calls
to FTP#filemtime they will all be read immediately,
queued in order, and then processed one after the other.
Name | Type | Description |
---|---|---|
command |
string |
The command that will be issued ie: “CWD foo” |
- Source:
- See:
- To Do:
-
- - make OO – double check endproc and then callback ? or callback and endproc
- Type
-
function
//the current implementation of FTP.rename is preferred,
//this is merely being used as an example
var myCustomRename = (function () {
var myQueueManager = ftp.Queue.create(‘RNFR’);
return function (pathArray, callback) {
var from = pathArray0,
to = pathArray1;
//override the callback, Queue’s expect the
//first parameter to be a string
myQueueManager(from, function (err, data) {
if (err) {
dbg(err);
} else {
//provide custom function and trigger callback when done
ftp.raw(’RNTO ’ + to, callback);
}
});
}
}());
Name | Type | Description |
---|---|---|
RunLast |
number |
value needed for runLevel parameter, will add command to the end of the queue; default Queue.RunLevel; |
- Source:
- See:
- default RunLevel FTP.Queue.RunLast
- Most methods use the FTP#run call.
- Every FTP#run call issued is stacked in a series queue by default. To change to a waterfall
or run in parallel.
RunLevels are a design of FTPimp to control process flow only.
When implementing parallel actions, parallel calls should only be issued inside the callback
of a parent waterfall or series queue. Otherwise, the FTP service itself likely will break
from the concurrent connection attempts.
-
number
Name | Type | Description |
---|---|---|
last |
number |
FTP.Queue.RunLast will push the command to the end of the queue; |
now |
number |
FTP.Queue.RunNow will run the command immediately; will overrun a current processing queue |
next |
number |
FTP.Queue.RunNext will run after current queue completes |
- Source:
- See:
-
- FTP#mkdir, FTP#rmdir, FTP#put for examples
- FTP#run for series, FTP#runNext for waterfall, FTP#runNow for parallel
//series
ftp.ping(function () { //runs first
ftp.ping(function () { //runs third
});
});
ftp.ping(function () { //runs second
});
//waterfall
var runNext = FTP.Queue.RunNext;
ftp.ping(function () { //runs first
//add runNow to the call
ftp.ping(function () { //runs second
}, runNow);
});
ftp.ping(function () { //runs third
});
//parallel
var runNow = FTP.Queue.RunNow;
ftp.put(‘foo’, function () { //runs first
});
ftp.put(‘foo’, function () { //runs second
}, runNow);
Name | Type | Description |
---|---|---|
RunNext |
number |
value needed for runLevel parameter to run commands immediately after the current queue; |
- Source:
- See:
Name | Type | Description |
---|---|---|
RunNow |
number |
value needed for runLevel parameter to run commands immediately, overrunning any current queue process; |
- Source:
- See:
Name | Type | Description |
---|---|---|
command |
string |
The command that will be issued, no parameters, ie: “CWD” |
on the command (parameter 1)
Name | Type | Description |
---|---|---|
command |
string |
The command that will be issued, no parameters, ie: “CWD” |
callback |
function |
The callback function to be issued. |
- fileTransferComplete
- queueEmpty
- error
- ready