You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: machines/create-manager.js
+62-58Lines changed: 62 additions & 58 deletions
Original file line number
Diff line number
Diff line change
@@ -8,13 +8,13 @@ module.exports = {
8
8
9
9
10
10
extendedDescription:
11
-
'The `manager` instance returned by this method contains any configuration that is necessary '+
12
-
'for communicating with the database and establishing connections (e.g. host, user, password) '+
13
-
'as well as any other relevant metadata. The manager will often also contain a reference '+
14
-
'to some kind of native container (e.g. a connection pool).\n'+
15
-
'\n'+
16
-
'Note that a manager instance does not necessarily need to correspond with a pool though--'+
17
-
'it might simply be a container for storing config, or it might refer to multiple pools '+
11
+
'The `manager` instance returned by this method contains any configuration that is necessary '+
12
+
'for communicating with the database and establishing connections (e.g. host, user, password) '+
13
+
'as well as any other relevant metadata. The manager will often also contain a reference '+
14
+
'to some kind of native container (e.g. a connection pool).\n'+
15
+
'\n'+
16
+
'Note that a manager instance does not necessarily need to correspond with a pool though--'+
17
+
'it might simply be a container for storing config, or it might refer to multiple pools '+
18
18
'(e.g. a PoolCluster from felixge\'s `mysql` package).',
19
19
20
20
@@ -34,14 +34,14 @@ module.exports = {
34
34
onUnexpectedFailure: {
35
35
description: 'A function to call any time an unexpected error event is received from this manager or any of its connections.',
36
36
extendedDescription:
37
-
'This can be used for anything you like, whether that\'s sending an email to devops, '+
38
-
'or something as simple as logging a warning to the console.\n'+
39
-
'\n'+
40
-
'For example:\n'+
41
-
'```\n'+
42
-
'onUnexpectedFailure: function (err) {\n'+
43
-
' console.warn(\'Unexpected failure in database manager:\',err);\n'+
44
-
'}\n'+
37
+
'This can be used for anything you like, whether that\'s sending an email to devops, '+
38
+
'or something as simple as logging a warning to the console.\n'+
39
+
'\n'+
40
+
'For example:\n'+
41
+
'```\n'+
42
+
'onUnexpectedFailure: function (err) {\n'+
43
+
' console.warn(\'Unexpected failure in database manager:\',err);\n'+
44
+
'}\n'+
45
45
'```',
46
46
example: '->'
47
47
},
@@ -62,10 +62,10 @@ module.exports = {
62
62
success: {
63
63
description: 'The manager was successfully created.',
64
64
extendedDescription:
65
-
'The new manager should be passed in to `getConnection()`.'+
66
-
'Note that _no matter what_, this manager must be capable of '+
67
-
'spawning an infinite number of connections (i.e. via `getConnection()`). '+
68
-
'The implementation of how exactly it does this varies on a driver-by-driver '+
65
+
'The new manager should be passed in to `getConnection()`.'+
66
+
'Note that _no matter what_, this manager must be capable of '+
67
+
'spawning an infinite number of connections (i.e. via `getConnection()`). '+
68
+
'The implementation of how exactly it does this varies on a driver-by-driver '+
69
69
'basis; and it may also vary based on the configuration passed into the `meta` input.',
70
70
outputVariableName: 'report',
71
71
outputDescription: 'The `manager` property is a manager instance that will be passed into `getConnection()`. The `meta` property is reserved for custom driver-specific extensions.',
@@ -88,19 +88,19 @@ module.exports = {
88
88
failed: {
89
89
description: 'Could not create a connection manager for this database using the specified connection string.',
90
90
extendedDescription:
91
-
'If this exit is called, it might mean any of the following:\n'+
92
-
' + the credentials encoded in the connection string are incorrect\n'+
93
-
' + there is no database server running at the provided host (i.e. even if it is just that the database process needs to be started)\n'+
94
-
' + there is no software "database" with the specified name running on the server\n'+
95
-
' + the provided connection string does not have necessary access rights for the specified software "database"\n'+
96
-
' + this Node.js process could not connect to the database, perhaps because of firewall/proxy settings\n'+
97
-
' + any other miscellaneous connection error\n'+
98
-
'\n'+
99
-
'Note that even if the database is unreachable, bad credentials are being used, etc, '+
100
-
'this exit will not necessarily be called-- that depends on the implementation of the driver '+
101
-
'and any special configuration passed to the `meta` input. e.g. if a pool is being used that spins up '+
102
-
'multiple connections immediately when the manager is created, then this exit will be called if any of '+
103
-
'those initial attempts fail. On the other hand, if the manager is designed to produce adhoc connections, '+
91
+
'If this exit is called, it might mean any of the following:\n'+
92
+
' + the credentials encoded in the connection string are incorrect\n'+
93
+
' + there is no database server running at the provided host (i.e. even if it is just that the database process needs to be started)\n'+
94
+
' + there is no software "database" with the specified name running on the server\n'+
95
+
' + the provided connection string does not have necessary access rights for the specified software "database"\n'+
96
+
' + this Node.js process could not connect to the database, perhaps because of firewall/proxy settings\n'+
97
+
' + any other miscellaneous connection error\n'+
98
+
'\n'+
99
+
'Note that even if the database is unreachable, bad credentials are being used, etc, '+
100
+
'this exit will not necessarily be called-- that depends on the implementation of the driver '+
101
+
'and any special configuration passed to the `meta` input. e.g. if a pool is being used that spins up '+
102
+
'multiple connections immediately when the manager is created, then this exit will be called if any of '+
103
+
'those initial attempts fail. On the other hand, if the manager is designed to produce adhoc connections, '+
104
104
'any errors related to bad credentials, connectivity, etc. will not be caught until `getConnection()` is called.',
105
105
outputVariableName: 'report',
106
106
outputDescription: 'The `error` property is a JavaScript Error instance with more information and a stack trace. The `meta` property is reserved for custom driver-specific extensions.',
@@ -113,9 +113,10 @@ module.exports = {
113
113
},
114
114
115
115
116
-
fn: function(inputs,exits){
116
+
fn: functioncreateManager(inputs,exits){
117
117
varutil=require('util');
118
118
varUrl=require('url');
119
+
var_=require('lodash');
119
120
varfelix=require('mysql');
120
121
121
122
@@ -133,7 +134,6 @@ module.exports = {
133
134
// contributions to the core driver in this area are welcome and greatly appreciated!
134
135
135
136
136
-
137
137
// Build a local variable (`_mysqlClientConfig`) to house a dictionary
138
138
// of additional MySQL options that will be passed into `.createPool()`
139
139
// (Note that these could also be used with `.connect()` or `.createPoolCluster()`)
@@ -148,11 +148,9 @@ module.exports = {
148
148
var_mysqlClientConfig={};
149
149
150
150
151
-
152
-
153
151
// Validate and parse `meta` (if specified).
154
-
if(!util.isUndefined(inputs.meta)){
155
-
if(!util.isObject(inputs.meta)){
152
+
if(!_.isUndefined(inputs.meta)){
153
+
if(!_.isObject(inputs.meta)){
156
154
returnexits.error('If provided, `meta` must be a dictionary.');
Copy file name to clipboardExpand all lines: machines/destroy-manager.js
+15-10Lines changed: 15 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -17,8 +17,12 @@ module.exports = {
17
17
required: true
18
18
},
19
19
20
-
meta:
21
-
require('../constants/meta.input')
20
+
meta: {
21
+
friendlyName: 'Meta (custom)',
22
+
description: 'Additional stuff to pass to the driver.',
23
+
extendedDescription: 'This is reserved for custom driver-specific extensions. Please refer to the documentation for the driver you are using for more specific information.',
24
+
example: '==='
25
+
}
22
26
23
27
},
24
28
@@ -38,8 +42,8 @@ module.exports = {
38
42
friendlyName: 'Failed',
39
43
description: 'Could not destroy the provided connection manager.',
40
44
extendedDescription:
41
-
'Usually, this means the manager has already been destroyed. But depending on the driver '+
42
-
'it could also mean that database cannot be accessed. In production, this can mean that the database '+
45
+
'Usually, this means the manager has already been destroyed. But depending on the driver '+
46
+
'it could also mean that database cannot be accessed. In production, this can mean that the database '+
43
47
'server(s) became overwhelemed or were shut off while some business logic was in progress.',
44
48
outputVariableName: 'report',
45
49
outputDescription: 'The `error` property is a JavaScript Error instance with more information and a stack trace. The `meta` property is reserved for custom driver-specific extensions.',
@@ -52,9 +56,7 @@ module.exports = {
52
56
},
53
57
54
58
55
-
fn: function(inputs,exits){
56
-
varutil=require('util');
57
-
59
+
fn: functiondestroyManager(inputs,exits){
58
60
// Note that if this driver is adapted to support managers which spawn
59
61
// ad-hoc connections or manage multiple pools/replicas using PoolCluster,
60
62
// then relevant settings would need to be included in the manager instance
Copy file name to clipboardExpand all lines: machines/get-connection.js
+21-18Lines changed: 21 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -13,17 +13,21 @@ module.exports = {
13
13
friendlyName: 'Manager',
14
14
description: 'The connection manager instance to acquire the connection from.',
15
15
extendedDescription:
16
-
'Only managers built using the `createManager()` method of this driver are supported. '+
17
-
'Also, the database connection manager instance provided must not have been destroyed--'+
18
-
'i.e. once `destroyManager()` is called on a manager, no more connections can be acquired '+
19
-
'from it (also note that all existing connections become inactive-- see `destroyManager()` '+
16
+
'Only managers built using the `createManager()` method of this driver are supported. '+
17
+
'Also, the database connection manager instance provided must not have been destroyed--'+
18
+
'i.e. once `destroyManager()` is called on a manager, no more connections can be acquired '+
19
+
'from it (also note that all existing connections become inactive-- see `destroyManager()` '+
20
20
'for more on that).',
21
21
example: '===',
22
22
required: true
23
23
},
24
24
25
-
meta:
26
-
require('../constants/meta.input')
25
+
meta: {
26
+
friendlyName: 'Meta (custom)',
27
+
description: 'Additional stuff to pass to the driver.',
28
+
extendedDescription: 'This is reserved for custom driver-specific extensions. Please refer to the documentation for the driver you are using for more specific information.',
29
+
example: '==='
30
+
}
27
31
28
32
},
29
33
@@ -43,12 +47,12 @@ module.exports = {
43
47
44
48
failed: {
45
49
description: 'Could not acquire a connection to the database using the specified manager.',
46
-
extendedDescription: 'This might mean any of the following:\n'+
47
-
' + the credentials encoded in the connection string are incorrect\n'+
48
-
' + there is no database server running at the provided host (i.e. even if it is just that the database process needs to be started)\n'+
49
-
' + there is no software "database" with the specified name running on the server\n'+
50
-
' + the provided connection string does not have necessary access rights for the specified software "database"\n'+
51
-
' + this Node.js process could not connect to the database, perhaps because of firewall/proxy settings\n'+
50
+
extendedDescription: 'This might mean any of the following:\n'+
51
+
' + the credentials encoded in the connection string are incorrect\n'+
52
+
' + there is no database server running at the provided host (i.e. even if it is just that the database process needs to be started)\n'+
53
+
' + there is no software "database" with the specified name running on the server\n'+
54
+
' + the provided connection string does not have necessary access rights for the specified software "database"\n'+
55
+
' + this Node.js process could not connect to the database, perhaps because of firewall/proxy settings\n'+
52
56
' + any other miscellaneous connection error',
53
57
outputVariableName: 'report',
54
58
outputDescription: 'The `error` property is a JavaScript Error instance explaining that a connection could not be made. The `meta` property is reserved for custom driver-specific extensions.',
@@ -61,9 +65,7 @@ module.exports = {
61
65
},
62
66
63
67
64
-
fn: function(inputs,exits){
65
-
varutil=require('util');
66
-
68
+
fn: functiongetConnection(inputs,exits){
67
69
// Note that if this driver is adapted to support managers which spawn
68
70
// ad-hoc connections or manage multiple pools/replicas using PoolCluster,
69
71
// then relevant settings would need to be included in the manager instance
0 commit comments