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-docs): Replace flume with async_channel in docs #2540

Merged
merged 4 commits into from
Jul 29, 2024

Conversation

rklaehn
Copy link
Contributor

@rklaehn rklaehn commented Jul 24, 2024

Description

This is mostly a 1:1 replacement, except for the fact that the same_channel api is missing from async_channel. So I replaced it with some ugly code that uses the fact that a async_channel Sender or Receiver is just an Arc.

To be removed if/when smol-rs/async-channel#98 is merged, but until then I think it is fine.

Breaking Changes

None

Notes & open questions

Note: we can not use tokio::sync::mpsc::Channel for the actor because we can't control from which thread Drop is called.
Note: some streams were Unpin before, but it was not explicit. Now I added Unpin explicitly (and boxed the stream to make it true). Not sure if the version check would catch this, pretty sure that not. But taking away Unpin would have been a breaking change.

Change checklist

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

This is mostly a 1:1 replacement, except for the fact that the same_channel
api is missing from async_channel. So I replaced it with some ugly code
that uses the fact that a async_channel Sender or Receiver is just an Arc<Channel>.

To be removed if/when smol-rs/async-channel#98 is
merged, but until then I think it is fine.
@rklaehn rklaehn force-pushed the iroh-docs-flume-purge branch from b0082bc to a5720e9 Compare July 24, 2024 10:33
pub fn doc_list(
&self,
_req: DocListRequest,
) -> impl Stream<Item = RpcResult<DocListResponse>> + Unpin {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added Unpin here. it was unpin before - implicitly assumed, but it is better to be explicit. Maybe we should remove this later, but for now let's keep it as close as possible to before. Otherwise I think this would be a breaking change.

@rklaehn rklaehn requested review from Frando and dignifiedquire July 24, 2024 10:54
@rklaehn rklaehn marked this pull request as ready for review July 24, 2024 11:11
Copy link
Member

@Frando Frando left a comment

Choose a reason for hiding this comment

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

LGTM. Not sure about the same_channel unsafe, would have to read rust mem docs to validate first. But if you did this, fine to approve.

@rklaehn rklaehn added this pull request to the merge queue Jul 29, 2024
Merged via the queue into main with commit e7a7552 Jul 29, 2024
26 checks passed
@rklaehn rklaehn deleted the iroh-docs-flume-purge branch July 29, 2024 07:46
matheus23 pushed a commit that referenced this pull request Nov 14, 2024
## Description

This is mostly a 1:1 replacement, except for the fact that the
same_channel api is missing from async_channel. So I replaced it with
some ugly code that uses the fact that a async_channel Sender or
Receiver is just an Arc<Channel>.

To be removed if/when smol-rs/async-channel#98
is merged, but until then I think it is fine.

## Breaking Changes

None

## Notes & open questions

Note: we can not use tokio::sync::mpsc::Channel for the actor because we
can't control from which thread Drop is called.
Note: some streams were Unpin before, but it was not explicit. Now I
added Unpin explicitly (and boxed the stream to make it true). Not sure
if the version check would catch this, pretty sure that not. But taking
away Unpin would have been a breaking change.

## Change checklist

- [ ] Self-review.
- [ ] 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.
- [ ] Tests if relevant.
- [ ] 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.

2 participants