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

[LEDGER] move couchdb util package to statecouchdb package #926

Merged
merged 1 commit into from
Apr 15, 2020

Conversation

cendhu
Copy link
Contributor

@cendhu cendhu commented Mar 27, 2020

Type of change

  • Improvement (improvement to code)

Description

We have a CouchDB util package that exposes API to read from and write to CouchDB. This package is used only by the statecouchdb and the tests package (i.e., ledger level integration test).

In general, a util package is justified only when an API needs to be used by so many other packages. For e.g., if we have 10 packages and each of them need a common API, it is not good to duplicate the API code. Hence, it is good to create a separate util package. One such example can be found in the volume folder in the Kubernetes repo – It can be seen that Kubernetes supports 26 different volume types and hence a util package to hold common APIs is justified. However, in our case, it is not justified to have a separate util package to facilitate CouchDB access.

Hence, we move all files in the CouchDB util package to the statecouchdb package itself. Note that there is a lot of opportunities to refactor the CouchDB util package but we would do it in a separate JIRA.

Additional details

Before starting the ledger checkpointing code, we would like to refactor the ledger package. If we continue to add new features with the current package structure, after a few years, it will be unmaintainable. We plan to have nearly 10 such PRs. Note that each PR may modify many files and we cannot do much about it. We might be okay to get some review burden than having an unmaintainable code in the longer term.

Related issues

FAB-17667

@cendhu cendhu requested a review from a team as a code owner March 27, 2020 18:58
@cendhu cendhu changed the title [for v2.2.0] ledger refactoring (1) -- move couchdb util package to statecouchdb package [for v2.2.0] move couchdb util package to statecouchdb package Mar 27, 2020
@cendhu cendhu requested a review from a team as a code owner March 27, 2020 19:12
@cendhu
Copy link
Contributor Author

cendhu commented Mar 30, 2020

gossip UT flake

@cendhu
Copy link
Contributor Author

cendhu commented Mar 30, 2020

/ci-run

@github-actions
Copy link

AZP build triggered!

@cendhu cendhu changed the title [for v2.2.0] move couchdb util package to statecouchdb package [for v2.2.0] move couchdb util package to statecouchdb package [1] Mar 30, 2020
@cendhu cendhu changed the title [for v2.2.0] move couchdb util package to statecouchdb package [1] move couchdb util package to statecouchdb package [merge-order-1] Mar 31, 2020
@cendhu cendhu force-pushed the mv-couchdb-util branch from 0fdf1c9 to b4de8d5 Compare April 1, 2020 09:43
@cendhu cendhu changed the title move couchdb util package to statecouchdb package [merge-order-1] [WIP] move couchdb util package to statecouchdb package [merge-order-1] Apr 1, 2020
Copy link
Contributor

@manish-sethi manish-sethi left a comment

Choose a reason for hiding this comment

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

A few comments on the changes in your last change-set

@cendhu
Copy link
Contributor Author

cendhu commented Apr 2, 2020

Yes, Manish. I catched all your points already and that's why I made it WIP. Will be done by today.

@manish-sethi
Copy link
Contributor

Yes, Manish. I catched all your points already and that's why I made it WIP. Will be done by today.

Yes, My fault. I noticed WIP tag, after submitting the comments

@cendhu cendhu force-pushed the mv-couchdb-util branch 3 times, most recently from 8dc4456 to 17b78a7 Compare April 2, 2020 09:41
@cendhu cendhu changed the title [WIP] move couchdb util package to statecouchdb package [merge-order-1] move couchdb util package to statecouchdb package Apr 2, 2020
@cendhu
Copy link
Contributor Author

cendhu commented Apr 2, 2020

@ryjones I have a question as you asked me to squash my commits to one.

Do we have this squash and merge feature? https://blog.pairworking.com/why-you-should-care-about-squash-and-merge-in-git-675856bf66b0

