Skip to content
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

core/node: add configuration options for Bitswap via fx #9258

Merged
merged 2 commits into from
Sep 19, 2022

Conversation

mrd0ll4r
Copy link
Contributor

@mrd0ll4r mrd0ll4r commented Sep 9, 2022

Fixes #9256

@welcome
Copy link

welcome bot commented Sep 9, 2022

Thank you for submitting this PR!
A maintainer will be here shortly to review it.
We are super grateful, but we are also overloaded! Help us by making sure that:

  • The context for this PR is clear, with relevant discussion, decisions
    and stakeholders linked/mentioned.

  • Your contribution itself is clear (code comments, self-review for the
    rest) and in its best form. Follow the code contribution
    guidelines

    if they apply.

Getting other community members to do a review would be great help too on complex PRs (you can ask in the chats/forums). If you are unsure about something, just leave us a comment.
Next steps:

  • A maintainer will triage and assign priority to this PR, commenting on
    any missing things and potentially assigning a reviewer for high
    priority items.

  • The PR gets reviews, discussed and approvals as needed.

  • The PR is merged by maintainers when it has been approved and comments addressed.

We currently aim to provide initial feedback/triaging within two business days. Please keep an eye on any labelling actions, as these will indicate priorities and status of your contribution.
We are very grateful for your contribution!

Copy link
Contributor

@Jorropo Jorropo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I like strong type checking.
    (becarefull I didn't wrote correct syntax in my suggestions)

  1. This doesn't do what we asked really.
    If I call:
  fx.Supply(bitswap.WithTracer(tracer)),
  fx.Supply(bitswap.TaskWorkerCount(2000)),

They wont get joined into one slice.

If you use the struct tags @ajnavarro linked you can make fx collect them for you.

core/node/bitswap.go Outdated Show resolved Hide resolved
core/node/bitswap.go Outdated Show resolved Hide resolved
core/node/groups.go Show resolved Hide resolved
@mrd0ll4r
Copy link
Contributor Author

mrd0ll4r commented Sep 9, 2022

If you use the struct tags @ajnavarro linked you can make fx collect them for you.

aha! Yeah, as I said, no clue how fx works :) I'll get to it

@Jorropo
Copy link
Contributor

Jorropo commented Sep 9, 2022

@mrd0ll4r if you really don't know how to do that no problem, I can make a PoC on this PR that you will cleanup 🙂.

// Additional options to bitswap.New can be provided via the "bitswap-options"
// group.
func OnlineExchange() fx.Option {
return fx.Provide(func(in onlineExchangeIn, lc fx.Lifecycle) exchange.Interface {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I saw somewhere that fx.Lifecycle was provided outside of an In struct. Let me know if that's the right way or not...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are you moving fx.Provide inside the function?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I asked for it, I I like type safety (returning fx.Option is imo clearer than interface{}).

Maybe it's less clear because you don't really what each option do (then we should rename it to ProvideOnlineExchange maybe ?)

Copy link
Member

@ajnavarro ajnavarro Sep 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not disagree with you, but everywhere else fx.Provide is called outside. I think we should keep code consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this back to have fx.Provide outside the function.

@mrd0ll4r
Copy link
Contributor Author

PTAL

@BigLep
Copy link
Contributor

BigLep commented Sep 16, 2022

I have re-requested review from @Jorropo

Copy link
Contributor

@Jorropo Jorropo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I'll leave the final word for @ajnavarro because I'm not totaly sure of what are the FX conventions.

@mrd0ll4r
Copy link
Contributor Author

Rebased, updated to move fx.Provide out of those constructors again.
PTAL and/or merge, maybe? :)

@ajnavarro ajnavarro merged commit 32e9a69 into ipfs:master Sep 19, 2022
@mrd0ll4r mrd0ll4r deleted the bitswap-fx-configuration branch September 19, 2022 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v0.15.0 / Bitswap v0.9.0 make it impossible to add Tracer
4 participants