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

fix: skip variadic params in constructors #1204

Merged
merged 1 commit into from
Sep 26, 2021
Merged

Conversation

Stebalien
Copy link
Member

We use them for "options". Ideally we'd be able to forward options through, but that would require real dependency injection.

We use them for "options". Ideally we'd be able to forward options
through, but that would require real dependency injection.
@marten-seemann
Copy link
Contributor

that would require real dependency injection

How would that look like?

@Stebalien
Copy link
Member Author

Stebalien commented Sep 26, 2021

This would allow passing options in a "group". We'd have to define a TcpTransport module as follows:

type TcpParams struct {
  fx.In

  Host host.Host
  Upgrader Upgrader
  Options []tcp.Option `group:"tcp_option"`
}

func TcpTransport(params TcpParams) Transport { ... }

type TcpOption struct {
  fx.Out

  Option tcp.Option `group:"tcp_option"`
}

But on second thought, this is even more complicated...

@Stebalien Stebalien merged commit f15c2a8 into master Sep 26, 2021
@Stebalien Stebalien deleted the fix/allow-variadic branch September 26, 2021 15:11
@Stebalien
Copy link
Member Author

Well, the options can be passed as: fx.Supply(fx.Annotated{Group: "tcp_option", MyTcpOption}) and transports could probably be supplied as Transport("tcp", constructor), or something like that. But this is an issue for another day.

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.

2 participants