Skip to content

Commit

Permalink
migrate from version 2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
kbarbounakis committed Oct 6, 2020
1 parent 18da705 commit 08973c5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
29 changes: 23 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,28 @@ Register Generic Pool Adapter on app.json as follows:
The generic pool adapter will try to instantiate the adapter defined in options.adapter property.

# Options

### adapter:
The name of the data adapter to be linked with this pool adapter.
### size:
The number of the data adapters that are going to be pooled for new connections. The default value is 25.
### timeout:
A number of milliseconds to wait for getting a new data adapter. If this timeout exceeds, a timeout error will occured. The default value is 30000.
### lifetime
A number of milliseconds which indicates whether or not a pooled data adapter will be automatically ejected from data adapters' collection. The default value is 1200000.

`@themost/pool` adapter uses [generic-pool](https://github.com/coopernurse/node-pool#documentation).
Read more about `generic-pool` [here](https://github.com/coopernurse/node-pool#documentation)

Important Note: Upgrade from 2.2.x to 2.5.x

Replace `@themost/pool@2.2.x` configuration:

{
"adapter": "development",
"size": 25,
"timeout": 30000,
"lifetime": 1200000
}

with:

{
"adapter": "development",
"max": 25,
"acquireTimeoutMillis": 30000
}
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,14 @@ function createInstance(options) {
/**
* @type {*}
*/
// upgrade from 2.2.x
if (typeof options.size === 'number') {
options.max = options.size
}
if (typeof options.timeout === 'number') {
options.acquireTimeoutMillis = options.timeout
}

let pool = GenericPoolAdapter[pools][name];
if (pool == null) {
//create new pool with the name specified in options
Expand Down
6 changes: 5 additions & 1 deletion spec/GenericPoolAdapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ describe('PoolAdapter', () => {
it('should create instance', () => {
const adapter = createInstance(
{
"adapter": "test"
"adapter": "test",
"size": 20
});
adapter.hasConfiguration(() => {
return configuration;
});
expect(adapter).toBeTruthy();
const pool = GenericPoolAdapter.pool('test');
expect(pool).toBeTruthy();
expect(pool.max).toBe(20);
});

it('should open and close', async () => {
Expand Down

0 comments on commit 08973c5

Please sign in to comment.