Closed aeasylife closed 9 months ago
I had planned to create a bean that can be used to get preconfigured channels/stubs by name. But I currently don't have time to work on that:
PushServiceStub stub = gprcClientInjector.getStub(PushServiceStub.class, "server143");
Currently you can only get the preconfigured Channel
s through GrpcChannelFactory
beans.
That way you can at least omit the PushServiceGrpcProperties
class.
Currently you can only get the preconfigured
Channel
s throughGrpcChannelFactory
beans. That way you can at least omit thePushServiceGrpcProperties
class.
Thank you for your reply. PushServiceGrpcProperties is just an example of server-side configuration, which actually needs to be obtained from the service registration list. Unfortunately, I am unable to assist in completing the plan due to insufficient abilities. I look forward to updating the plan in the future.
The context
I encountered a scenario where I need to connect multiple servers using the same client implementation.But I see in the examples that it is necessary to declare the client.
I want to be able to dynamically create stubs. like:
After debugging, I realized that I needed to modify the client in net.devh.boot.grpc.client.comfig.GrpcChannelsProperties. And then I realized that it couldn't be modified
Afterwards, I tried to write the following code,Most of it comes from source code.
It can run, but it's just a demo
The question
Is there a more elegant way to implement this feature? Are there any examples in the future?
The application's environment
Which versions do you use?