uber-go / fx

A dependency injection based application framework for Go.
https://uber-go.github.io/fx/
MIT License
5.68k stars 287 forks source link

Have separate package for rpc per library/encoding? #315

Closed bufdev closed 7 years ago

bufdev commented 7 years ago

Right now, modules/rpc is basically modules/yarpcthrift, ie it's not really for a generic rpc module, it's specifically for yarpc using the thrift encoding. Of course, you could add other rpc libraries (grpc for example) and other encodings (protobuf or avro for example) in the same package, but then you're talking about a lot of dependencies that aren't used for anyone importing this package.

I'd like to see something like:

modules/yarpc modules/yarpc/thrift modules/yarpc/protobuf modules/grpc modules/grpc/protobuf

bufdev commented 7 years ago

@breerly

HelloGrayson commented 7 years ago

We won't need to expose another RPC framework besides YARPC because YARPC will do that for us.

Besides the point: I agree, we need to expose all the functionally YARPC makes possible, and right now that is artificially limited to 1 encoding. A good litmus test would be: if we add a new encoding, like proto for example, there should be no work required in UberFX to expose that, it should just work.

The config project we are working on now (search "config:" in YARPC-go PRs) should resolve this (or put us in the position where it's the next thing to resolve): since the whole rpc: key will be delegated to yarpc, you'll need to be able to use it to work with any encodings.

I feel less strongly about whether the config key is named rpc: or yarpc:, but I sort of prefer the explicitness in the latter.

bufdev commented 7 years ago

"We" = Uber, I'd love if FX was usable as a general framework for everyone, including those not tied to YARPC, and there are some places where do we close tie-ins, but this is one that's easy to make sure we don't have a tie-in.

HelloGrayson commented 7 years ago

In other words, I do think:

bufdev commented 7 years ago

Note that in https://github.com/uber-go/fx/pull/275, I'm removing default names for modules as it is proposed now, so the key will not longer be tied by default to rpc.

bufdev commented 7 years ago

Oh also, I agree with @breerly's above list

bufdev commented 7 years ago

I don't want to do this until we get some of the bigger PRs in, otherwise we will be in merge world

yutongp commented 7 years ago

renaming has been discussed in #267 @yichengq