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! Remove S type parameter #24

Closed
wants to merge 3 commits into from
Closed

feat! Remove S type parameter #24

wants to merge 3 commits into from

Conversation

rklaehn
Copy link
Collaborator

@rklaehn rklaehn commented Dec 2, 2024

Description

This removes the S type parameter from the Blobs protocol handler.

Breaking Changes

Blobs no longer has the S type parameter. As a consequence, Blobs can no longer have the store available. So any code that needs direct access to the store can no longer get that via the protocol handler.

  • Blobs<S> -> Blobs
  • Blobs::store is removed (you need to keep a separate reference to the store)
  • Blobs::handle_rpc_request removed (you need to create a separate RpcHandler)
  • Blobs::rt renamed to Blobs::local_pool_handle

Notes & open questions

Rpc requires knowing the type of the store. But Blobs does not have that info. So the way it works now is that you can build a rpc handler using the blobs builder, and then get the blobs protocol handler from that.

Not super nice, but I can't see another way to do this since once the type info is gone there is no way to get it back.

Change checklist

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

Copy link

github-actions bot commented Dec 2, 2024

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

Last updated: 2024-12-02T13:26:30Z

}

fn shutdown(self: Arc<Self>) -> BoxedFuture<()> {
self.inner.clone().shutdown()
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do you need to clone, shouldn't this already be owned?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

self is Arc (has to be to comply with the ProtocolHandler trait, but I need an Arc, not an &Arc.

This is what I mean when I complain about the Arcs being contagious.

@matheus23
Copy link
Member

Have we considered an enum instead of a trait/abstraction here?

I.e.

enum BlobStore {
    InMemory(iroh_blobs::store::mem::Store),
    FileSystem(iroh_blobs::store::fs::Store),
}

impl iroh_blobs::store::Store for BlobStore {
    // ...
}

The argument against this would be a custom blob store implementation. So far I haven't seen anyone do that? Entirely possible that that's because I haven't looked enough yet. Please tell me if that's the case 😬

There's still a bunch more things we could do before going this route, e.g. a feature-flagged (and #[non_exhaustive]) enum in iroh_blobs should there be a need for a third option.

@rklaehn
Copy link
Collaborator Author

rklaehn commented Dec 4, 2024

The argument against this would be a custom blob store implementation. So far I haven't seen anyone do that? Entirely possible that that's because I haven't looked enough yet. Please tell me if that's the case 😬

I did it to do a blob store backed by s3 buckets, see https://github.com/n0-computer/iroh-experiments/tree/main/iroh-s3-bao-store . This was due to customer demand or at least as a demo for a prospective customer.

Also I really want to keep the traits so I can experiment with something like fjall without having to rewrite all of blobs.

@rklaehn
Copy link
Collaborator Author

rklaehn commented Dec 6, 2024

@dignifiedquire @matheus23 I think main motivation for getting rid of the S type parameter for Blobs was to allow better interaction with get_protocol (having to provide S there was weird). So now that get_protocol is no more, I think it is no longer super important.

So should we just close this? I don't think the complexity of having a two stage builder and internal dynamic dispatch is warranted anymore...

@rklaehn
Copy link
Collaborator Author

rklaehn commented Dec 6, 2024

Getting rid of S is no longer that important now that we removed get_protocol...

@rklaehn rklaehn closed this Dec 6, 2024
@rklaehn rklaehn deleted the remove-type-parameter branch January 2, 2025 09:37
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.

3 participants