If it is so, I will push multiple commits per PRs as it would enable the reviewer to easily look at changes made between two reviews. Otherwise, the reviewer's job would be painful to go over all files. During the merge, they can squash and merge.

@manish-sethi also feels that it is hard to review without seeing the diff between the base commit and new commits which made changes to code as per the suggestions.

@manish-sethi
Copy link
Contributor

@ryjones I have a question as you asked me to squash my commits to one.

Do we have this squash and merge feature? https://blog.pairworking.com/why-you-should-care-about-squash-and-merge-in-git-675856bf66b0

If it is so, I will push multiple commits per PRs as it would enable the reviewer to easily look at changes made between two reviews. Otherwise, the reviewer's job would be painful to go over all files. During the merge, they can squash and merge.

@manish-sethi also feels that it is hard to review without seeing the diff between the base commit and new commits which made changes to code as per the suggestions.

@cendhu - We can still see the diffs even if you push as a single commit. The problem is when you rebase in between

@cendhu cendhu force-pushed the mv-couchdb-util branch from 17b78a7 to 522c568 Compare April 2, 2020 15:50
@cendhu
Copy link
Contributor Author

cendhu commented Apr 2, 2020

Conflicts are resolved. @manish-sethi let's get this in. This PR is too boring now.

@cendhu cendhu force-pushed the mv-couchdb-util branch from 522c568 to 6bac872 Compare April 2, 2020 16:48
Copy link
Contributor

@manish-sethi manish-sethi left a comment

Choose a reason for hiding this comment

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

Overall LGTM. Just one comment on what you changed in the last patch

@cendhu cendhu force-pushed the mv-couchdb-util branch from 6bac872 to 36282c5 Compare April 9, 2020 12:05
Copy link
Contributor Author

@cendhu cendhu left a comment

Choose a reason for hiding this comment

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

I have addressed the review comments. I have pushed multiple commits so that the changes can be seen easily.

@cendhu cendhu force-pushed the mv-couchdb-util branch from 130cd9a to 028c590 Compare April 9, 2020 15:08
@cendhu cendhu changed the title move couchdb util package to statecouchdb package [LEDGER] move couchdb util package to statecouchdb package Apr 9, 2020
@cendhu cendhu force-pushed the mv-couchdb-util branch 5 times, most recently from 462a0d0 to 78111cb Compare April 14, 2020 15:47
@cendhu
Copy link
Contributor Author

cendhu commented Apr 14, 2020

rebased and fixed conflicts.

Copy link
Contributor

@manish-sethi manish-sethi left a comment

Choose a reason for hiding this comment

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

LGTM, mostly cleanup related comments.

@manish-sethi
Copy link
Contributor

@cendhu - LGTM now. You can squash and make it a single commit and we can merge now. Only one pending comment is there. If you want to address that while making it as a single commit, that would be good. But I am fine merging otherwise as well.

We have a CouchDB util package that exposes API to read from and
write to CouchDB. This package is used only by the statecouchdb and
the tests package (i.e., ledger level integration test).

In general, a util package is justified only when an API needs to be
used by so many other packages. For e.g., if we have 10 packages and
each of them need a common API, it is not good to duplicate the API
code and instead create a separate util package.

Hence, we move all files in the CouchDB util package to the statecouchdb
package itself. Note that there is a lot of opportunities to refactor
couchdb package but we will do that in a separate PR.

Given that we have moved couchdb util to the statecouchdb package,
we can have only one TestMain. It would be hacky to reuse
existing testVDBEnv for testing couchDB too. Hence, we introduce
another testEnv called testCouchDBEnv to test couchDB utils.

Signed-off-by: senthil <cendhu@gmail.com>
@cendhu
Copy link
Contributor Author

cendhu commented Apr 15, 2020

Squashed all 3 commits to a single commit.

@manish-sethi manish-sethi merged commit c41f9eb into hyperledger:master Apr 15, 2020
@cendhu cendhu deleted the mv-couchdb-util branch April 18, 2020 05:50
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 this pull request may close these issues.

3 participants