Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

zevlg
Copy link

@zevlg zevlg commented Feb 15, 2017

What do you think guys?

@SeanTAllen
Copy link
Member

SeanTAllen commented Feb 15, 2017

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.

@SeanTAllen
Copy link
Member

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.

@SeanTAllen
Copy link
Member

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.

@zevlg
Copy link
Author

zevlg commented Feb 20, 2017

I've added few modifications, favoring Design to not change existing API

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
Copy link
Member

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?

Copy link
Author

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

@Praetonus
Copy link
Member

Why not have the error reason be a parameter of connect_failed and not_listening, as mentioned in Alternatives? I don't really see how that would be "less smooth" and there are several advantages. I think having the error code as a parameter is less error prone because the method signature reminds you to check the reason, and it avoids setting a field on every operation in the implementation.

@SeanTAllen
Copy link
Member

the markdown formatting on this is off and currently kind of hard to read as half of it is in italics

@SeanTAllen
Copy link
Member

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.

@zevlg
Copy link
Author

zevlg commented Feb 21, 2017

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

@Praetonus
Copy link
Member

Praetonus commented Feb 21, 2017

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.

@jemc
Copy link
Member

jemc commented Feb 21, 2017

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.

@zevlg
Copy link
Author

zevlg commented Feb 22, 2017

Having single callback for connection result will also solve RFC 23, since it will force "net" package users to implement dispatch on error code

@zevlg
Copy link
Author

zevlg commented Feb 22, 2017

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 ?

@SeanTAllen
Copy link
Member

@zevlg yes. i think providing the error to existing methods is a the best approach

Base automatically changed from master to main February 8, 2021 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants