Skip to content

Commit

Permalink
Merge pull request #47 from hb-chen/master
Browse files Browse the repository at this point in the history
update doc
  • Loading branch information
hb-chen authored Jan 17, 2020
2 parents a621199 + 6f312f4 commit 850fef1
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 53 deletions.
99 changes: 51 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,62 @@
- [控制台示例](/console#目录)
- 以最常见的登录流程为例,实现一个场景简单,但包含微服务各种治理能力的示例
- [Hipster Shop示例](/hipstershop)
- 参考[GoogleCloudPlatform/microservices-demo](https://github.com/GoogleCloudPlatform/microservices-demo/)实现先一个业务场景比较复杂的微服务应用
- [目标](#目标)
- [目录结构](#目录结构)
- 参考[GoogleCloudPlatform/microservices-demo](https://github.com/GoogleCloudPlatform/microservices-demo/)实现一个业务场景比较复杂的微服务应用
- [架构设计](#架构设计)
- [目录结构](#目录结构)
- [目标功能](#目标功能)
- [开发环境](#开发环境)
- [部署环境](#部署环境)
- [参与贡献](#参与贡献)

## 目标
## 架构设计

### 系统架构图
<img src="/doc/img/architecture.png" width="50%">

### 业务架构图

**[Console示例](/console)**

<img src="/doc/img/console-design.png" width="50%">

- [Hipster Shop示例](/hipstershop)
- 参考[GoogleCloudPlatform/microservices-demo](https://github.com/GoogleCloudPlatform/microservices-demo/)

**领域模型&整洁架构参考**
- [Clean Architecture in go](https://medium.com/@hatajoe/clean-architecture-in-go-4030f11ec1b1)
- [基于 DDD 的微服务设计和开发实战](https://www.infoq.cn/article/s_LFUlU6ZQODd030RbH9)
- [当中台遇上 DDD,我们该如何设计微服务?](https://www.infoq.cn/article/7QgXyp4Jh3-5Pk6LydWw)

## 目录结构

```bash
├── console 控制台示例
│   ├── account go.micro.srv.account,Account服务
│ │   ├── domain 领域
│   │   │   ├── model 模型
│ │   │   ├── repository 存储接口
│ │ │   │   └── persistence ①存储接口实现
│ │   │   └── service 领域服务
│ │   ├── interface 接口
│ │   │   ├── handler micro handler接口
│ │   │   └── persistence ②存储接口实现
│ │   ├── registry 依赖注入,根据使用习惯,一般Go中不怎么喜欢这种方式
│ │   └── usecase 应用用例
│ │   ├── event 消息事件
│ │   └── service 应用服务
│   ├── api go.micro.api.console,API服务
│   ├── pb 服务协议统一.proto
│   └── web go.micro.api.console,Web服务,集成gin、echo、iris等web框架
├── deploy 部署
│   ├── docker
│   └── k8s
├── doc 文档资源
├── gateway 网关,自定义micro
└── pkg 公共资源包
```

## 目标功能

- 自定义[micro网关](gateway)
- [x] `JWT`认证
Expand Down Expand Up @@ -81,50 +128,6 @@
- Jaeger
- ...

## 目录结构

```bash
├── console 控制台示例
│   ├── account go.micro.srv.account,Account服务
│ │   ├── domain 领域
│   │   │   ├── model 模型
│ │   │   ├── repository 存储接口
│ │ │   │   └── persistence ①存储接口实现
│ │   │   └── service 领域服务
│ │   ├── interface 接口
│ │   │   ├── handler micro handler接口
│ │   │   └── persistence ②存储接口实现
│ │   ├── registry 依赖注入,根据使用习惯,一般Go中不怎么喜欢这种方式
│ │   └── usecase 应用用例
│ │   ├── event 消息事件
│ │   └── service 应用服务
│   ├── api go.micro.api.console,API服务
│   ├── pb 服务协议统一.proto
│   └── web go.micro.api.console,Web服务,集成gin、echo、iris等web框架
├── deploy 部署
│   ├── docker
│   └── k8s
├── doc 文档资源
├── gateway 网关,自定义micro
└── pkg 公共资源包
```

## 架构设计

### 系统架构图
<img src="/doc/img/architecture.png" width="50%">

### 业务架构图

- [Console示例](/console)
- [Hipster Shop示例](/hipstershop)
- 参考[GoogleCloudPlatform/microservices-demo](https://github.com/GoogleCloudPlatform/microservices-demo/)

**领域模型&整洁架构参考**
- [Clean Architecture in go](https://medium.com/@hatajoe/clean-architecture-in-go-4030f11ec1b1)
- [基于 DDD 的微服务设计和开发实战](https://www.infoq.cn/article/s_LFUlU6ZQODd030RbH9)
- [当中台遇上 DDD,我们该如何设计微服务?](https://www.infoq.cn/article/7QgXyp4Jh3-5Pk6LydWw)

## 开发环境

*TODO*
Expand Down
4 changes: 4 additions & 0 deletions console/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@

## 目录

- [架构](#架构)
- [快速开始](#快速开始)
- [Docker Compose启动](#docker-compose启动)`推荐`
- [编译启动](#编译启动)
- [服务测试](#服务测试)
- [Proto管理](#proto管理)

## 架构
<img src="/doc/img/console-design.png" width="75%">

## 快速开始
### Docker Compose启动

Expand Down
2 changes: 1 addition & 1 deletion console/web/beego/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

//New return a beego handler
func New() (http.Handler, error) {
beego.Get("/console/v1/beego", func(ctx *bctx.Context) {
beego.Get("/v1/beego", func(ctx *bctx.Context) {
log.Info("Received Get Request")
ctx.Output.JSON(map[string]string{
"message": "BeeGo Here",
Expand Down
2 changes: 1 addition & 1 deletion console/web/echo/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func New() (http.Handler, error) {
e.Use(middleware.Recover())

// Routes
r := e.Group("/console/v1/echo")
r := e.Group("/v1/echo")
r.GET("/", func(ctx echo.Context) error {
return ctx.JSON(200, echo.Map{
"message": "Hello Echo",
Expand Down
2 changes: 1 addition & 1 deletion console/web/gin/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

func New() (http.Handler, error) {
g := gin.Default()
r := g.Group("/console/v1/gin")
r := g.Group("/v1/gin")
r.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "Hello Gin",
Expand Down
2 changes: 1 addition & 1 deletion console/web/iris/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func New() (http.Handler, error) {
app.Use(recover.New())
app.Use(logger.New())

v1 := app.Party("/console/v1/iris")
v1 := app.Party("/v1/iris")
{
v1.Get("/", func(ctx iris.Context) {
ctx.JSON(iris.Map{"message": "Hello Iris!"})
Expand Down
2 changes: 1 addition & 1 deletion console/web/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func main() {
}

// 链路追踪
t, closer, err := tracer.NewJaegerTracer("go.micro.web.console", "127.0.0.1:6831")
t, closer, err := tracer.NewJaegerTracer("go.micro.api.console", "127.0.0.1:6831")
if err != nil {
log.Fatalf("opentracing tracer create error:%v", err)
}
Expand Down
Binary file added doc/img/console-design.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 850fef1

Please sign in to comment.