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

Next-Generation Design of TCP actors #1398

Closed
plajjan opened this issue Jul 4, 2023 · 1 comment
Closed

Next-Generation Design of TCP actors #1398

plajjan opened this issue Jul 4, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request stdlib Related to the Acton standard library
Milestone

Comments

@plajjan
Copy link
Contributor

plajjan commented Jul 4, 2023

We have basic TCP actors. I'd like to have more functionality. I've been pondering the design for quite some time but haven't really reached a conclusion on something that meets all my requirements.

Requirements:

  • support happy eyeball, which is about connecting to a host name with the quickest possible transport
    • for example, we want to connect to example.com, like so TCPConnection("example.com", 80", ...)
    • DNS resolves example.com, for both A and AAAA
    • we get both an IPv4 and an IPv6 address
    • we start connecting to both IPv4 and IPv6 at the same time
    • whichever connection establishes first is used, the other is discarded
  • support reconnection in a simple way
    • packets are dropped, it's every day life on the Internet, yet most socket interfaces are very low level - sockets cannot be reused, forcing user to redo everything
      • for example, it is NOT enough to connect once and then pass around a socket, the application must also have address, port etc, so it can reconnect
    • explicit reconnect, but maybe also some option of automatic reconnect?
  • work well with capabilities based security
    • we have capability based security, meaning we delegate access to things from a higher privilege actor to a semi-trusted actor, mostly by passing something in the Auth chain, like WorldAuth -> NetAuth -> TCPAuth -> TCPConnectAuth
      • for example, main actor has WorldAuth, creates TCPConnectAuth and passes to HTTPClient actor, which is then able to initialize a TCP connection but cannot do other things, like shut down the system
    • but we can also potentially create the resource itself in the higher privilege actor and pass the resource to the semi-trusted actor
      • for example, main actor directly created TCPConnection and passes to HTTPCLient
      • but this requires that HTTPClient actor, which now owns the TCPConnection can do reconnect, otherwise the connection quickly becomes useless
        • the alternative, soliciting help from the privileged actor to perform the reconnect, does not seem like it would lead to nice code
  • reusable for many TCP connections
    • like our base TCP client we have now are for plain TCP
    • but we should have the same design pattern and preferably implementation be reused for OpenSSL or similar protocol that rides on top of TCP
      • OpenSSL needs happy eyeballs too!
  • 0 overhead
    • for example, an SSL actor should directly talk to sockets, not be layered on top of a TCP actor
      • we don't want the SSL actor to sit on top of a TCP actor, which would introduce extra data passing, it would imply two worker thread schedulings etc
    • 0 overhead also means we cannot implement happy eyeballs using 2 levels of actors
      • but is it possible with mixin classes?

Thoughts:

  • multiple actors, perhaps using mixins or so, to cater to different use cases
    • higher level, simple to use, TCP actor
      • for example does automatic reconnect with resonable backoff
        • this should fit 90% of use cases
    • one more raw & low level TCP actor
@plajjan
Copy link
Contributor Author

plajjan commented Aug 15, 2023

This is pretty much done through #1414. There might be bugs etc but I think we've pretty much nailed the design. CLosing this.

@plajjan plajjan closed this as completed Aug 15, 2023
@plajjan plajjan self-assigned this Aug 15, 2023
@plajjan plajjan added enhancement New feature or request stdlib Related to the Acton standard library labels Aug 15, 2023
@plajjan plajjan added this to the Base milestone Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stdlib Related to the Acton standard library
Projects
None yet
Development

No branches or pull requests

1 participant