-
Notifications
You must be signed in to change notification settings - Fork 108
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
Promisify tilelive and add extra context #189
Comments
I have implemented a library, tests and all, to dynamically supply the |
👎 on Promises (at least until 👍 on options. +0 on batching, since it already exists in a couple of different forms. Can you elaborate on the quad-based index idea? I've implemented one mode of of batching w/ tilelive-streaming ( One longstanding (slightly voiced) request I have is for |
@rclark -- you would probably be the best person to weigh in here? |
@mojodna, thanks for the response!
|
Allows arbitrary parameters for the tilelive's getTile/Grid/Info interface As discussed in mapbox/tilelive#189
@mojodna the above PR implements my proposal for the |
Allows arbitrary parameters for the tilelive's getTile/Grid/Info interface As discussed in mapbox/tilelive#189
Overall I'm pretty enthusiastic about attempts to refresh the tilelive API contract, though ideally in ways that avoid any breaking API changes. This could include:
... but we should avoid changing the function signature to accept like a quadkey or something other than |
@rclark, the additional |
If you'd prefer to keep these functionalities contained within the tilelive-promise module, then should we close the ticket here? |
@rclark we could move that functionality into tilelive itself - this way the tilelive.load would automatically bring the interface to the common denominator, without any custom logic inside each module. |
Ok, if we're going to talk about bringing this functionality into tilelive itself, a couple of points to consider:
These changes would adjust the existing API interface, but could be handled in a non-breaking fashion. For the options object, it would still have to be up to the implementation (eg. tilelive-vector) to support it. |
|
No -- let's split this out/defer this discussion to some occasion where this concretely matters. @nyurik can you focus this discussion on adding a backwards-compatible Promise interface? |
@yhahn at a bare minimum, we should add two features at once - to avoid introducing two new interfaces that will both need to be supported: Promisification, and extra parameter passing. As discussed with @rclark, changing the existing @rclark had a valid objection that removing To sum up, how about |
Could we take this approach but flag this as a potentially breaking change by doing a semver major version bump? That way developers doing the major version bump will probably have a painless upgrade experience unless they have come to expect an |
I think this is not very good - the whole idea behind tilelive is "plug and play" components. You are basically saying that every single implementation of tilelive api must be verified to be handling the return correctly before you can use it, whereas with my proposal, all existing code will work without a single change to any of the components. I am already using it in Kartotherian with the injection lib, and the only time I need to modify existing code is when I want to change its behavior. |
As a developer that uses tilelive in production, I don't see any obvious benefits using a promisify interface instead of callback. Async/await is promising but far from mature for production usage, especially for modules that rely on native c++ addons such as node-mapnik which only provide precompiled binary up to node 6, and node-mapbox-gl-native sticks to node 4. Promise also provides unnecessary abstraction that may decrease performance,while performance matters as tilelive mostly is used on the backend services. If you likes promise, as @mojodna said, there are too many libraries which can help you promisify any callbacks.
Tilelive is a kind of contract or protocol, so please keep it stable and simple. Please do not introduce any incompatible changes unless we have concrete reasons that we must change it. |
Yeah, this is a bummer, and this is one reason why I think that the best approach is the one you've already implemented: https://github.com/kartotherian/tilelive-promise -- a helper library that can wrap tilelive modules and expose the functionality that you want to have, but that might not be important to others.
I'm very much in agreement with this statement. Though I've always been bothered by the way this contract is not actually enforced on tilelive-* modules. Figuring out ways to move away from the implicit contract is a direction that I'd love to explore elsewhere. As it stands now, I'm hesitant to add JS logic to tilelive.js that would wrap module functions like getTile, etc. Tilelive.js as it stands now is about defining this implicit contract, and about assistance loading modules. The present exception to that statement are the streaming functions, which honestly I would like to see move out of tilelive.js into an independent module. |
@rclark I so wish we can separate these two. API and dependency container are really two separate. unrelated things. And yes, stream functionality might not belong there either... There is one fundamental problem that I cannot work around with the current code. Given an API implementation, like My |
tilelive is fundamentally a URI-based dependency container service, allowing separation between service implementation/instantiation and service consumption. Moving away from the rigid
getTile(z,x,y)
API would allow more diverse context parameters and non-tile services.For example,
getTile(z, x, y, callback(err, data, headers))
would be something likePromise<{data, headers}> getAsync({zoom: z, index: ind, extra1: ...})
For compatibility, tilelive should inject a rudimentary
getAsync()
(See injection lib), that only supports the basic {tile|grid|info} modes into the legacy tilelive sources. The auto-injectedgetAsync()
would not support any of the magical customizations, such as parameters set on callback function. For that, the source would have to implement its own version of getAsync, e.g. tilelive-vector PR.Immediate benefits of adding a single
getAsync()
function:language
,licence
, ...The text was updated successfully, but these errors were encountered: