-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added optional pool prioritization functionality. * Fixed bug in heal process that was preventing heal failures from being detected properly in some cases.
- Loading branch information
1 parent
db6b05a
commit 03381f9
Showing
6 changed files
with
469 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export default function poolPrioritySort(a, b) { | ||
if (a.connection.connected && !b.connection.connected) { | ||
return -1; | ||
} | ||
if (!a.connection.connected && b.connection.connected) { | ||
return 1; | ||
} | ||
if (!a.connection.connected && !b.connection.connected) { | ||
return 0; | ||
} | ||
// if both pools are connected, then we sort by priority | ||
return a.dsn.priority - b.dsn.priority; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// The serialWarmupStrategy attempts to create connection pools in series, based | ||
// on the order of the dsns provided. | ||
// This isn't a very good strategy to use in practice, but it can be useful for testing | ||
export default function serialWarmupStrategy(dsns, connectionPoolFactory, onCreation, onError) { | ||
return dsns.reduce((p, dsn) => p.then( | ||
() => connectionPoolFactory(dsn).then( | ||
pool => onCreation(pool), | ||
err => onError(err), | ||
), | ||
), Promise.resolve()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export default function delay(ms) { | ||
return () => new Promise((resolve) => { setTimeout(resolve, ms); }); | ||
// In the event that we use jest.useFakeTimers, it is useful to optionally | ||
// accept a specific implementation of setTimeout. | ||
export default function delay(ms, setTimeoutToUse = setTimeout) { | ||
return () => new Promise((resolve) => { setTimeoutToUse(resolve, ms); }); | ||
} |
Oops, something went wrong.