diff --git a/README.md b/README.md index 7f3ecf2..2dc9b82 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -# Odin -

Odin Logo @@ -22,11 +20,11 @@ Odin框架是好未来在使用rpcx框架过程中不断完善、改进的,目 [中文文档](https://www.yuque.com/tal-tech/odin) -## Introduction +## 简介 Odin是基于go语言的rpc框架,框架除了致力于提供高性能的服务间调用能力外,也提供完善的服务治理功能、支持多种服务注册发现机制。为了业务方使用框架更加便捷,框架还具有配套管理工具自动生成代码,提高开发效率。 -## Features +## 特性 ### 高性能 首先,框架底层基于rpcx框架,其是一个纯Go语言的rpc框架,与主流rpc框架进行性能对比,优势明显。其性能仅弱于Go原生rpc调用。 @@ -43,30 +41,34 @@ Odin结合配套的辅助工具[rigger](http://github.com/tal-tech/rigger),可 Odin框架目前已支持日志Trace跨服务传递,记录一次完整请求的所有记录,根据同一TraceID,查看全部链路。其他包括动态插件都 可自定义开发,只需最终在main注入即可。 -## Quick Start +## 快速入门 + +### 安装脚手架 + +通过 [rigger](http://github.com/tal-tech/rigger)脚手架可一键创建odin模板的rpcx项目 -### Install +### 安装框架 ``` -rigger new micro rpcproject +rigger new rpc rpcproject 正克隆到 '/winshare/go/src/rpcproject'... rpcprojec项目已创建完成, 使用: cd /winshare/go/src/rpcproject && rigger build 开始你的微服务之旅! ``` -### Build +### 编译 ``` //Makefile可依需求自定义 rigger build ``` -### Run +### 启动 ``` //启动 rigger start ``` -## Config +## 配置 ``` //conf/conf.ini //listen port @@ -83,7 +85,7 @@ addrs=127.0.0.1:2181 basePath=/odin_demo ``` -## Example +## 运行 ``` rigger example zookeeper //Output diff --git a/app/common/Const.go b/app/common/const.go similarity index 100% rename from app/common/Const.go rename to app/common/const.go diff --git a/app/service/service.go b/app/service/service.go index efbfa3a..979d71a 100644 --- a/app/service/service.go +++ b/app/service/service.go @@ -2,11 +2,10 @@ package service import ( "context" - "odin/app/serviceInterface" "odin/proto" - rpcxplugin "github.com/tal-tech/odinPlugin" "github.com/tal-tech/odinPlugin/wrap" + "odin/app/serviceInterface" ) //rpcx服务注册类型 @@ -111,3 +110,4 @@ func (this *Odin) MysqlDelete(ctx context.Context, req *proto.MysqlDeleteRequest } return this.Wrapcall(ctx, "MysqlDelete", fn) } + diff --git a/app/service/serviceBridge.go b/app/service/serviceBridge.go index 7174091..83d7e7e 100644 --- a/app/service/serviceBridge.go +++ b/app/service/serviceBridge.go @@ -44,13 +44,13 @@ type MysqlDelete interface { type serviceBridge struct { SayHelloImpl SayHello UserInfoImpl UserInfo - AddUserImpl AddUser - UpdateUserImpl UpdateUser + AddUserImpl AddUser + UpdateUserImpl UpdateUser RedisSetImpl RedisSet RedisGetImpl RedisGet - MysqlInsertImpl MysqlInsert - MysqlSelectImpl MysqlSelect - MysqlDeleteImpl MysqlDelete + MysqlInsertImpl MysqlInsert + MysqlSelectImpl MysqlSelect + MysqlDeleteImpl MysqlDelete } func NewServiceBridge() *serviceBridge { @@ -92,3 +92,4 @@ func (s *serviceBridge) MysqlSelect(ctx context.Context, req *proto.MysqlSelectR func (s *serviceBridge) MysqlDelete(ctx context.Context, req *proto.MysqlDeleteRequest, resp *proto.MysqlDeleteResponse) error { return s.MysqlDeleteImpl.MysqlDelete(ctx, req, resp) } + diff --git a/app/serviceImpl/DemoService.go b/app/serviceImpl/demoService.go similarity index 100% rename from app/serviceImpl/DemoService.go rename to app/serviceImpl/demoService.go diff --git a/app/serviceImpl/HelloService.go b/app/serviceImpl/helloService.go similarity index 99% rename from app/serviceImpl/HelloService.go rename to app/serviceImpl/helloService.go index 012e15e..40e3412 100644 --- a/app/serviceImpl/HelloService.go +++ b/app/serviceImpl/helloService.go @@ -3,7 +3,6 @@ package serviceImpl import ( "context" "fmt" - "odin/proto" ) diff --git a/app/serviceImpl/UserService.go b/app/serviceImpl/userService.go similarity index 99% rename from app/serviceImpl/UserService.go rename to app/serviceImpl/userService.go index 8c469dc..58de948 100644 --- a/app/serviceImpl/UserService.go +++ b/app/serviceImpl/userService.go @@ -29,7 +29,6 @@ func (this *UserService) UserInfo(ctx context.Context, req *proto.UserInfoReques resp.City = user.City return nil } - func (this *UserService) AddUser(ctx context.Context, req *proto.AddUserRequest, resp *proto.AddUserResponse) error { userRepo, err := repository.GetUserRepo(ctx) if err != nil { diff --git a/conf/conf.ini b/conf/conf.ini index ded405a..2119ae2 100644 --- a/conf/conf.ini +++ b/conf/conf.ini @@ -2,19 +2,19 @@ network=tcp port=11900 -[log] +[Log] ; LogPath : /home/logs/ -LogPath=/home/logs/odin/odin.log +logPath=/home/logs/odin/odin.log ; level :DEBUG/INFO/WARNING/ERROR -Level=DEBUG +level=DEBUG ; RotateLines 1K/1M -RotateLines=0K +rotateLines=0K ; RotateSize 1M/1G -RotateSize=0M -; RotateDaily true/false -RotateHourly=true +rotateSize=0M +; RotateHourly true/false +rotateHourly=true ; Retention -Retention=48 +retention=48 [Registry] @@ -22,7 +22,7 @@ status=off ;Registry Address addrs=127.0.0.1:2181 -basePath=/odin_demo +basePath=/tal_tech updateInterval=1m [Expvar] diff --git a/conf/conf_dev.ini b/conf/conf_dev.ini index 8ea01b7..01ed61c 100644 --- a/conf/conf_dev.ini +++ b/conf/conf_dev.ini @@ -2,26 +2,26 @@ network=tcp port=11900 -[log] +[Log] ; LogPath : /home/logs/ -LogPath=/home/logs/odin/odin.log +logPath=/home/logs/odin/odin.log ; level :DEBUG/INFO/WARNING/ERROR -Level=DEBUG +level=DEBUG ; RotateLines 1K/1M -RotateLines=0K +rotateLines=0K ; RotateSize 1M/1G -RotateSize=0M -; RotateHoury true/false -RotateHoury=true +rotateSize=0M +; RotateHourly true/false +rotateHourly=true ; Retention -Retention=48 +retention=48 [Registry] status=off ;Registry Address addrs=10.10.10.11:2181 10.10.10.12:2181 10.10.10.13:2181 -basePath=/odin_demo +basePath=/tal_tech updateInterval=1m group=dev diff --git a/conf/conf_online.ini b/conf/conf_online.ini index b523e14..dc67393 100644 --- a/conf/conf_online.ini +++ b/conf/conf_online.ini @@ -2,26 +2,26 @@ network=tcp port=11900 -[log] +[Log] ; LogPath : /home/logs/ -LogPath=/home/logs/odin/odin.log +logPath=/home/logs/odin/odin.log ; level :DEBUG/INFO/WARNING/ERROR -Level=DEBUG +level=DEBUG ; RotateLines 1K/1M -RotateLines=0K +rotateLines=0K ; RotateSize 1M/1G -RotateSize=0M -; RotateHoury true/false -RotateHoury=true +rotateSize=0M +; RotateHourly true/false +rotateHourly=true ; Retention -Retention=48 +retention=48 [Registry] status=off ;Registry Address addrs=10.10.10.11:2181 10.10.10.12:2181 10.10.10.13:2181 -basePath=/xes_xueyan_hudong +basePath=/tal_tech updateInterval=1m group=online diff --git a/conf/conf_release.ini b/conf/conf_release.ini index aa4ad50..3d33b7f 100644 --- a/conf/conf_release.ini +++ b/conf/conf_release.ini @@ -2,26 +2,26 @@ network=tcp port=11900 -[log] +[Log] ; LogPath : /home/logs/ -LogPath=/home/logs/odin/odin.log +logPath=/home/logs/odin/odin.log ; level :DEBUG/INFO/WARNING/ERROR -Level=DEBUG +level=DEBUG ; RotateLines 1K/1M -RotateLines=0K +rotateLines=0K ; RotateSize 1M/1G -RotateSize=0M -; RotateHoury true/false -RotateHoury=true +rotateSize=0M +; RotateHourly true/false +rotateHourly=true ; Retention -Retention=48 +retention=48 [Registry] status=on ;Registry Address addrs=10.10.10.11:2181 10.10.10.12:2181 10.10.10.13:2181 -basePath=/xes_xueyan_hudong +basePath=/tal_tech updateInterval=1m group=release diff --git a/go.mod b/go.mod index 250cb55..397f18b 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,5 @@ module odin -go 1.12 - replace github.com/smallnest/rpcx v0.0.0 => github.com/smallnest/rpcx v0.0.0-20200214051052-c65a6415f3d1 require ( @@ -41,13 +39,13 @@ require ( github.com/spf13/cast v1.3.1 github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e // indirect github.com/tal-tech/connPool v0.0.0-20200806112113-738c408fe6ae // indirect - github.com/tal-tech/hera v0.0.0-20200807103530-dd689e514981 - github.com/tal-tech/loggerX v0.0.0-20200806121626-bc3db51db258 + github.com/tal-tech/hera v1.0.0 + github.com/tal-tech/loggerX v1.0.0 github.com/tal-tech/odinPlugin v0.0.0-20200807094654-094a1edd2a60 github.com/tal-tech/routinePool v0.0.0-20200806121001-477db7bdba8a // indirect - github.com/tal-tech/torm v0.0.0-20200806135310-06840940369a - github.com/tal-tech/xredis v0.0.0-20200806132427-7807ee6297d9 - github.com/tal-tech/xtools v0.0.0-20200827070525-4842d161be6a + github.com/tal-tech/torm v1.0.0 + github.com/tal-tech/xredis v1.0.0 + github.com/tal-tech/xtools v0.0.0-20200925092432-5d398cc834e0 github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b // indirect github.com/tjfoc/gmsm v1.3.0 // indirect github.com/toolkits/file v0.0.0-20160325033739-a5b3c5147e07 // indirect @@ -57,6 +55,7 @@ require ( github.com/xtaci/kcp-go v5.4.20+incompatible // indirect github.com/xtaci/lossyconn v0.0.0-20200209145036-adba10fffc37 // indirect go.opencensus.io v0.22.3 // indirect + golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d // indirect golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect ) diff --git a/proto/demo.go b/proto/demo.go new file mode 100644 index 0000000..323daaf --- /dev/null +++ b/proto/demo.go @@ -0,0 +1,32 @@ +package proto + +type RedisSetRequest struct { +} +type RedisSetResponse struct { + Reply []interface{} +} + +type RedisGetRequest struct { +} +type RedisGetResponse struct { + Reply []interface{} +} + +type MysqlInsertRequest struct { +} +type MysqlInsertResponse struct { + Reply []interface{} +} + +type MysqlSelectRequest struct { +} +type MysqlSelectResponse struct { + Reply []interface{} +} + +type MysqlDeleteRequest struct { +} +type MysqlDeleteResponse struct { + Reply []interface{} +} + diff --git a/proto/odin.go b/proto/odin.go new file mode 100644 index 0000000..8a600a3 --- /dev/null +++ b/proto/odin.go @@ -0,0 +1,39 @@ +package proto + +type SayHelloRequest struct { + Greeting string +} + +type SayHelloResponse struct { + Reply string +} + +type UserInfoRequest struct { + Id int +} + +type UserInfoResponse struct { + Name string + Age int + City string +} + +type AddUserRequest struct { + Name string + Age int + City string +} + +type AddUserResponse struct { + Id int +} + +type UpdateUserRequest struct { + Id int + Name string + Age int + City string +} + +type UpdateUserResponse struct { +} diff --git a/proto/proto.go b/proto/proto.go deleted file mode 100644 index 0d5a634..0000000 --- a/proto/proto.go +++ /dev/null @@ -1,80 +0,0 @@ -package proto - -type SayHelloRequest struct { - Greeting string -} - -type SayHelloResponse struct { - Reply string -} - -type MatrixHelloRequest struct { - Greeting string -} - -type MatrixHelloResponse struct { - Reply string -} - -type UserInfoRequest struct { - Id int -} - -type UserInfoResponse struct { - Name string - Age int - City string -} - -type AddUserRequest struct { - Name string - Age int - City string -} - -type AddUserResponse struct { - Id int -} - -type UpdateUserRequest struct { - Id int - Name string - Age int - City string -} - -type UpdateUserResponse struct { -} - -type RedisSetRequest struct { -} - -type RedisSetResponse struct { - Reply []string -} - -type RedisGetRequest struct { -} - -type RedisGetResponse struct { - Reply []string -} - -type MysqlInsertRequest struct { -} - -type MysqlInsertResponse struct { -} - -type MysqlSelectRequest struct { -} - -type MysqlSelectResponse struct { - Reply []interface{} -} - -type MysqlDeleteRequest struct { -} - -type MysqlDeleteResponse struct { -}