-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Added RFC for network errors handling #78
base: main
Are you sure you want to change the base?
Conversation
I'm not in favor of new methods. I'd rather use existing failure methods that already exist. We are pre-1.0, this is a small change, backwards compatibility isn't a concern. |
The "How we teach this" depends on functionality that doesn't exist... deprecation annotation. So, I don't consider that to be a good answer. I think it would be reasonable to update the doc strings for the given methods to account for the methods as well as add example code (or expand as the case maybe) for TCPConnection, UDPSocket and TCPListener to show usage of handling errors. |
Can you detail all the different SocketErrors we need to account for in the union type and what they would map to? There isn't enough here to implement. A complete mapping that is agreed upon would allow anyone to pick up and implement this. |
keeping notifiers API untouched
I've added few modifications, favoring Design to not change existing API |
text/0000-network-errors-handling.md
Outdated
2. Add private `_errno` field of `SocketErrNo` type into | ||
`TCPConnection`, `UDPSocket` and `TCPListener`. On failure, set | ||
`_errno` using corresponding OS errno code fetched using `SO_ERROR` | ||
socket option |
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.
On success, we'd also want to set it back to SocketOK
, right?
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.
Yeah, on any outcome (success or failure) we want to set _errno
. I'll fix
connections as well
Why not have the error reason be a parameter of |
the markdown formatting on this is off and currently kind of hard to read as half of it is in italics |
I'm not in favor of this RFC and the errno value. I'd want to see error values passed to notify methods as appropriate. |
Changing notifiers API is of course less smooth because it breaks existing code which uses "net" package. If keeping existing API is not important, then success and failure callbacks can be joined to single callback with error code provided |
As @SeanTAllen said, ensuring backwards compatibility isn't very important until we've hit 1.0. That said, I think we'd want to keep the success and failure callbacks separate since they are expected to take very different actions. |
I'd tend to agree with @Praetonus about keeping the callbacks separate - they are really very separate in terms how you want to handle them, and arguably the success case doesn't really need an error code. |
Having single callback for connection result will also solve RFC 23, since it will force "net" package users to implement dispatch on error code |
I actually like different callbacks as well for success&failure and also error provided in callback, that was the initial proposal in given RFC. So having API like fun ref not_listening(sock: UDPSocket ref, error: SocketError)
fun ref not_listening(listen: TCPListener ref, error: SocketError)
fun ref connect_failed(conn: TCPConnection ref, error: SocketError) is most affordable, correct ? |
@zevlg yes. i think providing the error to existing methods is a the best approach |
What do you think guys?