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): use boxed client to get rid of the C type parameter #2353

Merged
merged 7 commits into from
Jun 20, 2024

Conversation

rklaehn
Copy link
Contributor

@rklaehn rklaehn commented Jun 7, 2024

Description

I implemented a boxed connection and a boxed service endpoint in quic-rpc.

With this we can get rid of the <C: ServiceConnection<RpcService> type parameter and make the quinn and mem client/server side the same type.

The nice thing about this approach is that it will not lead to additonal boxing on the mem path, and for the quinn or whatever io path the boxing will probably not matter that much compared to all the other things going on.

Breaking Changes

Breaking changes affect solely the iroh client.

The iroh client as well as all the subsystem clients no longer need a type parameter C to distinguish between an in memory connection and a remote connection.

  • Code that directly uses the clients should be unaffected. E.g. iroh.blobs().read(hash) will still compile.

  • Code that takes a client as an argument will have to be modified to remove the type parameter. E.g.

fn download<C>(client: blobs::Client<C>) where C: ...

will become just

fn download(client: blobs::Client)

The type aliases iroh::client::MemIroh and iroh::client::QuicIroh for an iroh client specialized for memory or remote use have been retained, but will be removed in one of the next releases.

In detail:

  • iroh::client::Iroh loses the C type parameter
  • iroh::client::blobs::Client loses the C type parameter
  • iroh::client::tags::Client loses the C type parameter
  • iroh::client::authors::Client loses the C type parameter
  • iroh::client::docs::Client loses the C type parameter

Notes & open questions

Note: I marked the old type aliases MemIroh, QuicIroh etc as deprecated. That does not seem to actually do anything, but just serves as a reminder to remove them in the near future.

Change checklist

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

rklaehn added 4 commits June 7, 2024 21:52
# Conflicts:
#	iroh/src/client.rs
#	iroh/src/client/authors.rs
#	iroh/src/client/blobs.rs
#	iroh/src/client/docs.rs
#	iroh/src/client/tags.rs
#	iroh/src/node.rs
#	iroh/src/node/builder.rs
@rklaehn rklaehn force-pushed the boxed-client branch 2 times, most recently from d4ecad6 to 4bada75 Compare June 20, 2024 08:03
@rklaehn rklaehn marked this pull request as ready for review June 20, 2024 08:06
@rklaehn rklaehn force-pushed the boxed-client branch 2 times, most recently from 12cf5de to de11d25 Compare June 20, 2024 08:27
@rklaehn rklaehn requested a review from dignifiedquire June 20, 2024 08:35
Copy link
Contributor

@flub flub left a comment

Choose a reason for hiding this comment

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

This is lovely

iroh/src/client.rs Outdated Show resolved Hide resolved
They are no longer needed and will be removed soon.
iroh/src/client/authors.rs Outdated Show resolved Hide resolved
iroh/src/client.rs Show resolved Hide resolved
iroh/src/client/blobs.rs Outdated Show resolved Hide resolved
iroh/src/client/docs.rs Outdated Show resolved Hide resolved
iroh/src/client/tags.rs Outdated Show resolved Hide resolved
iroh/src/node/builder.rs Show resolved Hide resolved
document boxing overhead, some renaming, consistent use of type alias
@rklaehn rklaehn requested a review from Frando June 20, 2024 09:27
@rklaehn rklaehn enabled auto-merge June 20, 2024 10:02
@rklaehn rklaehn added this pull request to the merge queue Jun 20, 2024
@dignifiedquire
Copy link
Contributor

@rklaehn please add some more details on the breaking changes, otherwise I have to go through the whole PR when writing the changelog

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 20, 2024
@rklaehn
Copy link
Contributor Author

rklaehn commented Jun 20, 2024

@rklaehn please add some more details on the breaking changes, otherwise I have to go through the whole PR when writing the changelog

Added some more text. Is that sufficient?

@rklaehn rklaehn added this pull request to the merge queue Jun 20, 2024
Merged via the queue into main with commit abc7f5e Jun 20, 2024
29 checks passed
@dignifiedquire dignifiedquire deleted the boxed-client branch June 20, 2024 12:46
@dignifiedquire
Copy link
Contributor

thanks, looks great

ppodolsky pushed a commit to izihawa/iroh that referenced this pull request Jun 22, 2024
…0-computer#2353)

## Description

I implemented a boxed connection and a boxed service endpoint in
quic-rpc.

With this we can get rid of the `<C: ServiceConnection<RpcService>` type
parameter and make the quinn and mem client/server side the same type.

The nice thing about this approach is that it will not lead to additonal
boxing on the mem path, and for the quinn or whatever io path the boxing
will probably not matter that much compared to all the other things
going on.

## Breaking Changes

Breaking changes affect solely the iroh client.

The iroh client as well as all the subsystem clients no longer need a
type parameter C to distinguish between an in memory connection and a
remote connection.

- Code that directly uses the clients should be unaffected. E.g.
`iroh.blobs().read(hash)` will still compile.

- Code that takes a client as an argument will have to be modified to
remove the type parameter. E.g.

```rust
fn download<C>(client: blobs::Client<C>) where C: ...
```

will become just

```rust
fn download(client: blobs::Client)
```

The type aliases `iroh::client::MemIroh` and `iroh::client::QuicIroh`
for an iroh client specialized for memory or remote use have been
retained, but will be removed in one of the next releases.

In detail:

- iroh::client::Iroh loses the `C` type parameter
- iroh::client::blobs::Client loses the `C` type parameter
- iroh::client::tags::Client loses the `C` type parameter
- iroh::client::authors::Client loses the `C` type parameter
- iroh::client::docs::Client loses the `C` type parameter

## Notes & open questions

Note: I marked the old type aliases MemIroh, QuicIroh etc as deprecated.
That does not seem to actually do anything, but just serves as a
reminder to remove them in the near future.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
~~- [x] Tests if relevant.~~
- [x] All breaking changes documented.
matheus23 pushed a commit that referenced this pull request Nov 14, 2024
…2353)

## Description

I implemented a boxed connection and a boxed service endpoint in
quic-rpc.

With this we can get rid of the `<C: ServiceConnection<RpcService>` type
parameter and make the quinn and mem client/server side the same type.

The nice thing about this approach is that it will not lead to additonal
boxing on the mem path, and for the quinn or whatever io path the boxing
will probably not matter that much compared to all the other things
going on.

## Breaking Changes

Breaking changes affect solely the iroh client.

The iroh client as well as all the subsystem clients no longer need a
type parameter C to distinguish between an in memory connection and a
remote connection.

- Code that directly uses the clients should be unaffected. E.g.
`iroh.blobs().read(hash)` will still compile.

- Code that takes a client as an argument will have to be modified to
remove the type parameter. E.g.

```rust
fn download<C>(client: blobs::Client<C>) where C: ...
```

will become just

```rust
fn download(client: blobs::Client)
```

The type aliases `iroh::client::MemIroh` and `iroh::client::QuicIroh`
for an iroh client specialized for memory or remote use have been
retained, but will be removed in one of the next releases.

In detail:

- iroh::client::Iroh loses the `C` type parameter
- iroh::client::blobs::Client loses the `C` type parameter
- iroh::client::tags::Client loses the `C` type parameter
- iroh::client::authors::Client loses the `C` type parameter
- iroh::client::docs::Client loses the `C` type parameter

## Notes & open questions

Note: I marked the old type aliases MemIroh, QuicIroh etc as deprecated.
That does not seem to actually do anything, but just serves as a
reminder to remove them in the near future.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
~~- [x] 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.

4 participants