-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 documentation on some anti-patterns #6034
Conversation
@ulascansenturk : Could you please wrap the lines at 80-cols. Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to begin a document that explains why these options are not recommended by explaining that grpc.Dial
is not actually a "dialing" function at all. It creates a ClientConn
, which is a persistent, managed pool of connections that automatically reconnects as needed. The reason these options are not useful is that errors encountered during the first Dial
are no different from those that occur 1 second after the initial connection succeeds, and your application needs to handle both of those cases. It's for that reason that we don't recommend specially handling the initial connection error vs. any other one (vs. "WithBlock
...may end up waiting indefinitely" and "miss opportunities to recover").
Please also wrap all lines at 80 columns when you can, which will make it easier for us to read & review. |
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry again for the late reply. This looks really good, just a few more comments.
Documentation/anti-patterns.md
Outdated
|
||
## Conclusion | ||
|
||
The [`FailOnNonTempDialError`](https://pkg.go.dev/google.golang.org/grpc#FailOnNonTempDialError), [`WithBlock`](https://pkg.go.dev/google.golang.org/grpc#WithBlock), and [`WithReturnConnectionError`](https://pkg.go.dev/google.golang.org/grpc#WithReturnConnectionError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added to both the first references at the beginning and the references at the very end.
@dfawley
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add the references in the other direction? It would be nice if the godoc for those functions pointed to this document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For better understanding, do you want me to add godoc references to all other docstrings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like a link to this document from
Line 297 in 2997e84
// connecting the server happens in background. |
https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, i'll prepare new PR for that, or should I do it in this pull request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do it in this one, thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One other last minor thing. Otherwise LGTM!
Documentation/anti-patterns.md
Outdated
- When retrying failed RPCs, consider using the built-in retry mechanism | ||
provided by gRPC-Go, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems some of the wrapping got messed up here. Please take a final pass and make sure it's all lined up correctly, thanks.
dialoptions.go
Outdated
// For more information about this anti-pattern | ||
// see https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
//
// Use of this feature is not recommended. For more information, please see: <link>
?
dialoptions.go
Outdated
// For more information about this anti-pattern | ||
// see https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this above the // # Experimental
line and use the same text as above. (and similar request below)
@easwars can you review the changes & re-approve? |
@dfawley what if we want to catch configuration mistakes and don't care about the transient ones? Then WithBlock becomes useful before marking the container ready, no? What would you suggest instead? |
So in this case, For configuration errors, there are many other kinds of configuration problems and other errors that you couldn't catch this way anyway. E.g. you may connect to the wrong service, so the connection would succeed, but all RPCs would fail with NOT_IMPLEMENTED.
Yeah, as I said in #6034 (comment): " One way to detect and mitigate configuration errors is to use a phased rollout/canary process, and instrument monitoring in your applications. You can always just perform your RPCs using the channel, and the RPCs will fail with UNAVAILABLE when there are connection problems, and the error message should indicate the reason for the connection failure. Any dispatched RPCs will block until there is a READY connection or until the initial connection attempt has errored. (You should also typically not use the confusingly-named |
cc @temawi |
Created error handling documentation,
To rely on RPC errors instead of
grpc.FailOnNonTempDialError
grpc.WithBlock
grpc.WithReturnConnectionError
#6028
RELEASE NOTES: N/A