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
不要怂,就是干,撸起袖子干!
You need to sign in or sign up before continuing.
Commit ea4fa212
authored
May 06, 2014
by
Jan Aagaard Meier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change pg connector manager to use promises correctly
1 parent
f2d62129
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
24 deletions
.travis.yml
lib/dialects/postgres/connector-manager.js
.travis.yml
View file @
ea4fa21
...
@@ -37,9 +37,9 @@ matrix:
...
@@ -37,9 +37,9 @@ matrix:
fast_finish
:
true
fast_finish
:
true
include
:
include
:
-
node_js
:
"
0.1
2
"
-
node_js
:
"
0.1
1
"
env
:
DB=mysql DIALECT=mysql
env
:
DB=mysql DIALECT=mysql
allow_failures
:
allow_failures
:
-
node_js
:
"
0.1
2
"
-
node_js
:
"
0.1
1
"
env
:
DB=mysql DIALECT=mysql
env
:
DB=mysql DIALECT=mysql
\ No newline at end of file
lib/dialects/postgres/connector-manager.js
View file @
ea4fa21
...
@@ -64,13 +64,12 @@ module.exports = (function() {
...
@@ -64,13 +64,12 @@ module.exports = (function() {
ConnectorManager
.
prototype
.
connect
=
function
(
callback
)
{
ConnectorManager
.
prototype
.
connect
=
function
(
callback
)
{
var
self
=
this
var
self
=
this
var
emitter
=
new
Utils
.
Promise
();
return
new
Utils
.
Promise
(
function
(
resolve
,
reject
)
{
// in case database is slow to connect, prevent orphaning the client
// in case database is slow to connect, prevent orphaning the client
// TODO: We really need some sort of queue/flush/drain mechanism
// TODO: We really need some sort of queue/flush/drain mechanism
if
(
this
.
isConnecting
&&
!
this
.
pooling
&&
this
.
client
===
null
)
{
if
(
this
.
isConnecting
&&
!
this
.
pooling
&&
this
.
client
===
null
)
{
emitter
.
emit
(
'success'
,
null
)
return
resolve
()
return
emitter
}
}
this
.
isConnecting
=
true
this
.
isConnecting
=
true
...
@@ -86,8 +85,13 @@ module.exports = (function() {
...
@@ -86,8 +85,13 @@ module.exports = (function() {
config
.
reapIntervalMillis
=
this
.
config
.
pool
.
reapInterval
||
1000
config
.
reapIntervalMillis
=
this
.
config
.
pool
.
reapInterval
||
1000
config
.
uuid
=
this
.
config
.
uuid
config
.
uuid
=
this
.
config
.
uuid
}
}
var
connectCallback
=
function
(
err
,
client
,
done
)
{
var
connectCallback
=
function
(
err
,
client
,
done
)
{
var
timezoneCallback
=
function
()
{
self
.
isConnected
=
true
self
.
client
=
client
resolve
(
done
)
}
self
.
isConnecting
=
false
self
.
isConnecting
=
false
if
(
!!
err
)
{
if
(
!!
err
)
{
...
@@ -98,41 +102,36 @@ module.exports = (function() {
...
@@ -98,41 +102,36 @@ module.exports = (function() {
if
(
err
.
code
)
{
if
(
err
.
code
)
{
switch
(
err
.
code
)
{
switch
(
err
.
code
)
{
case
'ECONNREFUSED'
:
case
'ECONNREFUSED'
:
emitter
.
emit
(
'error'
,
new
Error
(
"Failed to authenticate for PostgresSQL. Please double check your settings."
))
reject
(
new
Error
(
"Failed to authenticate for PostgresSQL. Please double check your settings."
))
break
break
case
'ENOTFOUND'
:
case
'ENOTFOUND'
:
case
'EHOSTUNREACH'
:
case
'EHOSTUNREACH'
:
case
'EINVAL'
:
case
'EINVAL'
:
emitter
.
emit
(
'error'
,
new
Error
(
"Failed to find PostgresSQL server. Please double check your settings."
))
reject
(
new
Error
(
"Failed to find PostgresSQL server. Please double check your settings."
))
break
break
default
:
default
:
emitter
.
emit
(
'error'
,
err
)
reject
(
err
)
break
break
}
}
}
else
{
}
else
{
emitter
.
emit
(
'error'
,
new
Error
(
err
.
message
))
reject
(
new
Error
(
err
.
message
))
}
}
}
else
if
(
client
)
{
}
else
if
(
client
)
{
var
timezoneCallback
=
function
()
{
self
.
isConnected
=
true
self
.
client
=
client
emitter
.
emit
(
'success'
,
done
)
}
if
(
self
.
config
.
keepDefaultTimezone
)
{
if
(
self
.
config
.
keepDefaultTimezone
)
{
Utils
.
tick
(
timezoneCallback
)
timezoneCallback
(
)
}
else
{
}
else
{
self
.
setTimezone
(
client
,
'UTC'
,
timezoneCallback
)
self
.
setTimezone
(
client
,
'UTC'
,
timezoneCallback
)
}
}
}
else
if
(
self
.
config
.
native
)
{
}
else
if
(
self
.
config
.
native
)
{
self
.
setTimezone
(
self
.
client
,
'UTC'
,
function
()
{
if
(
self
.
config
.
keepDefaultTimezone
)
{
self
.
isConnected
=
true
timezoneCallback
()
emitter
.
emit
(
'success'
,
done
)
}
else
{
})
self
.
setTimezone
(
self
.
client
,
'UTC'
,
timezoneCallback
)
}
}
else
{
}
else
{
done
&&
done
()
done
&&
done
()
self
.
client
=
null
self
.
client
=
null
emitter
.
emit
(
'success'
)
resolve
(
)
}
}
}
}
...
@@ -167,8 +166,7 @@ module.exports = (function() {
...
@@ -167,8 +166,7 @@ module.exports = (function() {
})
})
}
}
}
}
}.
bind
(
this
))
return
emitter
}
}
ConnectorManager
.
prototype
.
setTimezone
=
function
(
client
,
timezone
,
callback
)
{
ConnectorManager
.
prototype
.
setTimezone
=
function
(
client
,
timezone
,
callback
)
{
...
...
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