Skip to content

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

Open
@Yaroslav-Kovalchyk-Imprivata

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementA feature request or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions