Skip to content

Commit

Permalink
rename Gateway to Manba
Browse files Browse the repository at this point in the history
* replace Gateway to Manba
* update excute file name with prefix `manba-`
  • Loading branch information
archfish committed Dec 28, 2019
1 parent 3819b9f commit adb3136
Show file tree
Hide file tree
Showing 14 changed files with 99 additions and 93 deletions.
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
[![Build Status](https://api.travis-ci.org/fagongzi/gateway.svg)](https://travis-ci.org/fagongzi/gateway)
[![Go Report Card](https://goreportcard.com/badge/github.com/fagongzi/gateway)](https://goreportcard.com/report/github.com/fagongzi/gateway)

Gateway/[简体中文](README_CN.md)
Manba/[简体中文](README_CN.md)
-------
Gateway is a restful API gateway based on HTTP, which can be used as a unified API access layer.
Manba is a restful API gateway based on HTTP, which can be used as a unified API access layer.

## Tutorial
A very detailed tutorial for beginners. [Link](./docs/tutorial.md)
Below are video tutorials.
Basics:
[![](https://img.youtube.com/vi/2qMWmdcw7o4/0.jpg)](https://www.youtube.com/watch?v=2qMWmdcw7o4)
A very detailed tutorial for beginners. [Link](./docs/tutorial.md)
Below are video tutorials.
Basics:
[![](https://img.youtube.com/vi/2qMWmdcw7o4/0.jpg)](https://www.youtube.com/watch?v=2qMWmdcw7o4)

Alternative bilibili.com video link: https://www.bilibili.com/video/av73432556/

Routing Configuration Tutorial:
[![](https://img.youtube.com/vi/D1pI6opB_ks/0.jpg)](https://www.youtube.com/watch?v=D1pI6opB_ks)
Routing Configuration Tutorial:
[![](https://img.youtube.com/vi/D1pI6opB_ks/0.jpg)](https://www.youtube.com/watch?v=D1pI6opB_ks)

Alternative bilibili.com video link: https://www.bilibili.com/video/av73432836/

JWT Plugin Configuration Tutorial:
[![](https://img.youtube.com/vi/sLb16YDSlBs/0.jpg)](https://www.youtube.com/watch?v=sLb16YDSlBs)
JWT Plugin Configuration Tutorial:
[![](https://img.youtube.com/vi/sLb16YDSlBs/0.jpg)](https://www.youtube.com/watch?v=sLb16YDSlBs)

Alternative bilibili.com video link: https://www.bilibili.com/video/av73433002/

Expand Down Expand Up @@ -56,8 +56,8 @@ Please make sure your Go version is 1.10 or above. Otherwise, **undefined "math/
The following content requires reader some knowledge of Docker. You can refer to [this book][2], or check out [the official documentation][1]

### Quick Start
Use `docker pull fagongzi/gateway` command to download gateway Docker image.
`docker run -d -p 9093:9093 -p 80:80 -p 9092:9092 fagongzi/gateway` initiates the container. 3 Ports are exposed:
Use `docker pull fagongzi/manba` command to download Manba Docker image.
`docker run -d -p 9093:9093 -p 80:80 -p 9092:9092 fagongzi/manba` initiates the container. 3 Ports are exposed:

* 80

Expand Down Expand Up @@ -107,23 +107,23 @@ Use `http://127.0.0.1` to access to your API
![](./images/arch.png)

## Web UI
Available Gateway Web UI Projects:
Available Manba Web UI Projects:
* [Official](https://github.com/fagongzi/gateway-ui-vue)
* [gateway_ui](https://github.com/archfish/gateway_ui)
* [gateway_ui (v2.x ONLY)](https://github.com/archfish/gateway_ui)
* [gateway_admin_ui](https://github.com/wilehos/gateway_admin_ui)

## Components
Gateway consists of `proxy` and `apiserver`.
Manba consists of `proxy` and `apiserver`.

### Proxy
Proxy is a component which provides service to clients. Proxy is a stateless node. Multiple proxies can be deployed to handle huge traffic.
[More](./docs/proxy.md).

### ApiServer
ApiServer provides GRPC and Restful to manage metadata for users. ApiServer integrates official Web UI.
ApiServer provides GRPC and Restful to manage metadata for users. ApiServer integrates official Web UI.
[More](./docs/apiserver.md).

## Concepts of Gateway
## Concepts of Manba
### Server
A server is a a real backend service.
[More](./docs/server.md).
Expand All @@ -133,7 +133,7 @@ Cluster consists of servers which provide the same service. A server is chosen t
[More](./docs/cluster.md).

### API
API is a key concept of Gateway. We can manage external APIs in Gateway and their distribution rules, aggregation rules and URL matching rules.
API is a key concept of Manba. We can manage external APIs in Manba and their distribution rules, aggregation rules and URL matching rules.
[More](./docs/api.md).

### Routing
Expand Down
14 changes: 7 additions & 7 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
[![Build Status](https://api.travis-ci.org/fagongzi/gateway.svg)](https://travis-ci.org/fagongzi/gateway)
[![Go Report Card](https://goreportcard.com/badge/github.com/fagongzi/gateway)](https://goreportcard.com/report/github.com/fagongzi/gateway)

Gateway/[English](./README.md)
Manba/[English](./README.md)
-------
Gateway 是一个基于HTTP协议的restful的API网关。可以作为统一的API接入层。
Manba是一个基于HTTP协议的restful的API网关。可以作为统一的API接入层。

## 教程
如果你是一个初学者,那么这个[详细的教程](./docs/tutorial.md)非常适合你。现在只有英文版本。
Expand Down Expand Up @@ -40,7 +40,7 @@ Gateway 是一个基于HTTP协议的restful的API网关。可以作为统一的A
以下内容要求对docker基本操作有一定了解,可以看[这本书][2],或者直接看[官方文档][1]

### 快速开始
使用 `docker pull fagongzi/gateway` 命令下载Docker镜像, 使用 `docker run -d -p 9093:9093 -p 80:80 -p 9092:9092 fagongzi/gateway` 运行镜像. 镜像启动后export 3个端口:
使用 `docker pull fagongzi/manba` 命令下载Docker镜像, 使用 `docker run -d -p 9093:9093 -p 80:80 -p 9092:9092 fagongzi/manba` 运行镜像. 镜像启动后export 3个端口:

* 80

Expand Down Expand Up @@ -91,9 +91,9 @@ docker-compose up -d
![](./images/arch.png)

## WebUI
可用的Gateway的WebUI的项目
可用的Manba的WebUI的项目
* [官方](https://github.com/fagongzi/gateway-ui-vue)
* [gateway_ui](https://github.com/archfish/gateway_ui)
* [gateway_ui(仅适配2.x)](https://github.com/archfish/gateway_ui)
* [gateway_admin_ui](https://github.com/wilehos/gateway_admin_ui)

## 组件
Expand All @@ -105,15 +105,15 @@ Proxy是Gateway对终端用户提供服务的组件,Proxy是一个无状态的
### ApiServer
ApiServer对外提供GRPC和Restful来管理元信息,ApiServer同时集成了官方的WebUI,[更多](./docs-cn/apiserver.md)

## Gateway中的概念
## Manba中的概念
### Server
Server是一个真实的后端服务,[更多](./docs-cn/server.md)

### Cluster
Cluster是一个逻辑概念,它由一组提供相同服务的Server组成。会依据负载均衡策略选择一个可用的Server,[更多](./docs-cn/cluster.md)

### API
API是Gateway的核心概念,我们可以在Gateway的中维护对外的API,以及API的分发规则,聚合规则以及URL匹配规则,[更多](./docs-cn/api.md)
API是Manba的核心概念,我们可以在Manba的中维护对外的API,以及API的分发规则,聚合规则以及URL匹配规则,[更多](./docs-cn/api.md)

### Routing
Routing是一个路由策略,根据HTTP Request中的Cookie,Querystring、Header、Path中的一些信息把流量分发到或者复制到指定的Cluster,通过这个功能,我们可以实现AB Test和线上引流,[更多](./docs-cn/routing.md)
Expand Down
3 changes: 1 addition & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Roadmap
这个文档定义了Gateway的roadmap.
这个文档定义了Manba的roadmap.

## Features
- [x] 在线流量复制
Expand All @@ -15,4 +15,3 @@
- [ ] SpringCloud协议转换插件
- [ ] Dubbo协议转换插件
- [ ] Grpc协议转换插件

16 changes: 8 additions & 8 deletions docs-cn/api.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
API
-----------
API是Gateway的核心概念。可以通过Gateway的API-Server管理API。
API是Manba的核心概念。可以通过Manba的API-Server管理API。

# API属性
## ID
Expand All @@ -10,7 +10,7 @@ API的ID,唯一标识一个API。
API的名称。

## URLPattern
URL匹配表达式,Gateway使用该字段来匹配原始请求的URL。该字段必须和`Method`配合使用,同时满足才算这个请求匹配了这个API。
URL匹配表达式,Manba使用该字段来匹配原始请求的URL。该字段必须和`Method`配合使用,同时满足才算这个请求匹配了这个API。

### URLPattern表达式
定义API的`URL`,使用`/`来分割URL Path的每个部分,每个部分可以这些类型:
Expand All @@ -22,7 +22,7 @@ URL匹配表达式,Gateway使用该字段来匹配原始请求的URL。该字
* 如果需要使用这些变量(例如在URL Rewrite的时候)可以使用:
* (number):id 变量名称为id
* (string):name 变量名称为name
* (enum:on|off):action 变量名称为action
* (enum:on|off):action 变量名称为action

一些例子:
* `/api/v1/product/(number):id`
Expand All @@ -48,7 +48,7 @@ API 状态枚举, 有2个值组成: `UP` 和 `Down`。只有`UP`状态才能
IP的访问控制,有黑白名单2个部门组成。

## DefaultValue(可选)
API的默认返回值,当后端Cluster无可用Server的时候,Gateway将返回这个默认值,默认值由Code、HTTP Body、Header、Cookie组成。可以用来做Mock或者后端服务故障时候的默认返回。
API的默认返回值,当后端Cluster无可用Server的时候,Manba将返回这个默认值,默认值由Code、HTTP Body、Header、Cookie组成。可以用来做Mock或者后端服务故障时候的默认返回。

## 聚合请求
聚合请求是原始请求转发到多个后端Server,并且把多个返回结果合并成一个JSON返回,并且可以指定每个转发请求的结果在最终JSON对象中的属性名称。多个转发请求可以同时发送,也可以按批次发送(后面请求参数依赖前面请求的返回值)。使用`BatchIndex`来设置每个转发请求的顺序。
Expand Down Expand Up @@ -154,19 +154,19 @@ API匹配时按该值的升序匹配,即值越小优先级越高。默认值
websocket选项,设置该API为`websocket`,注意:`websocket特性还处于试验阶段,默认关闭,可以使用--websocket启用特性`。网关转发websocket的时候,`Origin`默认使用后端Server的地址,如果需要设置特殊值,可以指定`Origin`参数。

## MaxQPS(可选)
API能够支持的最大QPS,用于流控。Gateway采用令牌桶算法,根据QPS限制流量,保护后端API被压垮。API的优先级高于`Server`的配置
API能够支持的最大QPS,用于流控。Manba采用令牌桶算法,根据QPS限制流量,保护后端API被压垮。API的优先级高于`Server`的配置

## CircuitBreaker(可选)
熔断器,设置后端API的熔断规则,API的优先级高于`Server`的配置。熔断器分为3个状态:

* Open

Open状态,正常状态,Gateway放入全部流量。当Gateway发现失败的请求比例达到了设置的规则,熔断器会把状态切换到Close状态
Open状态,正常状态,Manba放入全部流量。当Manba发现失败的请求比例达到了设置的规则,熔断器会把状态切换到Close状态

* Half

Half状态,尝试恢复的状态。在这个状态下,Gateway会尝试放入一定比例的流量,然后观察这些流量的请求的情况,如果达到预期就把状态转换为Open状态,如果没有达到预期,恢复成Close状态
Half状态,尝试恢复的状态。在这个状态下,Manba会尝试放入一定比例的流量,然后观察这些流量的请求的情况,如果达到预期就把状态转换为Open状态,如果没有达到预期,恢复成Close状态

* Close

Close状态,在这个状态下,Gateway禁止任何流量进入这个后端Server,在达到指定的阈值时间后,Gateway自动尝试切换到Half状态,尝试恢复。
Close状态,在这个状态下,Manba禁止任何流量进入这个后端Server,在达到指定的阈值时间后,Manba自动尝试切换到Half状态,尝试恢复。
10 changes: 5 additions & 5 deletions docs-cn/apiserver.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ApiServer
--------------
ApiServer对外提供GRPC接口,用来管理Gateway的元信息(Cluster、Server、Routing以及API)。
ApiServer对外提供GRPC接口,用来管理Manba的元信息(Cluster、Server、Routing以及API)。

# 对外开放的接口:
```
Expand All @@ -10,22 +10,22 @@ service MetaService {
rpc RemoveCluster (RemoveClusterReq) returns (RemoveClusterRsp) {}
rpc GetCluster (GetClusterReq) returns (GetClusterRsp) {}
rpc GetClusterList (GetClusterListReq) returns (stream metapb.Cluster) {}
rpc PutServer (PutServerReq) returns (PutServerRsp) {}
rpc RemoveServer (RemoveServerReq) returns (RemoveServerRsp) {}
rpc GetServer (GetServerReq) returns (GetServerRsp) {}
rpc GetServerList (GetServerListReq) returns (stream metapb.Server) {}
rpc PutAPI (PutAPIReq) returns (PutAPIRsp) {}
rpc RemoveAPI (RemoveAPIReq) returns (RemoveAPIRsp) {}
rpc GetAPI (GetAPIReq) returns (GetAPIRsp) {}
rpc GetAPIList (GetAPIListReq) returns (stream metapb.API) {}
rpc PutRouting (PutRoutingReq) returns (PutRoutingRsp) {}
rpc RemoveRouting (RemoveRoutingReq) returns (RemoveRoutingRsp) {}
rpc GetRouting (GetRoutingReq) returns (GetRoutingRsp) {}
rpc GetRoutingList (GetRoutingListReq) returns (stream metapb.Routing) {}
rpc AddBind (AddBindReq) returns (AddBindRsp) {}
rpc RemoveBind (RemoveBindReq) returns (RemoveBindRsp) {}
rpc RemoveClusterBind (RemoveClusterBindReq) returns (RemoveClusterBindRsp) {}
Expand Down
2 changes: 1 addition & 1 deletion docs-cn/benchmark.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

## Code

- gateway -version
- manba-proxy -version

```log
GitCommit: f4e8226
Expand Down
42 changes: 22 additions & 20 deletions docs-cn/build.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
搭建Gateway环境
搭建Manba环境
------------------------
这个章节帮助你搭建Gateway环境
这个章节帮助你搭建Manba环境

# 准备
## Etcd
Gateway目前支持Etcd作为元数据区的存储,所以需要一个Etcd环境,参考:[etcd environment](https://github.com/coreos/etcd)
Manba目前支持Etcd作为元数据区的存储,所以需要一个Etcd环境,参考:[etcd environment](https://github.com/coreos/etcd)


## Golang
如果你希望从源码编译Gateway,你需要一个[golang 环境](https://github.com/golang/go),必须使用`1.11`及以上的版本。
如果你希望从源码编译Manba,你需要一个[golang 环境](https://github.com/golang/go),必须使用`1.11`及以上的版本。

# 从源码编译
- 使用Makefile脚本

以下命令默认在项目根目录(即`$GOPATH/src/github.com/fagongzi/gateway`)目录下执行。
以下命令默认在项目根目录(即`$GOPATH/src/github.com/fagongzi/manba`)目录下执行。

- 编译适合当前系统的二进制文件

Expand Down Expand Up @@ -59,21 +59,24 @@ Gateway目前支持Etcd作为元数据区的存储,所以需要一个Etcd环
make help
```

# Gateway组件
Gateway运行环境包含2个组件:`ApiServer``Proxy`
# Manba组件

Manba运行环境包含2个组件:`ApiServer``Proxy`

* ApiServer
对外提供API管理元数据。

可执行文件`manba-apiserver`,对外提供API管理元数据。

* Proxy
Proxy是一个无状态的API代理,提供给终端用户直接访问。

可执行文件`manba-proxy`,Proxy是一个无状态的API代理,提供给终端用户直接访问。

## ApiServer
ApiServer 对外提供GRPC的服务,用来管理Gateway的元数据
ApiServer对外提供GRPC的服务,用来管理Manba的元数据。

```bash
$ ./apiserver --help
Usage of ./apiserver:
$ ./manba-apiserver --help
Usage of ./manba-apiserver:
-addr string
Addr: client entrypoint (default "127.0.0.1:9091")
-addr-store string
Expand All @@ -99,13 +102,12 @@ Usage of ./apiserver:
`discovery`参数用来是否使用服务发现的方式发布ApiServer提供的对外接口
`namespace`参数用来隔离多个环境,这个配置需要和对应的`Proxy``namespace`一致


## proxy
Proxy是内部所有API的统一对外入口,也就是API统一接入层。

```bash
$ ./proxy --help
Usage of ./proxy:
$ ./manba-proxy --help
Usage of ./manba-proxy:
-addr string
Addr: http request entrypoint (default "127.0.0.1:80")
-addr-pprof string
Expand Down Expand Up @@ -153,7 +155,7 @@ Usage of ./proxy:
`namespace`参数用来隔离多个环境,这个配置需要和对应的`ApiServer``namespace`一致

# 运行环境
我们以三台etcd、一台ApiServer,三台Proxy的环境为例
我们以三台etcd、一台ApiServer三台Proxy的环境为例

## 环境信息

Expand All @@ -165,22 +167,22 @@ Usage of ./proxy:

## 启动Proxy
```bash
./proxy --addr=192.168.1.200:80 --addr-rpc=192.168.1.200:9091 --addr-store=etcd://192.168.1.100:2379,192.168.1.101:2379,192.168.1.102:2379 --namespace=test
./manba-proxy --addr=192.168.1.200:80 --addr-rpc=192.168.1.200:9091 --addr-store=etcd://192.168.1.100:2379,192.168.1.101:2379,192.168.1.102:2379 --namespace=test
```

```bash
./proxy --addr=192.168.1.201:80 --addr-rpc=192.168.1.201:9091 --addr-store=etcd://192.168.1.100:2379,192.168.1.101:2379,192.168.1.102:2379 --namespace=test
./manba-proxy --addr=192.168.1.201:80 --addr-rpc=192.168.1.201:9091 --addr-store=etcd://192.168.1.100:2379,192.168.1.101:2379,192.168.1.102:2379 --namespace=test
```

```bash
./proxy --addr=192.168.1.202:80 --addr-rpc=192.168.1.202:9091 --addr-store=etcd://192.168.1.100:2379,192.168.1.101:2379,192.168.1.102:2379 --namespace=test
./manba-proxy --addr=192.168.1.202:80 --addr-rpc=192.168.1.202:9091 --addr-store=etcd://192.168.1.100:2379,192.168.1.101:2379,192.168.1.102:2379 --namespace=test
```

用户的API接入地址可以为:192.168.1.201:80、192.168.1.201:80、192.168.1.202:80其中任意一个

## 启动ApiServer
```bash
./apiserver --addr=192.168.1.203:9091 --addr-store=etcd://192.168.1.100:2379,192.168.1.101:2379,192.168.1.102:2379 --discovery --namespace=test
./manba-apiserver --addr=192.168.1.203:9091 --addr-store=etcd://192.168.1.100:2379,192.168.1.101:2379,192.168.1.102:2379 --discovery --namespace=test
```

## 调用ApiServer创建元信息
Expand Down
4 changes: 2 additions & 2 deletions docs-cn/cluster.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Cluster
-------
在Gateway中,Cluster是一个逻辑的概念。它是后端真实Server的一个逻辑组,在同一个组内的后端Server提供相同的服务。
在Manba中,Cluster是一个逻辑的概念。它是后端真实Server的一个逻辑组,在同一个组内的后端Server提供相同的服务。

# Cluster属性
一个Cluster包含2部分信息:
Expand All @@ -11,4 +11,4 @@ Cluster ID, 全局唯一。
Cluster名称

## LoadBalance
Cluster采取的负载均衡算法。
Cluster采取的负载均衡算法。
4 changes: 2 additions & 2 deletions docs-cn/optimization.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Optimization
Gateway网关在使用的时候有一些地方需要做一些优化,以便达到更好的性能。这里给出一些优化配置的意见。
Manba网关在使用的时候有一些地方需要做一些优化,以便达到更好的性能。这里给出一些优化配置的意见。

### Docker
在使用docker启动`Proxy`镜像的时候,由于默认的镜像的`somaxconn`是默认值`128`,docker 启动的时候加上如下参数:
Expand All @@ -24,4 +24,4 @@ Proxy默认回启用Keepalive来保持和后端服务的链接,这里有2个
这个参数是用来控制`Proxy`与每个后端建立的最大链接数,如果发现某个后端Server的并发非常高,延迟较大,有可能时间花费了等待空闲链接的操作上,可以适当调大这个值。

### limit-caching
这个参数控制单个`Proxy`使用多少内存来做缓存,如果`Proxy`中的API开启了缓存,那么可以通过这个参数控制缓存大小。
这个参数控制单个`Proxy`使用多少内存来做缓存,如果`Proxy`中的API开启了缓存,那么可以通过这个参数控制缓存大小。
Loading

0 comments on commit adb3136

Please sign in to comment.