Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 52fbf2e1
authored
May 16, 2013
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Plain Diff
Merge package.json
2 parents
c9f6924b
b348b17c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
7 deletions
lib/dialects/mysql/connector-manager.js
lib/emitters/custom-event-emitter.js
package.json
lib/dialects/mysql/connector-manager.js
View file @
52fbf2e
...
...
@@ -19,7 +19,9 @@ module.exports = (function() {
this
.
poolCfg
=
Utils
.
_
.
defaults
(
this
.
config
.
pool
,
{
maxConnections
:
10
,
minConnections
:
0
,
maxIdleTime
:
1000
maxIdleTime
:
1000
,
handleDisconnects
:
false
,
validate
:
validateConnection
});
this
.
pendingQueries
=
0
;
this
.
useReplicaton
=
!!
config
.
replication
;
...
...
@@ -83,6 +85,7 @@ module.exports = (function() {
destroy
:
function
(
client
)
{
disconnect
.
call
(
self
,
client
)
},
validate
:
self
.
poolCfg
.
validate
,
max
:
self
.
poolCfg
.
maxConnections
,
min
:
self
.
poolCfg
.
minConnections
,
idleTimeoutMillis
:
self
.
poolCfg
.
maxIdleTime
...
...
@@ -98,6 +101,7 @@ module.exports = (function() {
destroy
:
function
(
client
)
{
disconnect
.
call
(
self
,
client
)
},
validate
:
self
.
poolCfg
.
validate
,
max
:
self
.
poolCfg
.
maxConnections
,
min
:
self
.
poolCfg
.
minConnections
,
idleTimeoutMillis
:
self
.
poolCfg
.
maxIdleTime
...
...
@@ -115,6 +119,7 @@ module.exports = (function() {
},
max
:
self
.
poolCfg
.
maxConnections
,
min
:
self
.
poolCfg
.
minConnections
,
validate
:
self
.
poolCfg
.
validate
,
idleTimeoutMillis
:
self
.
poolCfg
.
maxIdleTime
})
}
...
...
@@ -247,10 +252,25 @@ module.exports = (function() {
connection
.
query
(
"SET time_zone = '+0:00'"
);
// client.setMaxListeners(self.maxConcurrentQueries)
this
.
isConnecting
=
false
if
(
config
.
pool
.
handleDisconnects
)
{
handleDisconnect
(
this
.
pool
,
connection
)
}
done
(
null
,
connection
)
}
var
handleDisconnect
=
function
(
pool
,
client
)
{
client
.
on
(
'error'
,
function
(
err
)
{
if
(
err
.
code
!==
'PROTOCOL_CONNECTION_LOST'
)
{
throw
err
}
pool
.
destroy
(
client
)
})
}
var
validateConnection
=
function
(
client
)
{
return
client
&&
client
.
state
!=
'disconnected'
}
var
enqueue
=
function
(
queueItem
,
options
)
{
options
=
options
||
{}
if
(
this
.
activeQueue
.
length
<
this
.
maxConcurrentQueries
)
{
...
...
lib/emitters/custom-event-emitter.js
View file @
52fbf2e
...
...
@@ -2,9 +2,20 @@ var util = require("util")
,
EventEmitter
=
require
(
"events"
).
EventEmitter
,
proxyEventKeys
=
[
'success'
,
'error'
,
'sql'
]
var
bindToProcess
=
function
(
fct
)
{
if
(
fct
)
{
if
(
process
.
domain
)
{
return
process
.
domain
.
bind
(
fct
);
}
}
return
fct
;
};
module
.
exports
=
(
function
()
{
var
CustomEventEmitter
=
function
(
fct
)
{
this
.
fct
=
fct
this
.
fct
=
bindToProcess
(
fct
);
}
util
.
inherits
(
CustomEventEmitter
,
EventEmitter
)
...
...
@@ -21,7 +32,7 @@ module.exports = (function() {
CustomEventEmitter
.
prototype
.
success
=
CustomEventEmitter
.
prototype
.
ok
=
function
(
fct
)
{
this
.
on
(
'success'
,
fct
)
this
.
on
(
'success'
,
bindToProcess
(
fct
)
)
return
this
}
...
...
@@ -29,13 +40,14 @@ module.exports = (function() {
CustomEventEmitter
.
prototype
.
fail
=
CustomEventEmitter
.
prototype
.
error
=
function
(
fct
)
{
this
.
on
(
'error'
,
fct
)
this
.
on
(
'error'
,
bindToProcess
(
fct
)
)
return
this
;
}
CustomEventEmitter
.
prototype
.
done
=
CustomEventEmitter
.
prototype
.
complete
=
function
(
fct
)
{
fct
=
bindToProcess
(
fct
);
this
.
on
(
'error'
,
function
(
err
)
{
fct
(
err
,
null
)
})
.
on
(
'success'
,
function
(
result
)
{
fct
(
null
,
result
)
})
return
this
...
...
@@ -52,3 +64,4 @@ module.exports = (function() {
return
CustomEventEmitter
;
})()
package.json
View file @
52fbf2e
...
...
@@ -35,9 +35,10 @@
"validator"
:
"1.1.1"
,
"moment"
:
"~1.7.0"
,
"commander"
:
"~0.6.0"
,
"generic-pool"
:
"1.0.9"
,
"dottie"
:
"0.0.6-1"
,
"toposort-class"
:
"0.1.4"
"toposort-class"
:
"0.1.4"
,
"generic-pool"
:
"2.0.3"
,
"dottie"
:
"0.0.6-1"
},
"devDependencies"
:
{
"jasmine-node"
:
"1.5.0"
,
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment