Fetch API: support redirection? #122
Replies: 3 comments 8 replies
-
Makes sense to me, and could be useful beyond federation like for package sharding or serving log data via CDN. Might be good to have a higher redirect limit if those are compelling use cases. |
Beta Was this translation helpful? Give feedback.
-
This is great. I have some open questions still around if/when content is mirrored along with logs.
Just to clarify, while the client gets logs from Maybe the following would be nice. While each registry has it's map for redirection, the client could have one too. When it downloads a package from a registry that informs the client to redirect, the client could ask the user if they would like to update their config to match the redirection currently being recommended. Users could then easily see what redirection it's been informed to make historically, avoid redundant calls to ask about redirection, and also see which registries have historically made recommendations to the client that it it has already incorporated into its config, along with the query that motivated the current local client config. |
Beta Was this translation helpful? Give feedback.
-
I think that we're getting to a point where more clarity around how content location is communicated to the client could be very helpful, (at least for me). I guess right now, there is no information in logs about urls used for fetching content, and then there is also the whole question about auth and restricted access. I guess if you start with thinking about the simple case where we're only talking about public packages, and content download urls are in the logs, then does redirection need to happen? Essentially, if I understand correctly, I also think we've discussed mirroring being a mechanism for registries with more robust cloud resources to absorb some of the traffic for a registry with public packages that can't handle the demands its userbase. Maybe if registries tell clients how to fetch content without them needing to talk to the registry that is being mirrored, it could help with this goal as well? I still very much like the idea of being able to ask registries how they're mapping namespaces to mirrored registries, and am trying to avoid changing the subject to content storage implementation details, but I think the topics are a bit related, and don't quite know how to separate them. If we want I could create another discussion for this topic? |
Beta Was this translation helpful? Give feedback.
-
We've talked about mirroring (i.e. replicating) package logs from other registries, whereby the registry will keep a copy of a log streamed from upstream registries so it can directly serve the log to its clients.
For example, the
wasi:http
package originates from theregistry.wasi.dev
registry and theregistry.neato.burrito
registry is configured to mirror it by streaming events fromregistry.wasi.dev
. With that, a client can fetch the log forwasi:http
directly fromregistry.neato.burrito
without taking toregistry.wasi.dev
.In addition to mirroring, I think we should consider supporting redirection in the API. That is to say, a registry should be able to answer with "well, I can't serve you
wasi:http
directly, but you can find it over atregistry.wasi.dev
".Having this would enable pretty cheap federation of registries even before we've designed a proper streaming API for replication. For example, I could configure my registry to redirect anything with a
wasi
namespace toregistry.wasi.dev
without much fuss. Clients that are configured to source packages solely from my registry now have access to WASI packages as well.Right now the fetch API takes a batched set of packages to fetch and therefore an individual 3XX response can't be used.
To support this, perhaps we would need the fetch response to include a map of log ids to their redirected locations; the client would then turn around and delegate the relevant part of the fetch operation to those locations (this might require some finagling in the client storage implementation to ensure the per-registry storage works as intended).
Clients could be configured with a maximum redirection count and probably use a default of 1 with the expectation that a registry answers with the original location of the package.
What are folks thoughts on this?
Beta Was this translation helpful? Give feedback.
All reactions