-
-
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
[WIP] New node constructor #6387
Conversation
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
I wouldn't bother. If it's easy, it's easy for users to migrate. We can also migrate ipget as an example.
👍 |
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
Status update: This is ready for a review, and should be possible to merge in less than a week.
@Stebalien would be great if you could have a look at at least |
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
@magik6k can you either squash it or (more work) make commits correspond to logical units of work. This is a big change so reviewing it will be difficult. |
Many commits touch things in multiple places, and bulk of changes has happened in a few big commits. I'd go about reviewing file by file (and leave commits unsquashed as it might be helpful when debugging regressions if one happens) Summary of changes:
I'd probably start the review from |
@magik6k from what I can see, most of those commits don't build or fail tests so they are useless for finding regressions (bisect won't work and walking them one by one probably won't work either). |
In most of these commits most tests pass, and given that when using bisect you usually don't run the whole test suite - you just test the affected thing, this shouldn't affect bisecting much. If you can't run bisect on some commit because it's between some breaking change, and relevant update, you just call Having this squashed to 3-5 commits that pass tests, doing git bisect would get you one huge commit which wouldn't narrow the scope of what could be broken much. |
I wish there were a better way to override/provide defaults but I can't think of anything better. My best "pure fx" solution is to use named provides but I can't think of a way to do this without a bunch of boilerplate. package main
import (
"context"
"fmt"
"go.uber.org/fx"
)
type foo string
type bar string
// Override overrides the named option.
func Override(thing interface{}) fx.Option {
return fx.Provide(fx.Annotated{
Name: "override",
Target: thing,
})
}
// DefaultFoobar provides a default foobar unless an override has been
// specified.
func DefaultFoobar(s struct {
fx.In
Foo foo `name:"override" optional:"true"`
Bar bar `name:"override" optional:"true"`
}) (foo, bar) {
if s.Foo == "" {
s.Foo = "default foo"
}
if s.Bar == "" {
s.Bar = "default bar"
}
return s.Foo, s.Bar
}
func main() {
app := fx.New(
Override(func() foo { return "explicit foo" }),
//Override(func() bar { return "explicit bar" }),
fx.Provide(DefaultFoobar),
fx.Invoke(func(foo foo, bar bar) {
fmt.Println(foo)
fmt.Println(bar)
}),
)
if err := app.Start(context.Background()); err != nil {
panic(err)
}
} I wonder how well this will integrate with libp2p once we switch that over to something like fx? I'd like to share the same fx instance. |
Possibly relevant: uber-go/fx#653 |
We should probably start experimenting with libp2p a bit before we continue. |
Putting this here for visibility, there is still some fixing and cleanups needed.
Feel free to have a look at the code, but don't bother to review fully yet (there are some questions in TODOs that may need decisions).
Notes:
cmd/ipfs
package done.core/coreapi/node.go
coreapi
package because of some circular import problems, there are few potential solutions I didn't try yet.Questions:
IpfsNode
struct in favour of something else, like just the DI container?