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

feat(iroh): make Endpoint::cancel_token public #3098

Closed
wants to merge 1 commit into from

Conversation

arilotter
Copy link

It's used inside the Router to automatically shut down if the Endpoint is shut down, but this is a privilege uniquely granted to Router since it's part of Iroh proper.

End-user code with a custom accept loop is not able to see this cancel_token method, and thus is not able to automatically shut down should the Endpoint shut down.

To bring end-user accept loops into feature parity with Iroh's internals, this method must be pub.

Closes #3096

It's used inside the Router to automatically shut down if the Endpoint is shut down, but this is a privilege uniquely granted to Router since it's part of Iroh proper.

End-user code with a custom accept loop is not able to see this cancel_token method, and thus is not able to automatically shut down should the Endpoint shut down.

To bring end-user accept loops into feature parity with Iroh's internals, this method must be `pub`.

Closes n0-computer#3096
@arilotter arilotter closed this Jan 7, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jan 8, 2025
## Description

The internal CancellationToke was used to know by other parts of the
code when the endpoint is shut down.  But those bits of code already
have mechanisms to do so.  This bit of API makes is a bit of extra
complexity that is not needed.

## Breaking Changes

None, this is internal.

## Notes & open questions

Closes #3096.
Closes #3098 (replaces).

Maybe not directly but now there's an example of how to write an
accept loop without having to rely on the CancellationToken.


## Change checklist

- [x] Self-review.
- [x] Documentation updates following the [style
guide](https://rust-lang.github.io/rfcs/1574-more-api-documentation-conventions.html#appendix-a-full-conventions-text),
if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.
@arilotter arilotter deleted the patch-1 branch January 8, 2025 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

consider making Endpoint::cancel_token public
1 participant