-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pg-mvt: Implement timeout in getTile #661
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice use of Promise.race
!. Which is, the only use case that I know for that method.
I left some comments, mostly about moving the code and renaming methods.
As a general advice: try to use camelCase
for naming variables.
// Init DB and get layer column names. | ||
initDB (callback) { | ||
try { | ||
this.psql = new PSQL(this.dbParams, this.dbPoolParams); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move the creation of the connection to the constructor and rename this function (e.g: getAllLayerColumns
)
debug("Error running pg-mvt query " + query + ": " + err); | ||
if (err.message) { | ||
err.message = "PgMvtRenderer: " + err.message; | ||
const pr_getTile = new Promise((resolve, reject) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about extracting this promise to a new method of the class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my initial idea, then I saw that I needed the query string to be able to cancel and decide to merge it all together, but as I can see now I can have a function generating the promise that receives the query as a parameter.
/// @param z tile zoom | ||
/// callback: will be called when done using nodejs protocol (err, data) | ||
getTile (z, x, y, callback) { | ||
return this._getTileTimeout(z, x, y, this.render_limit, callback); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not move the content of_getTileTimeout
to getTile
?
I'll review it. I think it comes from switching languages and styles between projects 😅 |
Comments addressed. I had to add an extra commit to test this locally (Postgis 3.0). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
💪
this.psql = new PSQL(this.dbParams, this.dbPoolParams); | ||
} | ||
|
||
// Init DB and get layer column names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Careful! Update the comment!
Since you need to open a new connection to close a running query I had to move the connection parameters to the renderer, so I decided to move
getLayerColumns
too and add ainitDB
function to avoid handling promises in the constructor.To get the limits inside this renderer I've modified the factory to add
mapnik.mapnik.limits
tomvt
, which is not pretty but needed for compatibility.Closes #577
Closes #624