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 59fa81f8
authored
Oct 24, 2012
by
Mick Hansen
Committed by
Jan Aagaard Meier
Oct 31, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
provide option (not exposed currently) to turn off mysql query queuing
1 parent
60fe7eaf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
20 deletions
lib/dialects/mysql/connector-manager.js
lib/dialects/mysql/connector-manager.js
View file @
59fa81f
...
@@ -14,6 +14,8 @@ module.exports = (function() {
...
@@ -14,6 +14,8 @@ module.exports = (function() {
this
.
activeQueue
=
[]
this
.
activeQueue
=
[]
this
.
maxConcurrentQueries
=
(
this
.
config
.
maxConcurrentQueries
||
50
)
this
.
maxConcurrentQueries
=
(
this
.
config
.
maxConcurrentQueries
||
50
)
this
.
poolCfg
=
this
.
config
.
pool
this
.
poolCfg
=
this
.
config
.
pool
this
.
pendingQueries
=
0
;
this
.
useQueue
=
false
;
var
self
=
this
var
self
=
this
...
@@ -47,41 +49,69 @@ module.exports = (function() {
...
@@ -47,41 +49,69 @@ module.exports = (function() {
})
})
}
}
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
)
Utils
.
_
.
extend
(
ConnectorManager
.
prototype
,
require
(
"../connector-manager"
).
prototype
)
;
var
isConnecting
=
false
var
isConnecting
=
false
;
ConnectorManager
.
prototype
.
query
=
function
(
sql
,
callee
,
options
)
{
ConnectorManager
.
prototype
.
query
=
function
(
sql
,
callee
,
options
)
{
if
(
!
this
.
isConnected
&&
!
this
.
pool
)
this
.
connect
()
if
(
!
this
.
isConnected
&&
!
this
.
pool
)
this
.
connect
();
var
queueItem
=
{
if
(
this
.
useQueue
)
{
query
:
new
Query
(
this
.
client
,
this
.
sequelize
,
callee
,
options
||
{}),
var
queueItem
=
{
sql
:
sql
query
:
new
Query
(
this
.
client
,
this
.
sequelize
,
callee
,
options
||
{}),
sql
:
sql
};
enqueue
.
call
(
this
,
queueItem
);
return
queueItem
.
query
;
}
}
enqueue
.
call
(
this
,
queueItem
)
var
self
=
this
,
query
=
new
Query
(
this
.
client
,
this
.
sequelize
,
callee
,
options
||
{});
this
.
pendingQueries
++
;
query
.
done
(
function
()
{
self
.
pendingQueries
--
;
if
(
self
.
pool
)
self
.
pool
.
release
(
query
.
client
);
else
{
if
(
self
.
pendingQueries
===
0
)
{
setTimeout
(
function
()
{
self
.
pendingQueries
===
0
&&
self
.
disconnect
.
call
(
self
);
},
1
);
}
}
});
return
queueItem
.
query
if
(
!
this
.
pool
)
query
.
run
(
sql
);
}
else
{
this
.
pool
.
acquire
(
function
(
err
,
client
)
{
if
(
err
)
return
query
.
emit
(
'error'
,
err
);
query
.
client
=
client
;
query
.
run
(
sql
);
return
;
});
}
return
query
;
};
ConnectorManager
.
prototype
.
connect
=
function
()
{
ConnectorManager
.
prototype
.
connect
=
function
()
{
var
self
=
this
var
self
=
this
;
// in case database is slow to connect, prevent orphaning the client
// in case database is slow to connect, prevent orphaning the client
if
(
this
.
isConnecting
||
this
.
pool
)
{
if
(
this
.
isConnecting
||
this
.
pool
)
{
return
return
;
}
}
connect
.
call
(
self
,
function
(
err
,
client
)
{
connect
.
call
(
self
,
function
(
err
,
client
)
{
self
.
client
=
client
self
.
client
=
client
;
return
return
;
})
})
;
return
return
;
}
}
;
ConnectorManager
.
prototype
.
disconnect
=
function
()
{
ConnectorManager
.
prototype
.
disconnect
=
function
()
{
if
(
this
.
client
)
if
(
this
.
client
)
disconnect
.
call
(
this
,
this
.
client
);
disconnect
.
call
(
this
,
this
.
client
)
return
;
return
};
}
// private
// private
...
...
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