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

How to access the managed channels? #741

Open
hsalem7 opened this issue Sep 12, 2022 · 8 comments
Open

How to access the managed channels? #741

hsalem7 opened this issue Sep 12, 2022 · 8 comments
Labels
feedback required Information are missing or feedback for suggestions is requested question A question about this library or its usage
Milestone

Comments

@hsalem7
Copy link

hsalem7 commented Sep 12, 2022

Hello, I am trying to access the managed channels in order to warm up the DNS resolver.

I mean I want the channel to resolve the service host after the application is started. But I couldn't access the managed channels in any way!

So is there a way to do so? or is there any workaround?

Many thanks

@hsalem7 hsalem7 added the question A question about this library or its usage label Sep 12, 2022
@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 13, 2022

Currently, there is no way to access the ManagaedChannels directly. It is planned though.

Why do you wish to warmup the dns resolvers?

One way to do that (per channel) is to send a request to the channel. E.g. a health request.

@hsalem7
Copy link
Author

hsalem7 commented Sep 13, 2022

That is a good idea. But the problem is that the service doesn't have health check methods! (Unless there is another way 🙈 )
And the actual endpoints require some user context that I don't want to access during the service startup.

@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 13, 2022

You dont have to use an existing method/valid input.
Just create the stub call it and discard the result (error). Like normal http you can call any url and the browser will resolve the hostname/show an error.
That way, the dns is initialized.

@ST-DDT ST-DDT added the feedback required Information are missing or feedback for suggestions is requested label Sep 14, 2022
@hsalem7
Copy link
Author

hsalem7 commented Sep 14, 2022

The problem is that we have many interceptors that check some data and I don't want to bypass those, so if I provide the wrong data, the call will not happen, that is why it is not an option for me.

And regarding your statement:

Currently, there is no way to access the ManagaedChannels directly. It is planned though

Can I help somehow with that implementation? I can dedicate time to that.

@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 14, 2022

There are two parts that I would like to do.

  • Extract the injection logic from the bean post processor, so that it can be injected itself
    • The injector is also responsible to apply the interceptors, removing this task from the channel factory
    • If possible, it should also split the injection step from channel factory (using a lazy forwarding channel; that way there is no longer a dependency between the InProcessChannel and Server)
  • Replace the different ManagedChannel/ServerFactories with something that are just use grpc native builder factory + configurer to build the instance, all configuration logic should be moved from the factories to configurers

From an architectural perspective it should look somewhat like this:

grafik

Which part do you wish to tackle?

  • Split GrpcClientBeanPostProcessor into GrpcClientInjector
  • Rewrite ManagedChannelFactory

@hsalem7
Copy link
Author

hsalem7 commented Sep 15, 2022

I would start with the first one Split GrpcClientBeanPostProcessor into GrpcClientInjector

@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 15, 2022

Awesome. The public API of the injector should be somewhat like this:

  • <T> T get(String name, Class<T> type)
  • <T> T get(@GrpcClient client, Class<T> type)

Where T is the type of the field and @GrpcClient the annotation on that field.
The name variant is a simplification for manual use where you dont want to set any additional options.
Feel free to adjust the method signature to your liking/implementation needs.

@slogic
Copy link

slogic commented Feb 15, 2023

My case is integration test. I need to inspect some behaviour and signup to ManagedChannel.notifyWhenStateChanged. I very need this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback required Information are missing or feedback for suggestions is requested question A question about this library or its usage
Projects
None yet
Development

No branches or pull requests

3 participants