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

Unable to set the id_provider when using RpcModule::raw_json_request #1342

Open
JamesHinshelwood opened this issue Apr 4, 2024 · 2 comments

Comments

@JamesHinshelwood
Copy link

JamesHinshelwood commented Apr 4, 2024

In our test suite, we use RpcModule::raw_json_request to simulate calls to our server, without having to spin up an actual HTTP/WS server.

This works for the most part, however the id_provider for subscriptions is set on the Server, rather than RpcModule. Therefore, RpcModule uses the default RandomIntegerIdProvider, despite our actual implementation using a different provider.

Currently, I am hacking around this in the glue code of our test suite, but it would be nice to avoid that.

In the best case scenario, would it be possible to move the id_provider lower down the stack to the RpcModule? Alternatively, if that isn't possible or feasible, could we let the user pass an id_provider in calls to raw_json_request?

@niklasad1
Copy link
Member

niklasad1 commented Apr 4, 2024

Good question, lemme have a ponder but indeed it would be better to add the IdProvider to the RpcModule for testing etc.

@niklasad1
Copy link
Member

I had a look and adding the id provider to the RpcModule itself is massive change because it's generated by the proc maco API and we have no notion of the subscription ID generation in there....

So, what you do think about:

  • Change the API to RpcModule::raw_json_request(&self, request: &str, buf_size: usize, id_provider: &dyn IdProvider) {...}
  • Add another API RpcModule::subscribe_with_provider(&self, sub_method: &str, params: impl ToRpcParams, buf_size: usize, id_provider: &dyn IdProvider) {...}

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

No branches or pull requests

2 participants