Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Gsoc: Add getRevisionDifference method with test, add header support to SocketClient and StreamClient, add POST support to getChanges method, add methods to BulkUpdater with tests. #42

Merged
merged 9 commits into from Jul 2, 2015

Conversation

Abhishek-17
Copy link
Contributor

Hi..! I am working on a project under Google's summer of code program for Drupal which involves writing a php based replicator. I am following this link for implementing the replication protocol and this is the first set of changes that i have made.
I will try to describe most of the changes that have been done in the client. Let's go file by file.

  1. CouchDBClient.php
    1. In getChanges() method, whenever doc_ids parameter is set and is not null, POST is used instead of GET for the request as the number of document ids can be large and using the POST is also the recommended way. See api/da ase/changes.
    2. getRevisionDifference() method has been added to the CouchDBClient class which sends a _POST /{db}/revs_diff request.
  2. CouchDBClientTest.php
    1. testGetRevisionDifference() has been added as the test for getRevisionDifference() method.
    2. Code for checking the doc_ids parameter has been added to the testGetChanges() method.
  3. BulkUpdater.php
    1. updateDocuments() method has been added. It's like the existing updateDocument() method, but instead of a document it takes an array having documents as array or as JSON strings. It's more convenient to add multiple documents to the Updater.
    2. setNewEdits() method has been added, which sets the new_edits option to true/false. This prevents the database from assigning them new revision IDs and is needed for the replicator. It is also one of the options that request JSON for _POST /{db}/bulk_docs api can have. So it will also be a good feature addition.
    3. setFullCommitHeader() has been added and it sets the X-Couch-Full-Commit in the HTTP request header sent by the execute() method to true/false. It's needed for the replicator.
    4. execute() method has been modified for supporting custom HTTP request headers. Currently only X-Couch-Full-Commit is being sent.
  4. BulkUpdaterTest.php
    This file has been added and contains the tests for BulkUpdater. This was not there initially and tests the new changes along with the pre-existing methods also. However there is no test for setFullCommitHeader() method.
  5. TestUtil.php
    1. getBulkTestDatabase() method has been added which returns the name of the database to be used for tests in BulkUpdaterTest. It's like the existing getTestDatabase() method.
  6. CouchDBFunctionalTestCase.php
    1. getBulkTestDatabase() method has been added which returns TestUtil::getBulkTestDatabase() ;
    2. createCouchDBClientForBulkTest() method has been added and returns an instance of CouchDBClient to be used in the tests for BulkUpdater.
  7. .gitignore
    1. Added .idea to it. It can be ignored.
  8. SocketClient.php and StreamClient.php
    1. Spelling errors in the inline comments have been corrected.
    2. Custom HTTP header support has been added to both the clients. The request() method takes the request headers also. This is needed as sometime we have to use the customer HTTP header like the above described X-Couch-Full-Commit, content type is not always application/json or the Accept header can be multipart/mixed. All this was not possible with the earlier clients and are needed for the requests of the replicator.

@Abhishek-17 Abhishek-17 changed the title Gsoc: Added getRevisionDifference method with test, added header support to SocketClient and StreamClient, added POST support to getChanges method Gsoc: Add getRevisionDifference method with test, add header support to SocketClient and StreamClient, add POST support to getChanges method, add methods to BulkUpdater with tests. Jul 2, 2015
* @return Response
* @throws HTTPException
*/
public function request( $method, $path, $data = null, $raw = false )
public function request( $method, $path, $data = null, $raw = false, array $headers = array())
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this change also needed in AbstractHttpClient class?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi beberlei..!
You meant in the request method of the Client interface..? It's not needed. It will be a desired addition though.

Copy link
Member

Choose a reason for hiding this comment

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

yes please add it, you cannot extend an interface this way, it is not proper :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added it. Please let me know if there is any other issue. :)

…ace and update phpdoc. Correct inline comment in CouchDBClientTest.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants