@@ -186,6 +186,55 @@ MySQL.destroyConnection({
186
186
187
187
188
188
189
+ ////////////////////////////////////////////////////////////////////////////////////////
190
+ // AN ALTERNATE (SIMPLER) APPROACH
191
+ // (a driver-level concept of "manager" would allow us to avoid dealing with various
192
+ // different pooling implementations across different dbs)
193
+
194
+
195
+ // This is new:
196
+ // It is necessary because state needs to be managed outside of the context of
197
+ // one particular connection (e.g. pool or cluster pool, or custom cluster/sharding setup)
198
+ MySQL . createManager ( {
199
+ connectionString : 'mysql://...' ,
200
+ meta : {
201
+ // << this is where all sorts of stuff relating to
202
+ // connection configuration might be passed in (user/pass/host).
203
+ // There could be >1 connection strings if this is a cluster deployment
204
+ // with replicas and such-- that's up to the driver to implement.
205
+ }
206
+ } ) . exec ( /*...*/ ) ;
207
+
208
+
209
+ // destroyManager is critical because some packages (looking at you `mysql`)
210
+ // need to have special logic called in order to make the process exit gracefully.
211
+ // This is for use in the adapter's teardown method.
212
+ MySQL . destroyManager ( {
213
+ manager : manager ,
214
+ meta : { }
215
+ } ) . exec ( /*...*/ ) ;
216
+
217
+
218
+ // Instead of `connectionString`, now `getConnection()` expects a `manager`.
219
+ // Note that there is currently no standardized way to force a new connection
220
+ // to be opened. Individual drivers may implement this if they so choose using
221
+ // the `meta` input. To build additional pools, create more managers using
222
+ // `createManager()`. For further customizability, fork this driver.
223
+ MySQL . getConnection ( {
224
+ manager : manager ,
225
+ meta : { }
226
+ } ) . exec ( /*...*/ ) ;
227
+
228
+
229
+ // This is unchanged. Note that there is currently no standardized way to force a
230
+ // connection to be destroyed rather than released. Individual drivers may implement
231
+ // this if they so choose using the `meta` input. To forcibly kill a particular pool,
232
+ // call `destroyManager()`. For further customizability, fork this driver.
233
+ MySQL . releaseConnection ( {
234
+ connection : connection ,
235
+ meta : { }
236
+ } ) . exec ( /*...*/ ) ;
237
+
189
238
190
239
191
240
@@ -224,7 +273,9 @@ Waterline.transaction({
224
273
during : function ( T , done ) {
225
274
226
275
276
+ }
227
277
278
+ } ) ;
228
279
229
280
230
281
// MOVING ON
0 commit comments