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

WIP: Split LCD implementation PR, part two #2199

Closed

Conversation

HaoyangLiu
Copy link

@HaoyangLiu HaoyangLiu commented Aug 31, 2018

  • Add client manager to do load balancing
  • Add swagger-ui for these modules: bank,transaction

Proceed from:
#2118
#2147
#2177

Closes #525 and #1020 and #2179 and #2108

@HaoyangLiu
Copy link
Author

The following PRs mentioned before about other APIs and spec will depend on this PR. It would be wonderful if this PR could be reviewed and merged soon.

@HaoyangLiu HaoyangLiu changed the title Split LCD implementation PR, part two R4R: Split LCD implementation PR, part two Aug 31, 2018
Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

These Swagger libraries look possibly useful - was there a previous design discussion here? I think I'm missing some context.

@@ -0,0 +1,46 @@
package context
Copy link
Contributor

Choose a reason for hiding this comment

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

This is interesting, but with only round-robin load balancing it's not that useful in my opinion. I would rather have a discussion about what we want this to do for clients - maybe track failed requests, or track latency, and automatically switch clients to provide the best UX. I'm not convinced we need this right now (but if you think we do by all means explain why).

Copy link
Author

Choose a reason for hiding this comment

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

The round-robin load balancing is indeedly simple. But it does contribute to TPS, please refer to the my test report. I think a load balancing module is necessary. Maybe currently we can just remove this module. But in long run, we have to add load balancing. How do you think about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it depends on the use-case that the this client/context is designed for. As is it's optimized for a single wallet application to be bundled w/ Electron in the Voyager app... if we're making calls to query the app state then ultimately a full node is required to service the state queries (with or without proof), so it would arguably work to just have load-balancing behind a set of full nodes.

@@ -0,0 +1,725 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this from a previous consensus on API documentation - can you link to it?

Copy link
Member

@jackzampolin jackzampolin Aug 31, 2018

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

This is something that has been discussed repeatedly in a number of issues. Having automatically generated API docs is going to be increasingly important as the surface area of the API grows. I've also personally used swagger in previous projects and found it amazing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Generally agreed - but we should figure out how exactly we want to do this. If we can now generate these automatically:

  1. Are the downstream consumers (@faboweb @fedekunze) in favor of this particular autogeneration format / will it suit their needs?
  2. Why does this PR commit an autogenerated file?
  3. Can we remove the existing manual docs in favor of autogenerated ones?

Copy link
Member

Choose a reason for hiding this comment

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

  1. Yes, see issues
  2. It shouldn't, we should add that to .gitignore
  3. Yes, eventually.

Copy link
Contributor

Choose a reason for hiding this comment

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

Great, thanks for the clarification. Sounds like @faboweb or @fedekunze would be far better suited than I to review this PR!

Copy link
Author

Choose a reason for hiding this comment

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

@cwgoes @jackzampolin @fedekunze
Please refer to this link for swag tool. Currenly it has some defects. It can't properly generate the data structure for some complex self-define struct. Besides, I can find all APIs when theses API don't locate in a same root folds. So I have to manually edit docs.go

Copy link
Member

@jackzampolin jackzampolin Aug 31, 2018

Choose a reason for hiding this comment

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

I don't think we want to be in a position where we are relying on a non functional tool and manual editing for our docs process. Can't we just use a swagger.yaml file and update that instead of relying on go struct tags and the swag tool? Or alternately can we try to figure out how to get the generation to work properly? Would love to hear some other thoughts here.

Copy link
Author

Choose a reason for hiding this comment

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

Please refer this swag example. It requres the main.go locate in the root fold. And all related handlers and data struct also locate in this root folds. However, in cosmos-sdk, main.go locates in cmd/gaia/cmd/gaiacli, and handlers locate in many folds, such as client/key, x/. And data strcut locates in many folds too.
So if we want to make swag generation works well, we have to refactor our code structure. Do you agree with me @fedekunze ?
I'm thinking usging swagger.yaml file. But it may also require maunally edit API docs.
In long run, maybe refactor our code strcuture is a good idea.

@fedekunze fedekunze requested a review from faboweb August 31, 2018 15:20
@fedekunze
Copy link
Collaborator

CC: @cosmos/cosmos-ui

@HaoyangLiu
Copy link
Author

@cwgoes @jackzampolin
So far, the first PR #2192 has been merged. Now the gaiacli rest-server can also perform proof verification. It is equivalent to a gaia-lite, just missing swagger-ui which provides APIs specification and better human interaction.
The following PRs are mainly to implement a rest-server with swagger-ui, as well as to refactor some APIs to accommodate newest API spec.
If it is not urgent, how about refactor the code structure for all handler and related data structures?

@HaoyangLiu
Copy link
Author

Please move to #2215
This PR will be closed soon.

@HaoyangLiu HaoyangLiu changed the title R4R: Split LCD implementation PR, part two WIP: Split LCD implementation PR, part two Sep 3, 2018
@HaoyangLiu HaoyangLiu closed this Sep 6, 2018
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.

6 participants