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(iroh): move code from builder to node and make things nicer #2386

Merged
merged 2 commits into from
Jun 19, 2024

Conversation

Frando
Copy link
Member

@Frando Frando commented Jun 19, 2024

Description

This is a cleanup of the node and builder code.

  • Move run and gc_loop from builder.rs to node.rs - it is not about building but about running.
  • Improve the code flow and naming all around the builder, spawn and run functions
  • Make sure we shutdown the node correctly while spawning

Breaking Changes

  • Removed Node::controller. Use Node::client instead. The former was mostly unusable anyway because we made the RPC structs private.

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.
  • All breaking changes documented.

@Frando Frando force-pushed the refactor/node-and-builder branch from e36e948 to 32ef8ac Compare June 19, 2024 12:44
@Frando Frando marked this pull request as ready for review June 19, 2024 12:45
@Frando Frando force-pushed the refactor/node-and-builder branch from 1d65c7b to ec042bb Compare June 19, 2024 12:58
@rklaehn
Copy link
Contributor

rklaehn commented Jun 19, 2024

Very much in favour of moving core node logic into node. It always felt weird to have half the logic in the builder!

handler.inner.sync.doc_start_sync(req).await
})
let handler = Self::new(inner);
join_set.spawn(async move {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are adding lots of tasks to the joinset. Presumably this is so they can all be properly shut down on shutdown.

But is it OK to add lots of tasks without ever calling join_next? won't you aggregate a lot of handles to long-finished short lived tasks?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do call join_next in the main loop, and break the main loop if a task panics - which is the main reason for the join set IMO (shutdown as well, but it won't matter much in practice because the tasks will also abort once the join set is dropped).

@Frando Frando added this pull request to the merge queue Jun 19, 2024
Merged via the queue into main with commit 08f1fe0 Jun 19, 2024
24 of 25 checks passed
ppodolsky pushed a commit to izihawa/iroh that referenced this pull request Jun 22, 2024
…0-computer#2386)

This is a cleanup of the node and builder code.

* Move `run` and `gc_loop` from `builder.rs` to `node.rs` - it is not
about building but about running.
* Improve the code flow and naming all around the builder, spawn and run
functions
* Make sure we shutdown the node correctly while spawning

* Removed `Node::controller`. Use `Node::client` instead. The former was
mostly unusable anyway because we made the RPC structs private.

<!-- Any notes, remarks or open questions you have to make about the PR.
-->

- [x] Self-review.
- [x] Documentation updates if relevant.
- [ ] ~~Tests if relevant.~~
- [x] All breaking changes documented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants