Why does grpc.NewClient silently ignore DialOptions?
SamMobed opened this issue · comments
Hi,
The grpc.NewClient godoc specifies how DialOptions returned by WithBlock, WithTimeout, WithReturnConnectionError, and FailOnNonTempDialError are ignored by it.
In the following document, it's explained that using deprecated DialOptions can cause problems.
I'm wondering why NewClient silently ignores these options when they are set by users, instead of returning an error? The user might be expecting a certain behavior when creating the connection, and silently ignoring these options instead of explicitly raising an error might hurt their work.
I don't know if erroring has been considered and rejected, or if we just didn't think about it (the PR introducing NewClient
has no mention of this option). I could see the argument for accepting those options to make it easier to switch to NewClient
. I am not sure this was the best option: if users do rely on WithBlock
, and since NewClient
is a new function, I suppose that in most cases it's easy enough for users to get rid of those ineffective and deprecated options when they migrate to the new interface. And it makes it even more explicit that the blocking behaviour doesn't apply anymore.
Introducing this error as a breaking change might be OK. @arvindbr8 mentioned that issuing logs might be a reasonable trade-off. We'll wait for @dfawley to decide if we want to do something about it though, to see if those options were considered.
Since Dial
calls NewClient
, we'd need to filter these options out there before calling NewClient
. I think the current behavior is fine (even if it's not optimal), and changing it now will be hard, since it would be a breaking behavior change. I'd be inclined to leave things as-is, personally.