Skip to content

Commit

Permalink
Merge pull request #6 from sixiaobai/master
Browse files Browse the repository at this point in the history
依赖组件升级&大小写调整&demo演示支持
  • Loading branch information
wgffgw authored Sep 26, 2020
2 parents 97a210c + f509a30 commit 73a947c
Show file tree
Hide file tree
Showing 15 changed files with 134 additions and 143 deletions.
24 changes: 13 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Odin

<p align="center">
<a href="https://tal-tech.github.io/odin-doc/" target="_blank">
<img src="https://xesftp.oss-cn-beijing.aliyuncs.com/oa/res/odin.jpg?raw=true" alt="Odin Logo" align=center />
Expand All @@ -22,11 +20,11 @@ Odin框架是好未来在使用rpcx框架过程中不断完善、改进的,目

[中文文档](https://www.yuque.com/tal-tech/odin)

## Introduction
## 简介

Odin是基于go语言的rpc框架,框架除了致力于提供高性能的服务间调用能力外,也提供完善的服务治理功能、支持多种服务注册发现机制。为了业务方使用框架更加便捷,框架还具有配套管理工具自动生成代码,提高开发效率。

## Features
## 特性

### 高性能
首先,框架底层基于rpcx框架,其是一个纯Go语言的rpc框架,与主流rpc框架进行性能对比,优势明显。其性能仅弱于Go原生rpc调用。
Expand All @@ -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
Expand All @@ -83,7 +85,7 @@ addrs=127.0.0.1:2181
basePath=/odin_demo
```

## Example
## 运行
```
rigger example zookeeper
//Output
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions app/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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服务注册类型
Expand Down Expand Up @@ -111,3 +110,4 @@ func (this *Odin) MysqlDelete(ctx context.Context, req *proto.MysqlDeleteRequest
}
return this.Wrapcall(ctx, "MysqlDelete", fn)
}

11 changes: 6 additions & 5 deletions app/service/serviceBridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package serviceImpl
import (
"context"
"fmt"

"odin/proto"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
18 changes: 9 additions & 9 deletions conf/conf.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
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]
status=off

;Registry Address
addrs=127.0.0.1:2181
basePath=/odin_demo
basePath=/tal_tech
updateInterval=1m

[Expvar]
Expand Down
18 changes: 9 additions & 9 deletions conf/conf_dev.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions conf/conf_online.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions conf/conf_release.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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
Expand All @@ -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
)
32 changes: 32 additions & 0 deletions proto/demo.go
Original file line number Diff line number Diff line change
@@ -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{}
}

39 changes: 39 additions & 0 deletions proto/odin.go
Original file line number Diff line number Diff line change
@@ -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 {
}
Loading

0 comments on commit 73a947c

Please sign in to comment.