TrueLayer / ginepro

A client-side gRPC channel implementation for tonic
Apache License 2.0
127 stars 24 forks source link

wait for an initial resolution to succeed before fully constructing `LoadBalancedChannel` #20

Closed tdyas closed 2 years ago

tdyas commented 3 years ago

Motivations

The service probe loop appears to log and ignore errors while running. This seems fine while the service is running, but at startup, it could be an indication that the ServiceDefinition has an invalid hostname (e.g., has a typo). Some callers might prefer to panic in that situation so deployment systems are immediately aware of a problem instead of just reporting nothing resolved via metrics.

Solution

When constructing a LoadBalancedChannel, the code should wait for an initial resolution of the provided ServiceDefinition to succeed before returning the LoadBalancedChannel. This has the benefit of (1) finding invalid DNS names immediately (and allowing the program to exit immediately); and (2) ensures that LoadBalancedChannel has an initial non-empty set of endpoints to use before the program enters application code.

Alternatives

An alternative would be for callers to access the current set of endpoints and wait with a timeout until there are one or more endpoints. If no endpoints are resolved by the timeout, then a caller could error exit or alert. I don't know offhand whether Channel supports something like this.