Skip to content

Commit 0a3b3cf

Browse files
committed
docs: include FactoryOptions interface
1 parent 43d82b1 commit 0a3b3cf

File tree

4 files changed

+177
-3
lines changed

4 files changed

+177
-3
lines changed

docs/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ sequelize-pool
99
- [AggregateError](classes/aggregateerror.md)
1010
- [Pool](classes/pool.md)
1111
- [TimeoutError](classes/timeouterror.md)
12+
13+
### Interfaces
14+
15+
- [FactoryOptions](interfaces/factoryoptions.md)

docs/classes/pool.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Name |
3636

3737
### constructor
3838

39-
\+ **new Pool**<RawResource\>(`factory`: *FactoryOptions*<RawResource\>): [*Pool*](pool.md)<RawResource\>
39+
\+ **new Pool**<RawResource\>(`factory`: [*FactoryOptions*](../interfaces/factoryoptions.md)<RawResource\>): [*Pool*](pool.md)<RawResource\>
4040

4141
Generate an object pool with a specified `factory`.
4242

@@ -50,7 +50,7 @@ Name |
5050

5151
Name | Type |
5252
:------ | :------ |
53-
`factory` | *FactoryOptions*<RawResource\> |
53+
`factory` | [*FactoryOptions*](../interfaces/factoryoptions.md)<RawResource\> |
5454

5555
**Returns:** [*Pool*](pool.md)<RawResource\>
5656

docs/interfaces/factoryoptions.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
[sequelize-pool](../README.md) / FactoryOptions
2+
3+
# Interface: FactoryOptions<T\>
4+
5+
Factory options. Used for generating/destroying/validating resources & other configuration
6+
7+
## Type parameters
8+
9+
Name |
10+
:------ |
11+
`T` |
12+
13+
## Table of contents
14+
15+
### Properties
16+
17+
- [acquireTimeoutMillis](factoryoptions.md#acquiretimeoutmillis)
18+
- [create](factoryoptions.md#create)
19+
- [destroy](factoryoptions.md#destroy)
20+
- [idleTimeoutMillis](factoryoptions.md#idletimeoutmillis)
21+
- [log](factoryoptions.md#log)
22+
- [max](factoryoptions.md#max)
23+
- [maxUses](factoryoptions.md#maxuses)
24+
- [min](factoryoptions.md#min)
25+
- [name](factoryoptions.md#name)
26+
- [reapIntervalMillis](factoryoptions.md#reapintervalmillis)
27+
- [validate](factoryoptions.md#validate)
28+
29+
## Properties
30+
31+
### acquireTimeoutMillis
32+
33+
`Optional` **acquireTimeoutMillis**: *number*
34+
35+
Delay in milliseconds after which pending acquire request in the pool will be rejected.
36+
Pending acquires are acquire calls which are yet to receive an response from factory.create
37+
38+
**`default`** 30000
39+
40+
___
41+
42+
### create
43+
44+
**create**: () => *Promise*<T\>
45+
46+
Should create the item to be acquired
47+
48+
#### Type declaration:
49+
50+
▸ (): *Promise*<T\>
51+
52+
**Returns:** *Promise*<T\>
53+
54+
___
55+
56+
### destroy
57+
58+
**destroy**: (`resource`: T) => *void* \| *Promise*<void\>
59+
60+
Should gently close any resources that the item is using.
61+
Called when resource is destroyed.
62+
63+
#### Type declaration:
64+
65+
▸ (`resource`: T): *void* \| *Promise*<void\>
66+
67+
#### Parameters:
68+
69+
Name | Type |
70+
:------ | :------ |
71+
`resource` | T |
72+
73+
**Returns:** *void* \| *Promise*<void\>
74+
75+
___
76+
77+
### idleTimeoutMillis
78+
79+
`Optional` **idleTimeoutMillis**: *number*
80+
81+
Delay in milliseconds after which available resources in the pool will be destroyed.
82+
This does not affects pending acquire requests.
83+
84+
**`default`** 30000
85+
86+
___
87+
88+
### log
89+
90+
`Optional` **log**: *boolean* \| FactoryLogger
91+
92+
Whether the pool should log activity. If function is specified,
93+
that will be used instead. The function expects the arguments msg, loglevel
94+
95+
**`default`** false
96+
97+
___
98+
99+
### max
100+
101+
**max**: *number*
102+
103+
Maximum number of items that can exist at the same time.
104+
Any further acquire requests will be pushed to the waiting list.
105+
106+
___
107+
108+
### maxUses
109+
110+
`Optional` **maxUses**: *number*
111+
112+
The number of times an item is to be used before it is destroyed
113+
no matter whether it is still healthy. A value of 0 indicates the
114+
item should be used indefinitely so long as it is healthy.
115+
This can help with "re-balancing" connections when pool members behind
116+
a load balancer are added but are not being adopted due to pools being
117+
full of pre-existing persistent connections.
118+
119+
**`default`** Infinity
120+
121+
___
122+
123+
### min
124+
125+
**min**: *number*
126+
127+
Minimum number of items in pool (including in-use).
128+
When the pool is created, or a resource destroyed, this minimum will
129+
be checked. If the pool resource count is below the minimum, a new
130+
resource will be created and added to the pool.<Paste>
131+
132+
___
133+
134+
### name
135+
136+
`Optional` **name**: *string*
137+
138+
Name of the factory. Serves only logging purposes.
139+
140+
___
141+
142+
### reapIntervalMillis
143+
144+
`Optional` **reapIntervalMillis**: *number*
145+
146+
Clean up is scheduled in every `factory.reapIntervalMillis` milliseconds.
147+
148+
**`default`** 1000
149+
150+
___
151+
152+
### validate
153+
154+
**validate**: (`resource`: T) => *boolean*
155+
156+
Should return true if connection is still valid and false
157+
If it should be removed from pool. Called before item is
158+
acquired from pool.
159+
160+
#### Type declaration:
161+
162+
▸ (`resource`: T): *boolean*
163+
164+
#### Parameters:
165+
166+
Name | Type |
167+
:------ | :------ |
168+
`resource` | T |
169+
170+
**Returns:** *boolean*

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export { TimeoutError } from './TimeoutError';
22
export { AggregateError } from './AggregateError';
3-
export { Pool } from './Pool';
3+
export { Pool, FactoryOptions } from './Pool';

0 commit comments

Comments
 (0)