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

For ViewQuery.keys(), use GET instead of POST #165

Open
ceefour opened this issue Mar 26, 2014 · 4 comments
Open

For ViewQuery.keys(), use GET instead of POST #165

ceefour opened this issue Mar 26, 2014 · 4 comments

Comments

@ceefour
Copy link
Contributor

ceefour commented Mar 26, 2014

Currently Ektorp uses POST to get a ViewQuery that has specified keys() :

06:44:05.451 | DEBUG | ostersg_Worker-4 | c.q.g.c.s.PlaceProgressCalcJob   | Executing calcAndStoreAllPlaceProgress for tenant 'boostersg'
06:44:05.466 | INFO  | ostersg_Worker-4 | c.q.g.c.a.GuardianAnalyticsImpl  | [boostersg] Calculating PlaceProgress for 1 places (incl. unplaced): [sherway_garden]
06:44:05.466 | TRACE | ostersg_Worker-4 | o.e.h.StdHttpClient              | Content: {"keys":["sherway_garden"]}
06:44:05.565 | TRACE | ostersg_Worker-4 | o.e.h.StdHttpClient              | POST /boostersg_prd/_design/Checklist/_view/placeId_active_only 200 OK
06:44:05.565 | DEBUG | ostersg_Worker-4 | sitory/boostersg_prd/checklist/1 | Find all Checklist IDs by Place [sherway_garden] returned 0: []

While it works, services like Cloudant charges POST requests 5 times more expensive than GET requests.

Ektorp should default to GET requests unless it's really necessary to use POST? (maybe when the GET URI is close to 8 KB)

@YannRobert
Copy link
Collaborator

private <T> T executeQuery(final ViewQuery query,

method private T executeQuery(final ViewQuery query, ResponseCallback rh)
in class StdCouchDbConnector
could be set protected so you can override it, as a first move

@ceefour
Copy link
Contributor Author

ceefour commented Apr 6, 2014

Please merge pull request #170

ceefour added a commit to soluvas/Ektorp that referenced this issue Apr 7, 2014
ceefour added a commit to soluvas/Ektorp that referenced this issue Apr 10, 2014
ceefour added a commit to soluvas/Ektorp that referenced this issue Apr 10, 2014
ceefour added a commit to soluvas/Ektorp that referenced this issue Apr 10, 2014
helun pushed a commit that referenced this issue Apr 22, 2014
Introduce query executor strategy, enabling #165
@YannRobert
Copy link
Collaborator

Now that #174 is merged, you should be able to create you own implementation of a QueryExecutor to be injected into the StdCouchDbConnector.

ceefour added a commit to soluvas/Ektorp that referenced this issue Jul 14, 2014
from the discussion in helun#165,
which prefers `GET` HTTP method even in case of multiple keys.
It is more appropriate for hosted services like <a href="http://cloudant.com/">Cloudant</a>
where `POST` requests are charged more than `GET`.

However, if the HTTP request length exceeds `MAX_KEYS_LENGTH_FOR_GET` characters,
it will use `POST` HTTP method.

`ViewQuery` needed to be factored slightly to support its usage.
@ceefour
Copy link
Contributor Author

ceefour commented Sep 18, 2014

@YannRobert @helun 1.4.2 changes are not sufficient to implement my own QueryExecutor properly.

Please review #192 for the additional changes required.

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 a pull request may close this issue.

2 participants