new Queue(command) → {function}
Provides a factory to create a simple queue procedure. Look
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.
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.
Parameters:
Name | Type | Description |
---|---|---|
command |
string | The command that will be issued ie: "CWD foo" |
Returns:
queueManager - The simple queue manager
- Type
- function
Members
(static, readonly) RunLast
Properties:
Name | Type | Description |
---|---|---|
RunLast |
number | value needed for runLevel parameter, will add command to the end of the queue; default Queue.RunLevel; |
- Source:
- See:
(static, readonly) RunLevels :number
Static Queue value passed in the runLevel param of methods to control the priority of those methods.
- 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.
- 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.
Type:
- number
Properties:
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
Example
//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);
(static, readonly) RunNext
Properties:
Name | Type | Description |
---|---|---|
RunNext |
number | value needed for runLevel parameter to run commands immediately after the current queue; |
- Source:
- See:
(static, readonly) RunNow
Properties:
Name | Type | Description |
---|---|---|
RunNow |
number | value needed for runLevel parameter to run commands immediately, overrunning any current queue process; |
- Source:
- See:
Methods
(static) create(command)
Create a new Queue instance for the command type.
Parameters:
Name | Type | Description |
---|---|---|
command |
string | The command that will be issued, no parameters, ie: "CWD" |
(static) registerHook(command, callback)
Register a data hook function to intercept received data
on the command (parameter 1)
Parameters:
Name | Type | Description |
---|---|---|
command |
string | The command that will be issued, no parameters, ie: "CWD" |
callback |
function | The callback function to be issued. |