-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Think through the CoreAPI Path API and implementation. #4666
Comments
Note: this also looks like a nice place to plugin a real namespaced resolver system (yay). |
Related to: ipld/specs#3 |
Somewhat related #4643 (comment) I haven't touched paths in CoreAPI yet, I'll try to make a draft PR tomorrow, addressing these and some other points. |
Awesome! |
Response to TODOs in #4672 but contains a lot if discussion on future work so I figured I'd put it here. Namespaces
Getting this right is really important. I can see a few solutions but we need to discuss this thoroughly. CID NamespaceThat is, we could introduce a new Not sure if I'm a fan of this...
IPLD NamespaceAgain, given that we're not doing any path resolution, the namespace doesn't really matter (that much). IPLD is the most general purpose as all valid UnixFS objects are IPLD objects. This would mean that the namespace is only concerned with path resolution and shouldn't be used to interpret the target value.
Command ChoosesWe could make the default namespace an option to Alternatively, we could combine the IPLD namespace solution and this solution. If no default is passed, we default to IPLD. We could even make this option a function with the signature Personally, I'd vote for this option (with the fallback to IPLD) as it has all the advantages of the IPLD option but is slightly more flexible. Path RemaindersWe may just want to set a "resolved" bit somewhere and use that to determine if the path has been resolved. We also need to address ipld/specs#3 Mutable v. ImmutableWe may, eventually, have other mutable namespaces (maybe?). I'd like to just provide a method Resolution based on prefixI'd really just like a global path resolution registry that maps namespaces to resolvers. But yeah, this can come later. MFSIdeally, I'd like to introduce the concept of "mounting" all of our namespaces inside MFS (although I haven't thought through all of the ramifications). Then, we'd just hand the path off to MFS and let it do the lookup. Although, we could also just have MFS "mount" all namespaces (i.e., mount the resolver). (If I could break things, I would introduce So... Let the debate begin! |
Having the command choose is something that should work fine - we can still give the user an option to choose which resolver to use if we add another
Pros:
A con here is that paths can represent 2 different things depending on the resolver/command used.
(edit: cleaned up some wordings) |
Having two separate functions, one for IPFS and one for IPLD, both of them taking a path seems a bit odd. Won't the path have the namespace so shouldn't the choice be unambiguous at this point? Also, I'd like the resolver to be fully pluggable. Ideally, the top-level resolver wouldn't understand any of our pathing schemes, just the concept of pathing/namespaces (and maybe CIDs because they'll be baked into most of our pathing schemes).
I must be missing something here. We do not want to get rid of the
I agree that more namespaces isn't the way to go. I mentioned the
I don't consider any of the solutions I provided to be hacks (well, the
I'm not sure if I understand your point here. We plan on having a However, I guess I never really explained my concern with regard to IPNS... The issue with IPNS is that, given |
Oh, I meant The point
The current default is to use With the ability to publish
The only API returning
Well, IPNS can handle |
So... I omitted a ton of context in that proposal.
This becomes a problem with all the However, as the "IPLD namespace" proposal pointed out, we never have paths of the form
My concern, in this case, was that some error message might state Note: Simply choosing
All my comments about "doesn't handle IPNS" were referring to the fact that we can't determine id |
Currently you can't create a path without a prefix using CoreApi [1].
You can't pass unprefixed path to any coreapi function. When porting the commands to use coreapi, the default prefix will have to be attached in the command layer. If we enforce this, then the |
But you can call |
Yes, the current default is to parse this as a CID and prefix with |
To push this somewhere: This is how I see the
By explicitly disallowing unprefixed paths we don't have the ParsePath("QmId...") ambiguity. As this is an CoreAPI-only thing, we can still maintain current command behaviour quite easily. Problems: MFS is weird in this case. We can either - add But - what if we treated all unprefixed paths as MFS paths? In this case MFS would provide a resolver. We still can have Downsides:
|
I'm not really comfortable with this as it implies that IPFS is somehow the "correct" namespace. Maybe rename the function to
I'd almost just go with the "pass strings" option. For MFS, paths really are just strings. Internally, the files API would parse the string into a path and do any necessary resolution. Personally, I'd have liked to have had a separate |
So I did a bit of poking in #4672 locally. I think that I think I'll go with this and see how it turns out. Also, note that if we would want to use mfs as the global namespace, we should reserve |
coreapi.ParsePath
doesn't actually extract the root.The text was updated successfully, but these errors were encountered: