2.3.0 • Published 5 years ago

action-flow v2.3.0

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

just-mongo

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

// commonJS
const AF = require('action-flow').default(options);
// es modules
import AFCreator from 'action-flow';
const AF = AFCreator(options);

2) Describe the operation. Any objects will accepted to describing.

const userRequestFlow = AF.create({
  description: 'user-request',
  userId,
});

Or you can create a common thread for any threads.

const anyFlow = AF.multi([
  {one: 1}, {two: 2},
]);

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.await();

4) Do your code.

// execute user request code

5) Set the ending the operation.

await userRequestFlow.end();

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 = require('action-flow')({
  host: 'localhost',
  password: 'yourPwd',
});

process

Storage in Node.js process memory. No specific options.

const AF = require('action-flow')({
  driverName: 'process',
});

mongodb

MongoDB storage.

Options (optional): user, password, host, port.

const AF = require('action-flow')({
  host: 'localhost',
});

Use driverClass option to connect custom driver.

const AF = require('action-flow')({
  driverName: 'custom',
  driverClass: someClass,
});

More options

NameDescriptionRequiredDefault
awaitTimeoutSecMaximum waiting timefalse60
sessionNamePrefix for all descriptionsfalsenull
noSHATurn off sha256 for descriptionfalsefalse

Other docs:

2.3.0

5 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago

0.0.1

7 years ago