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

Batch requests? #146

Open
kriegfrj opened this issue Jun 2, 2021 · 6 comments
Open

Batch requests? #146

kriegfrj opened this issue Jun 2, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@kriegfrj
Copy link
Contributor

kriegfrj commented Jun 2, 2021

So I've just learned that the remote OData service that I'm trying to connect to requires that all requests (even singletons) be sent as batch requests.

Unless I'm mistaken, the current client generator does not generate clients that support batch requests out-of-the-box?

@kriegfrj
Copy link
Contributor Author

kriegfrj commented Jun 2, 2021

To clarify a little: I realise that you could submit a batch request using the _custom() call on the client. However, if I had to use this exclusively, it isn't much better than using HttpClient directly.

It would be nice if all of the type-safe wrappers around the entity data and requests could be re-used for the batch requests. (Alternatively, if this is already doable, it would be nice if there were some examples in the README.md 😄.)

@davidmoten
Copy link
Owner

You are right, no support for batch requests exists. I would implement as per http://docs.oasis-open.org/odata/odata/v4.01/csprd02/part1-protocol/odata-v4.01-csprd02-part1-protocol.html#_Toc486263479.

We'll have to give you some functionality to modify standard headers as well to conform to expectations of v2 service.

@davidmoten davidmoten added the enhancement New feature or request label Jun 3, 2021
@kriegfrj
Copy link
Contributor Author

kriegfrj commented Jun 4, 2021

I had a high-level idea for how this could be implemented in a fairly transparent way, with minimal changes to the code base.

What if each batch request was implemented as HTTP client wrapper over the top of the "main" client. Individual batches would be built up by submitting requests through this client wrapper, and when you've finished you call some method on the wrapper client which submits the batch. This would require minimal changes to the generated code.

One issue that I can foresee is that the generated clients all handle requests synchronously (correct me if I'm wrong). That wouldn't work with this approach because the first request obviously won't complete until it receives a response. A solution to this would be to add asynchronous request support to the generated clients by returning a CompletableFuture<ReturnType>. You could then submit the requests to the batch http client asynchronously, submit the batch and wait for the result.

Thoughts?

@davidmoten
Copy link
Owner

Interesting, I'll have to read the spec to check up on all this...

@davidmoten
Copy link
Owner

a quick and dirty might be to wrap every individual request as a batch request (of 1). The http client can be customized already.

@kneringerjohann
Copy link
Contributor

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants