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

Asynchronous connect for caf-net #1390

Open
2 tasks
Neverlord opened this issue Mar 18, 2023 · 0 comments
Open
2 tasks

Asynchronous connect for caf-net #1390

Neverlord opened this issue Mar 18, 2023 · 0 comments

Comments

@Neverlord
Copy link
Member

Neverlord commented Mar 18, 2023

CAF 0.19 introduced a new high-level DSL for spinning up connections to servers. For example:

  namespace ws = caf::net::web_socket;
  // ...
  auto conn
    = ws::with(sys)
        // Connect to the given URI.
        .connect(server)
        // If we don't succeed at first, try up to 10 times with 1s delay.
        .retry_delay(1s)
        .max_retry_count(9)
        // After connecting, spin up a worker to manage it.
        .start([&sys, hello](auto pull, auto push) {
          // ...
        });

This is fine when doing this from the main thread that has no other task than booting up the workers. However, it's a blocking API and thus should be avoided from cooperatively-scheduled actors.

CAF should offer an asynchronous API alongside the blocking functions, e.g., async_connect, to establish the connection in some background thread.

Currently, we would have to support the new async-connect in these protocols:

  • WebSocket
  • Length-prefix Framing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant