Skip to content
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

Merged
merged 14 commits into from
Sep 14, 2018

Conversation

Algunenano
Copy link
Contributor

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 a initDB 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 to mvt, which is not pretty but needed for compatibility.

Closes #577
Closes #624

@dgaubert dgaubert self-assigned this Sep 14, 2018
Copy link
Contributor

@dgaubert dgaubert left a 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);
Copy link
Contributor

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) => {
Copy link
Contributor

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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?

@dgaubert dgaubert removed their assignment Sep 14, 2018
@Algunenano
Copy link
Contributor Author

As a general advice: try to use camelCase for naming variables.

I'll review it. I think it comes from switching languages and styles between projects 😅

@Algunenano
Copy link
Contributor Author

Comments addressed. I had to add an extra commit to test this locally (Postgis 3.0).

Copy link
Contributor

@dgaubert dgaubert left a 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Careful! Update the comment!

@Algunenano Algunenano merged commit 58e8770 into CartoDB:master Sep 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement timeout for MVT PostGIS renderer Innefective vars in ST_AsMVT queries
2 participants