-
Notifications
You must be signed in to change notification settings - Fork 266
Conversation
Don't use gx for just _some_ of the IPFS imports
@ORBAT - I'm really sorry about the slow reply here. I completely missed the notification about this PR due to email config. Should be fixed now.
eep. good point. The main reason to pull out the IPFS code was to work around some dependency issues we have experienced with it (e.g., #3786). I'm not sure what the right solution to that is, but on future reflection, if people are going to be actively working with the IPFS support (e.g., you), then we might as well have the code in this tree for easier maintainability rather than separate. So I support moving this back in. That said, I don't think that it should use the 'external protocol' concept if it is linked into the binary. |
# the standard vet set is atomic,bool,buildtags,nilfunc,printf. printf causes a lot of spurious failures, so leave that | ||
# out | ||
test: | ||
$(GOTEST) -vet=atomic,bool,buildtags,nilfunc ./... |
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.
This is a good idea, thanks. Can you mention it in the README?
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.
Sure thing!
go/ipfs/options.go
Outdated
}) | ||
} | ||
|
||
// TODO: figure out less grody way of passing options to the external protocol. Maybe even extend Spec so that it supports |
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.
One way that we have done it in the past is put it in a config file (see go/config
), which works so long as you don't want to set them per-connection.
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.
At least personally I won't be needing per-connection settings, so the config file should work fine.
go/ipfs/options.go
Outdated
c := &config{maxConcurrent: 1} | ||
for _, opt := range opts { | ||
if err := opt.apply(c); err != nil { | ||
return nil, errors.Wrap(err, "error in configuration") |
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 agree that we should move to this. Our error handling has gotten messy and fragmented and now that there's a standard approach to what we were trying to do we should just do that.
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'll take a look at refactoring d/try.go
to use github.com/pkg/errors, it seems like it should be fairly painless. I'll plonk it in a separate PR once I get around to it.
return errors.Wrap(r.SetConfig(rc), "error setting IPFS repo config") | ||
} | ||
|
||
// An Option configures the IPFS ChunkStore |
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.
This is cool, I was not familiar with this pattern.
go/ipfs/options.go
Outdated
} | ||
|
||
// SetLocal makes the ChunkStore only use the local IPFS blockstore for both reads and writes. | ||
func SetLocal() Option { |
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.
Why the distinction between optFunc
and Option
? Why not just return optFunc
?
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.
Also, why not:
func SetLocal(c *config) error {
...
}
...rather than returning a new function?
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.
Option
should actually be refactored into type Option func(*config) error
as I didn't end up needing anything but plain 'ol functions for the options.
All the option-setting functions return Option
to have them all appear under the Option
type in the documentation; see e.g. zap's docs for an example
// | ||
// The external protocol is implemented by the Protocol type. | ||
func RegisterProtocols(opts ...Option) error { | ||
if err := register(NetworkProtoName, false, opts...); err != nil { |
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 don't think that there is any value to using external protocols system if the code is going to be linked into the binary anyway. Might as well just put it back as a peer to the other protocols.
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.
Yeah, started out with the protocol before realizing I have no way of sanely registering it from the noms
binary. Might as well yank it out.
Hi, thanks for the reply and the feedback; no worries about how long it took. I'll check the current IPFS dependencies and see if #3786 is still an issue. Getting rid of gx dependencies may or may not be an option, dunno yet. |
Hi @aboodman, I've got a couple of questions (with likely more incoming since I'm trying to learn the ropes of noms internals, so please bear with me.)
|
@ORBAT - I'm so sorry (again). I'm not sure why I keep missing these mails. If I'm unresponsive, can you please just ping the thread again. I'm trying to spend more time on Noms the last few weeks, and I'd love to have contributions. I think right now the traffic is just low enough that it's easy to miss in my inbox. You can also just shake my tree at any other channel (e.g., aboodman on Twitter). But hopefully now that I'm spending time on this again, it won't continue to happen. Regarding your questions:
Awesome.
It's hard to remember, and it's possible we didn't even explore the The Because of the magic of the IPFS network, with I don't think we ever really got the
The latter was the goal IIRC. Perhaps the special case in the put path is not necessary!
I actually came to the conclusion over time that the
No idea! Can you give me a pointer to the code in question?
I'm so sad I didn't catch this question faster. Cool to have someone digging in.
It's not the case that multiple databases can be backed by one ChunkStore. The difference between So when you write something to
Basically if you think of a stack of components, with your code at the top, and the OS at the bottom, Noms is in the middle. The
Think of like a webserver that is servicing requests. If this server caches a single database instance across all requests (which would be a reasonable thing to do) then the server would want to rebase the db before each request to ensure it is seeing the latest state of the world. The reason it is called === HTH, and hope you're still interested. |
Closing this for now since I've moved onto other projects |
This PR reintroduces the IPFS chunkstore. It also makes spec's external protocol registration thread-safe.
Commit 217ba38 by @aboodman stated that
but as it currently stands, cmd/noms can't interact with IPFS stores unless it's in the main noms repo.
Some notes regarding this PR:
d/try.go
after usinggithub.com/pkg/errors
. What might actually be worth while is refactoring try.go to use pkg/errors (see e.g. this blog post) as getting textual information about error context is extremely handyChunkStoreTestSuite
should probably be refactored so that it can be used for testing the IPFS chunkstore as well. I actually tried doing that (including adding aFactory
for the IPFS chunkstore) but tests kept freezing so I scrapped itSetPortIdx
option should probably be complemented with separate options for setting the API/gateway/swarm ports (although only the swarm port seemed to be open when eg. running ipfs-chat)