Action flow 2.3
Smart mutex manager.
Example
You can pause the user's requests until the user's previous request is executed.
How it works?
1) Connect and configure the action-flow
// commonJSconst AF = ;// es modules;const AF = ;
2) Describe the operation. Any objects will accepted to describing.
const userRequestFlow = AF;
Or you can create a common thread for any threads.
const anyFlow = AF;
This way, only one client can executing these two operations at a time.
The thread of two operations will not start until these two threads of these operations are free. The expectation of a stream occurs sequentially to avoid deadlocks.
3) Set the waiting the operation.
await userRequestFlow;
4) Do your code.
// execute user request code
5) Set the ending the operation.
await userRequestFlow;
Drivers & Custom drivers
At now the action-flow have 3 drivers. To use specific driver, use driverName option.
- redis (default)
- process
- mongodb (just-mongo library is dev dependency, install that to use)
About each of drivers
redis
Queue storage in Redis lists.
Options (optional): host, port, password.
const AF = host: 'localhost' password: 'yourPwd';
process
Storage in Node.js process memory. No specific options.
const AF = driverName: 'process';
mongodb
MongoDB storage.
Options (optional): user, password, host, port.
const AF = host: 'localhost';
Use driverClass option to connect custom driver.
const AF = driverName: 'custom' driverClass: someClass;
More options
Name | Description | Required | Default |
---|---|---|---|
awaitTimeoutSec | Maximum waiting time | false | 60 |
sessionName | Prefix for all descriptions | false | null |
noSHA | Turn off sha256 for description | false | false |