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

Generic Router Implementation #3976

Closed
mossid opened this issue Mar 26, 2019 · 3 comments
Closed

Generic Router Implementation #3976

mossid opened this issue Mar 26, 2019 · 3 comments
Labels
Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity.

Comments

@mossid
Copy link
Contributor

mossid commented Mar 26, 2019

Ref: #3880 (comment)

We now have three router logic:

Tx Router: https://github.com/cosmos/cosmos-sdk/blob/develop/baseapp/router.go
Query Router: https://github.com/cosmos/cosmos-sdk/blob/develop/baseapp/queryrouter.go
Proposal Handler: (PR not merged yet)

We need to abstract out this logic, we expect the number of multipurpose modules(like governance proposal) will increase. Two possible implementations are go generate and reflect(https://golang.org/pkg/reflect/#Value.Call). AFAIK go generate is recommended to avoid in our codebase, and reflection is inefficient. Is there a better way to improve?

@mossid mossid added core Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity. labels Mar 26, 2019
@alexanderbez
Copy link
Contributor

alexanderbez commented Mar 26, 2019

Under the hood the router is just a simple map, no? We can have a generic router that is of type map[string]interface{} and enforce the caller to make sure the returning values are the correct type. This is essentially identical to go's container/list.

@jackzampolin
Copy link
Member

This is a great thing for dev ux when building on the SDK. I think this is something we might want to look at while splitting gaia out of the SDK

@alexanderbez alexanderbez changed the title Abstract out handler router logic Generic Router Implementation Mar 27, 2019
@alexanderbez alexanderbez removed the core label Jul 6, 2020
@tac0turtle
Copy link
Member

tac0turtle commented Jun 1, 2021

I think this is more or less completed with the migration to protobuf. We no longer require users to create switch statements since the protobuf service is registered now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Code Hygiene General cleanup and restructuring of code to provide clarity, flexibility, and modularity.
Projects
None yet
Development

No branches or pull requests

4 participants