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

Refactor server spawning to be synchronous and infallible #2097

Merged

Conversation

jvff
Copy link
Contributor

@jvff jvff commented Jun 4, 2024

Motivation

While refactoring to replace tokio::spawns with spawning on JoinSets, I realized it would help if the spawning of servers was synchronous and infallible. That means that the spawn* methods only spawn tasks, and do no other work.

Proposal

Refactor server spawn* methods to be infallible and (mostly) synchronous. The spawn_{grpc,simple} methods in linera-service are still asynchronous but they only await the collection of the handles, which can be done in a spawned task as well. However, that requires some further refactoring so that the caller awaits all the tasks, which I left for the next PR.

In terms of functionality, the visible part of the changes is error reporting. Before it would log a separate error message if an error occurred while a task was starting (for example when parsing an IP address or binding to a socket). With this PR, all errors are logged by the same expression which handles any error during the spawn and during the execution.

Test Plan

This is an internal refactor. No new coverage is needed and CI should catch any regressions.

Release Plan

This is an internal refactor, so nothing is needed.

Links

jvff added 8 commits June 4, 2024 03:10
Perform all IO operations in the spawned task.
Perform all IO operations in the spawned task.
Return an error only from the spawned task.
There's no need to delay it.
There aren't any failure scenarios for them.
The fields can be cloned directly in the `async` block, just like what
is done with the `server_config.internal_network` value.
There's no need to keep them in the block, now that they are
synchronous.
Make it explicit that the order of the futures doesn't matter.
@jvff jvff added the refactor label Jun 4, 2024
@jvff jvff added this to the Testnet milestone Jun 4, 2024
@jvff jvff requested review from Twey, ma2bd and christos-h June 4, 2024 03:20
@jvff jvff self-assigned this Jun 4, 2024
@jvff jvff requested a review from afck June 4, 2024 13:04
@jvff jvff merged commit 7a6da04 into linera-io:main Jun 4, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging this pull request may close these issues.

2 participants