hitzhangjie / gorpc-cli Goto Github PK
View Code? Open in Web Editor NEW`gorpc` cmdline for quickly generate project based on rpc framework `go-rpc`
License: Apache License 2.0
`gorpc` cmdline for quickly generate project based on rpc framework `go-rpc`
License: Apache License 2.0
service
defined, use this to find out all pb.Register${Service}Service
TODOXXX
, expand rpc method statements finishedok, what code structure should be visualized?
提炼出可复用的代码作为单独的repo,包括但不限于:
等等吧
I am trying on this, it's a little complex, not that so complex. And I am not using plantuml activity.
Displaying the participants, branches, actions all in sequential diagram maybe better to understand.
The picture above is from Ballerina microservice framework. I do some trying for golang.
Before showing some samples, I want to share my thinkings.
which language construct or activities should we visualize?
I think OOP is good.
Maybe what we care most is the Participants and Communication.
Besides, we care the condition branches. like when something happens? If it happens, what we should do?
what communication stands for?
ps: After I do some trying on this, I think it would be better if we could specify which activity we should focus on.
how should we visualize these constructs or activites?
some samples:
func TestIfElse() {
num := 1
if num == 1 {
fmt.Println("1")
} else if num == 2 {
fmt.Println("2")
} else {
fmt.Println("others")
}
}
and relevant puml:
@startuml
participant ifstmt
alt ../../testdata/ast/ifelse.go:8:5
ifstmt->ifstmt
note right: stmt ../../testdata/ast/ifelse.go:9:3
else ../../testdata/ast/ifelse.go:10:9
alt ../../testdata/ast/ifelse.go:10:12
ifstmt->ifstmt
note right: stmt ../../testdata/ast/ifelse.go:11:3
else ../../testdata/ast/ifelse.go:12:9
ifstmt->ifstmt
note right: stmt ../../testdata/ast/ifelse.go:13:3
end
end
@enduml
rendered picture:
ForStmt
package ast
import "fmt"
func TestForStmt() {
for i := 0; i < 10; i++ {
fmt.Println("hello world")
}
}
relevant puml:
@startuml
participant forStmt
group ForStmt
forStmt->forStmt
note right: init ../../testdata/ast/for.go:6:6
loop ../../testdata/ast/for.go:6:14
forStmt->forStmt
note right: body stmt: ../../testdata/ast/for.go:7:3
forStmt->forStmt
note right: post ../../testdata/ast/for.go:6:22
end
end
@enduml
rendered picture:
take a real project as example:
Just a little try, It even cannot satisfy my own usage.
If we could find a better reprentation manner, it would be better.
I learned that the microservice framework Ballerina supports graphical editor, https://medium.com/ballerina-techblog/ballerina-vscode-plugin-graphical-editor-for-ballerina-b6af226178d6.
Maybe we could use this render method like Ballerina, though it would be much more complex. Or we could add some options to exclude/include the language constructs.
该设计最初是为了用来对存量协议提供适当的支持,目前提供了两种方式:
建议使用第二种,本身也是google protocol buffer推荐的方式,注释的方式难以维护,难以扩展,也不是官方推荐的方式,特别是两种方式混用的时候,非常丑陋。
以前安装是通过make install进行安装的,会通过go build -ldflags "-X pkg.var=${revision}"
的形式将当前代码版本写入到二进制程序里。
现在go get方式,无法干预链接过程,需要在提交代码前,将代码中的版本变量config.GoRPCCliVersion更新为正确的版本。可以考虑通过makefile target来解决。
generate instruction like:
this file is generated by bindata, don't edit it.
更好的开发测试支持:
1.自动编译程序(带-gcflags参数),生成调试符号、禁用内联优化,方便后面调试;
2.goast分析服务接口实现(包括请求、响应类型分析);
3.goast分析函数中外部依赖,如db、rpc调用,可以是任意函数调用;
有两个明显的好处:
tdd模式,鼓励先规划测试用例,再投入开发,红绿红绿……
该issue提及的方式,与tdd也不冲突,只需要一个加载配置文件的helper函数辅助一下即可。
删除一下代码:
以gorpc create
代码生成为例,过程中涉及到了:
--plugins=validator+swagger
instead of --swagger --validator
按照最初我的设计:
use --plugins instead of --mock, --swagger,
so we can keep this tool relatively stable, also we can extend it with plugins.
and we can use it like gorpc create --plugins=mock+swagger+anything
.
After *.proto updated, including adding service
, rpc
definition, we should re-generate the template project.
But we shouldn't overwritten the written code by developers.
Solutions:
Actually, both methods need parse previous code to build an AST and parse.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.