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): ActiveRelayActor terminates itself #3061

Merged
merged 10 commits into from
Dec 19, 2024

Conversation

flub
Copy link
Contributor

@flub flub commented Dec 18, 2024

Description

This moves the logic of terminating an ActiveRelayActor from the
RelayActor to the ActiveRelayActor itself. This is nice for two
reasons:

  • The interactions between ActiveRelayActor and RelayActor are even
    simpler. RelayActor logic is now easy to reason about.

  • It will allow ActiveRelayActor to manage reconnections with
    exponential backoff better. Currently this behaviour is not changed
    but the RelayActor getting involved meant the backoff behaviour was
    influcenced in two places.

Now that the ActiveRelayActor lifecyle is much more straight forward
the RelayActor's terminating is tidied up as well.

Breaking Changes

Notes & open questions

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

This moves the logic of terminating an ActiveRelayActor from the
RelayActor to the ActiveRelayActor itself.  This is nice for two
reasons:

- The interactions between ActiveRelayActor and RelayActor are even
  simpler.  RelayActor logic is now easy to reason about.

- It will allow ActiveRelayActor to manage reconnections with
  exponential backoff better.  Currently this behaviour is not changed
  but the RelayActor getting involved meant the backoff behaviour was
  influcenced in two places.

Now that the ActiveRelayActor lifecyle is much more straight forward
the RelayActor's terminating is tidied up as well.
@flub flub requested a review from a team December 18, 2024 14:32
@flub flub self-assigned this Dec 18, 2024
@flub flub added this to the v0.31.0 milestone Dec 18, 2024
Copy link

github-actions bot commented Dec 18, 2024

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3061/docs/iroh/

Last updated: 2024-12-19T12:50:54Z

Copy link

github-actions bot commented Dec 18, 2024

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: dc91b4b

@flub flub requested a review from dignifiedquire December 18, 2024 15:41
@flub flub requested a review from dignifiedquire December 19, 2024 09:39
@flub
Copy link
Contributor Author

flub commented Dec 19, 2024

oops, seems the interval change didn't work...

This kind of shows why I avoided it the first time: it is a lot more
complex to use.
@flub
Copy link
Contributor Author

flub commented Dec 19, 2024

oops, seems the interval change didn't work...

Fixed. It kind of shows why I didn't use this the first time round: a lot more complex.

@dignifiedquire
Copy link
Contributor

Fixed. It kind of shows why I didn't use this the first time round: a lot more complex.

feel free to go back if you think it is simpler

@flub
Copy link
Contributor Author

flub commented Dec 19, 2024

Fixed. It kind of shows why I didn't use this the first time round: a lot more complex.

feel free to go back if you think it is simpler

It's ok: tests caught it and it still leaves the code clearer to read. I don't think this should be a maintenance burden as this doesn't interact with anything else the actor does.

// the last datagrams sent to the relay, received datagrams will trigger ACKs which
// is sufficient to keep active connections open.
let mut inactive_timeout = tokio::time::interval(RELAY_INACTIVE_CLEANUP_TIME);
inactive_timeout.reset(); // skip immediate tick
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't using interval_at be cleaner? (honest question, not sure it does what you need here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

probably not, gets very verbose again and then i'd prefer the original sleep probably. going to leave this as-is.

Copy link
Contributor

@dignifiedquire dignifiedquire left a comment

Choose a reason for hiding this comment

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

one last question, otherwise nice improvements

@flub flub added this pull request to the merge queue Dec 19, 2024
Merged via the queue into main with commit 693922a Dec 19, 2024
26 checks passed
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.

2 participants