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(ws server): impl IdProvider for Box<T> #684

Merged
merged 5 commits into from
Feb 1, 2022

Conversation

niklasad1
Copy link
Member

@niklasad1 niklasad1 commented Feb 1, 2022

Implement IdProvider for Box<T> to support Box<dyn IdProvider>, in addition I also added std::fmt::Debug to the IdProvider.

//cc @maciejhirsz
I had a look how difficult it would be to make this purely static dispatch because currently we pass dyn IdProvider to the RpcModule if the call is a subscription,

Then we would have to add a type param on Methods, RpcModule and related types and the only user-facing would be the the RpcModule which is a bit annoying but it would kill the extra indirection's. The benefit of this is that we could get rid of the Arc<dyn IdProvider> to I: IdProvider and require Clone on IdProvider.

@niklasad1 niklasad1 requested a review from a team as a code owner February 1, 2022 15:44
ws-server/src/tests.rs Outdated Show resolved Hide resolved
ws-server/src/server.rs Outdated Show resolved Hide resolved
@niklasad1 niklasad1 changed the title refactor(ws server): set_id_provider Box<dyn> refactor(ws server): impl IdProvider for Box<T> Feb 1, 2022
Copy link
Contributor

@dvdplm dvdplm left a comment

Choose a reason for hiding this comment

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

Works for me.

ws-server/src/tests.rs Outdated Show resolved Hide resolved
ws-server/src/tests.rs Outdated Show resolved Hide resolved
@dvdplm dvdplm merged commit 425ae56 into master Feb 1, 2022
@dvdplm dvdplm deleted the na-box-dyn-dispatch-subscription-id branch February 1, 2022 23:16
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.

4 participants