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 ad7c3f08
authored
May 01, 2012
by
sdepold
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/megshark/sequelize
into mysql-pooling
2 parents
35068ffb
9f8900f5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
9 deletions
lib/dialects/mysql/connector-manager.js
spec-jasmine/config/config.js
lib/dialects/mysql/connector-manager.js
View file @
ad7c3f0
...
...
@@ -13,24 +13,34 @@ module.exports = (function() {
this
.
activeQueue
=
[]
this
.
maxConcurrentQueries
=
(
this
.
config
.
maxConcurrentQueries
||
50
)
this
.
poolCfg
=
this
.
config
.
pool
var
self
=
this
if
(
this
.
poolCfg
)
{
//the user has requested pooling, so create our connection pool
if
(
!
this
.
poolCfg
.
maxConnections
)
{
this
.
poolCfg
.
maxConnections
=
10
}
var
self
=
this
this
.
pool
=
Pooling
.
Pool
({
name
:
'sequelize-mysql'
,
create
:
function
(
done
)
{
connect
(
self
,
done
)
connect
.
call
(
self
,
done
)
},
destroy
:
function
(
client
)
{
disconnect
(
null
,
client
)
disconnect
.
call
(
self
,
client
)
},
max
:
self
.
poolCfg
.
maxConnections
,
idleTimeoutMillis
:
self
.
poolCfg
.
maxIdleTime
})
}
process
.
on
(
'exit'
,
function
()
{
//be nice & close our connections on exit
if
(
self
.
pool
)
{
self
.
pool
.
drain
()
}
else
if
(
self
.
client
)
{
disconnect
(
self
.
client
)
}
return
})
}
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
)
...
...
@@ -56,7 +66,7 @@ module.exports = (function() {
if
(
this
.
isConnecting
||
this
.
pool
)
{
return
}
connect
(
self
,
function
(
err
,
client
)
{
connect
.
call
(
self
,
function
(
err
,
client
)
{
self
.
client
=
client
return
})
...
...
@@ -65,12 +75,15 @@ module.exports = (function() {
ConnectorManager
.
prototype
.
disconnect
=
function
()
{
if
(
this
.
client
)
disconnect
(
this
,
this
.
client
)
disconnect
.
call
(
this
,
this
.
client
)
return
}
// private
var
disconnect
=
function
(
self
,
client
)
{
var
disconnect
=
function
(
client
)
{
var
self
=
this
client
.
end
(
function
()
{
var
intervalObj
=
null
var
cleanup
=
function
()
{
...
...
@@ -92,7 +105,8 @@ module.exports = (function() {
})
}
var
connect
=
function
(
self
,
done
)
{
var
connect
=
function
(
done
)
{
var
self
=
this
var
client
=
require
(
"mysql"
).
createClient
({
user
:
self
.
config
.
username
,
password
:
self
.
config
.
password
,
...
...
@@ -171,7 +185,7 @@ module.exports = (function() {
}
ConnectorManager
.
prototype
.
__defineGetter__
(
'hasNoConnections'
,
function
()
{
return
(
this
.
queue
.
length
==
0
)
&&
(
this
.
activeQueue
.
length
==
0
)
&&
this
.
client
.
_queue
&&
(
this
.
client
.
_queue
.
length
==
0
)
return
(
this
.
queue
.
length
==
0
)
&&
(
this
.
activeQueue
.
length
==
0
)
&&
(
this
.
client
==
null
||
(
this
.
client
.
_queue
&&
(
this
.
client
.
_queue
.
length
==
0
))
)
})
ConnectorManager
.
prototype
.
__defineGetter__
(
'isConnected'
,
function
()
{
...
...
@@ -189,3 +203,5 @@ module.exports = (function() {
return
ConnectorManager
})()
spec-jasmine/config/config.js
View file @
ad7c3f0
...
...
@@ -3,13 +3,14 @@ module.exports = {
return
parseInt
(
Math
.
random
()
*
999
)
},
//make maxIdleTime small so that tests exit promptly
mysql
:
{
username
:
"root"
,
password
:
null
,
database
:
'sequelize_test'
,
host
:
'127.0.0.1'
,
port
:
3306
,
pool
:
{
maxConnections
:
5
,
maxIdleTime
:
30
000
}
pool
:
{
maxConnections
:
5
,
maxIdleTime
:
30
}
},
sqlite
:
{
...
...
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