Patch for #165: For ViewQuery.keys(), use GET instead of POST - #170
Patch for #165: For ViewQuery.keys(), use GET instead of POST#170ceefour wants to merge 7 commits into
Conversation
|
İ'd like to suggest that this patch be accepted, it has saved me a significant cost saving with cloudant |
|
the build is failing. |
|
Ok I'll try to fix it. |
|
Ok I've found the issue, since the current tests actually expects the behavior, I'll need to add more tests |
|
How is it working with GET request size limit ? this would depend a combination of the key size and key count. I would like to point out that this particular feature can be implemented using method override This hopefully would avoid any change on ViewQuery class. |
|
The caller determines this:
|
|
The behavior should not change for current users. GET should only be used if you explicitly request that. I think it should be controlled though a separate method: |
|
@helun, alright I'll change it to that. I would like to propose that default uses While the behavior changes, it should just work for all but the most extreme cases, in which case one should be able to easily fix it by using the proper method. Do you approve? |
|
Do you mind if I propose an alternative implementation that would fix #165 ? |
|
If @ceefour makes the changes i proposed there will just be one new method in ViewQuery: or have I missed something? |
|
The point is that the logic is too complex to be implemented in the same StdCouchDbConnector method What if I want to use an automatic threshold, that, if the HTTP request can be done using GET because the query String is shorter than x Kb, then decides to use GET, otherwise fallback to POST ? What if I want to use a constant or variable threshold, that, if the keys count it higher than X, uses POST, otherwise used GET ? Some users would expect the framework to handle this, and propose yet another patch to the existing method, with another boolean that would drive the decision to use GET or POST ? What if some other user one day ask for a feature to transparently split the query of 1000 IDs into 10 GET queries of 100 IDs ? Then a user may ask for an automatic retry on failure, etc ... I propose that method with queryExecutor beeing a member of StdCouchDbConnector, of type QueryExecutor (new interface) so that @ceefour can inject an alternative QueryExecutor into the StdCouchDbConnector instance he wants to change behavior of. @ceefour could then contribute an AlwaysUseGetQueryExecutor implementation. This would not even require any change on the ViewQuery class As for encouraging new user to use AlwaysUseGetQueryExecutor, and existing user to switch, we can do this using documentation. @ceefour would this fit your need ? |
|
Hi @helun, my latest commit soluvas@adc3cd2 implements your request, with a "twist" (as a way of persuading you to use
I hope this is acceptable. Please :) |
|
@YannRobert I have two opinions about it, but this is just my opinion. I feel that Ektorp is a low-level CouchDB access library. It's a bit higher when compared to dealing with HttpClient, but feels the same level as JDBC. The features you described seems like it belongs to a higher abstraction, like what Hibernate does. If these features (auto-retry, auto-split, etc.) will be included into Ektorp (which is nice), I believe it is a separate feature than what I'm trying to achieve here (and should be discussed separately), which is simply a low-level way to tell Ektorp what HTTP method to use. |
|
http://en.wikipedia.org/wiki/Strategy_pattern Do you need a StdCouchDbConnector to always use the same "strategy", when querying ? point 1 Point 1 would not require a change in ViewQuery. Just wire-in the strategy you want into StdCouchDbConnector Point 2 may be done with a change in ViewQuery (as you did), but may be done using several instance of StdCouchDbConnector, each configured with the appropriate stategy. As I understand your need, you are more concerned by always using the GET method, so always using an alternative implementation to the existing one. Please let me do the refactoring so that you can wire-in the strategy you like. I may come up with a PR real soon. |
|
Please see my PR #174 |
|
We'll go with @YannRobert s solution, so I'll close this one |
|
@helun Thanks :) Now I can wait for 1.4.2 release :) |
For ViewQuery.keys(), use GET instead of POST. Fixed #165.