-
-
Notifications
You must be signed in to change notification settings - Fork 196
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
Feature: adds configurable query parameters to tile endpoints #867
Feature: adds configurable query parameters to tile endpoints #867
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.
I'm not seeing when we check to see if both caching and map params are enabled during config validation. I'll need to go through it again, but I'm worried that could lead to come confusion when trying to startup and have caching.
Were the caching check is happening right now, it ignores the caching if the map has any parameters, which is the correct behavior, but how does the user know that the cache does not contain that map?
I made a few code clean-up comments as well. I kind of want to get some of the simpler code cleanups into the main branch; that would make reviewing this easier as well, I think, as those things would not distract from the main part of the code.
Overall I think this will work; bit concerned about number generation for placeholders. Does this force anyone writing SQL to use $%d instead of '?'? What happens if one types a number that is generated in the SQL by mistake? Where would the failure point be? How, would the user know this? We need to be able to document this so that people can trouble shoot issues like this? Are we able to catch issues like this before hand?
@gdey, thank you so much for the review! I've tried to preserve the commits from the original feature author, as my impression was that they were already reviewed and approved. However, it might be easier if I redo the commit history and separate code cleanups from the actual feature code. What do you think? Regarding caching, will it be enough to log a warning? Or should we fail the config validation? We don't support per-map caching, so the best thing we can do without implementing it is to skip maps with configured parameters.
No, the numbered arguments are handled by the Tegola internals and are not exposed to the end user in any way. In maps' configuration, one uses only "tokens", like
If that's just a mistake, Tegola will probably catch it during startup while executing We definitely must ensure that the documentation clearly states that only |
cb3e35e
to
def63c4
Compare
I would say go ahead and rebase the code to separate out the clean-up from the actual feature code. This provides two benefits as I see it.
I feel we should fail on config validation. At least warn there that caching is being turned off due to maps with parameters. Just skipping a map with parameters seems like the worst of both worlds, because the user has to remember which maps have parameters and which don't. The PR is logging (with your review changes) when a map is not going to be cached at the time of tile buildup; this is going to inflate the logs (I believe) since this will have every time, an (uncached) tile is requested. Failing at config validation time, or logging at that time the maps that will not be included in the cache may be better. @dechristopher @mojodna @ARolek @ear7h opinions?
Okay, cool. Could not remember how we had implemented that.
I need to think about this.
👍 |
Pull Request Test Coverage Report for Build fe493a746-PR-867
💛 - Coveralls |
Just summarizing my thoughts and findings on the caching The problems
Possible solutions
Personally, I don't like №3 as the users don't have any saying in this; by adding this line, they just acknowledge the fact, so it's not a "configuration option". |
def63c4
to
ad9fa71
Compare
@gdey, I rewrote the commit history. It should be much easier to follow it commit by commit now, as there are less back and forth changes. |
6ffd38a
to
2f0f188
Compare
Thank you for the great summation!
Sounds like this would be true Per Atlas and not for the entirety of Tegola instance.
This seems to be the natural solution but will require documentation around people missing the warning on startup, and further clarification in the feature documentation.
|
@ARolek are we able to upgrade to go1.18, or do we still need to wait on that? |
Got an internal error when trying to build a lambda version of this branch. Has anyone else come across this issue? Oh yea to clarify, this is after building tegola_lambda and uploading it to my lambda function on AWS that typically works when building the main branch. When opening the /capabilities url I get an internal error. |
Thanks for giving it a try, @sjb-citian ! I haven't tested the lambda build. Are there any logs or a stacktrace so I could investigate? |
@bemyak I rebuilt it this morning using the command specified in the read.me of the cmd/lambda folder and reconfigured my endpoint on AWS and it worked! Likely a build error on my part or I configured the endpoint incorrectly, either this branch definitely works with lambda. |
@sjb-citian thanks for being diligent on this contribution, and again apologies for the slow response on my end. Regarding caching, I think we should go with:
This seems the most natural in my mind. If the user wants some caching, we can suggest they out a cache in front of tegola, like a CDN. Your breakdown of the complications with caching dynamic tiles is very correct. It opens up a whole new world of complexities that will likely need to be solved, but I think are beyond the scope of this initial enhancement. I think the cache detail is the only final outstanding detail. What I would like to do next is the following:
I'm excited to play with this feature. It has been long requested and again, I appreciate your diligence and patience. Your contribution is greatly appreciated! |
e693c24
to
60b3db9
Compare
8572cfb
to
713967e
Compare
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.
LGTM
@ARolek, can I do something else here? |
@bemyak nope! Action on me to get the release notes and documentation updates for the current version polished out. If you would like to help on that front I can push up a branch that you can help on. I'm mainly trying to cut over to using mvt_postgis in our readmes. |
@bemyak can you rebase this branch against |
fix: small typos and doc cleanup in provider/postgis feat: implemented Query Parameters into postgres provider feat: implemented default parameter values feat: revamp param specification in config
- Fixed test in case no env vars are defined - QueryParams inserted only once per token - Minor fixes
Warn about disabled caching
This is needed to access configured map parameters from the provider's initialization code to inspect geom type. Unfortunately, config pkg depends on the provider pkg, so simply referencing these types creates a dependency loop.
713967e
to
ebf58d2
Compare
@ARolek, done! I've just dropped two commits with the Go update and CI fix |
ebf58d2
to
1201df2
Compare
@bemyak alright, I just cut the v0.16.0 version of tegola. Going to run the CI on this PR and then I will merge it in. Thanks again for the commitment and patience on this PR. I would like to let this sit in pre-release state for a bit so we can let the community give it a try. |
PR now in master: https://github.com/go-spatial/tegola/commits/master. I'm going to open a discussion for anyone that needs help with the feature or has feedback. Onward! |
@bemyak when opening this discussion, I realized the configuration instructions for the feature are only in the PR. Could you send in some README documentation to help guide future users? |
This PR is a successor of #795.
The main differences/features are:
int
Go is updated to(dropped, as upstream already uses 1.19)1.18.3
A user can define custom parameters on per-map basis like this:
When a request is received, a value of
QueryParameterValue
is constructed to hold the resulting parameter query (still with?
) and a value (parsed to the proper type).Then
(params map[string]QueryParameterValue) ReplaceParams(sql string, args *[]interface{}) string
function can be called which replaces parameters with positional arguments (e.g.,$1
,$2
) and fills an array with their values. This should prevent SQL injections.