Interceptors are not great for routing to different backends. That'd be the job of a LoadBalancer. For your case, it sounds like you could also just create a Channel implementation instead of a ClientInterceptor. It could create multiple ManagedChannels and decide which to use based on the application logic.
On Mon, Jul 20, 2020 at 10:21 AM Sivabalan <[email protected]> wrote: > Hi folks, > Let's say I have an interceptor which dictates which host to route the > application request to based on some business logic. In okhttp client, it > is straightforward by re-creating the request with a new host url. From my > understanding of grpc, a channel/managedchannel is tightly coupled with the > host and so(I do understand we could leverage dns resolver etc, but if not > for that), an interceptor can't really update the host once the channel is > created. If the request has to be routed to a different host compared to > what current channel was instantiated, a new channel has to be > instantiated, followed by adding all interceptors again and then start > serving requests. > > Is my understanding correct? If there is any workaround to update the host > dynamically by one of the interceptors. > > -- > Regards, > -Sivabalan > > -- > You received this message because you are subscribed to the Google Groups " > grpc.io" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/grpc-io/CABeKz3md8b-UQvMLcTqVyXt%3DAQP1ooTPVte93%3D4bOFffgEcShg%40mail.gmail.com > <https://groups.google.com/d/msgid/grpc-io/CABeKz3md8b-UQvMLcTqVyXt%3DAQP1ooTPVte93%3D4bOFffgEcShg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "grpc.io" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/CA%2B4M1oNrz%2BvdQBOd6Yi8o0CWebtySm9G0FxEjDWHrpaJb96%2BJQ%40mail.gmail.com.
smime.p7s
Description: S/MIME Cryptographic Signature
