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

Add option to avoid throwing error if immediateConnectTimeout is defined but server is not available #1161

Open
Yaroslav-Kovalchyk-Imprivata opened this issue Jan 15, 2025 · 0 comments
Labels
enhancement A feature request or improvement

Comments

@Yaroslav-Kovalchyk-Imprivata
Copy link

Yaroslav-Kovalchyk-Imprivata commented Jan 15, 2025

The problem

We'd like to enable immediateConnectTimeout option to improve first gRPC call performance, but there is a downside: gRPC server must be available on client application startup. Otherwise IllegalStateException is thrown and application context startup fails (see net.devh.boot.grpc.client.channelfactory.AbstractChannelFactory#connectOnStartup, line 301):

`

  if (!connected) {
        throw new IllegalStateException("Can't connect to channel " + name);
    }

`

The solution

Please add a configutation property to make throwing exception optional (e.g. immediateConnectError or similar). This property could be enabled by default to keep backward compatibility. The code sniplet above could be changed to something like this:

`

    if (!connected && this.properties.getChannel(name).getImmediateConnectError()) {
        throw new IllegalStateException("Can't connect to channel " + name);
    }

`

Alternatives considered

There is a way to implement custom StubTransformer and access ManagedChannel using reflection, but this is ugly and strictly relyes on internal implementation, that could be changed in future versions.

@Yaroslav-Kovalchyk-Imprivata Yaroslav-Kovalchyk-Imprivata added the enhancement A feature request or improvement label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A feature request or improvement
Projects
None yet
Development

No branches or pull requests

1 participant