Skip to content

Commit

Permalink
Merge pull request apache#1 from dubbogo/develop
Browse files Browse the repository at this point in the history
sync fork

Former-commit-id: ef9e1db [formerly c0a3c15]
Former-commit-id: 288b04c
  • Loading branch information
ztelur authored Jan 19, 2021
2 parents 4adab4a + 26aac7a commit 1f7a957
Show file tree
Hide file tree
Showing 114 changed files with 5,440 additions and 879 deletions.
25 changes: 19 additions & 6 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,25 @@ dubbo-go-proxy支持2种协议的调用:
2. [Dubbo协议调用](https://github.com/dubbogo/dubbo-go-proxy/blob/develop/docs/sample/dubbo.md)

## 特性
1. dubbo-go-proxy 有完善的插件机制可以支持自定义的扩展
2. 正如其它的网关一样,主要来做流量和接口的治理
3. 兼容 java 和 go 的 dubbo 及 Spring Cloud(HTTP)
4. 支持传统的网关自定义映射外,还支持自动识别注册中心的 RPC 服务暴露 HTTP 接口
4. 能支持边车和集中部署(规划中)
5. istio 下支持 dubbo 协议流量(规划中)
- 多协议支持
- HTTP 代理,基于官方 net/http 包
- Dubbo 代理,基于 [dubbogo](https://github.com/apache/dubbo-go) (1.5.5) 泛化调用
- 多形式的 Dubbo 配置
- 标准的 API 接口配置:配置 API 到 Dubbo 之间的关系
- 通用的 API 接口配置:把请求的接口信息通过 POST 请求携带过来转换(兼顾[dubbo-proxy](https://github.com/apache/dubbo-proxy)
- 动态特性
- 路由重写,支持请求发送到上游之前重写 host, uri, schema,headers(开发中)
- 超时控制
- 限流熔断(开发中)
- 插件机制(开发中)
- 路由匹配
- 支持传统的网关接口自定义映射外,还支持自动识别注册中心的 RPC 服务暴露 HTTP 接口(开发中)
- 控制面板(开发中)
- 安全
- IP 黑白名单
- 云原生支持
- istio 下支持 dubbo 协议流量(规划中)
- 能支持边车和集中部署(规划中)

## 架构图
![image](https://raw.githubusercontent.com/dubbogo/dubbo-go-proxy/master/docs/images/dubbgoproxy-infrastructure.png)
Expand Down
12 changes: 11 additions & 1 deletion cmd/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,25 @@
package main

import (
_ "net/http/pprof"
"os"
"strconv"
"time"
)

import (
_ "github.com/apache/dubbo-go/common/proxy/proxy_factory"
_ "github.com/apache/dubbo-go/metadata/service/inmemory"
"github.com/urfave/cli"
_ "net/http/pprof"
)

import (
_ "github.com/dubbogo/dubbo-go-proxy/pkg/filter/accesslog"
_ "github.com/dubbogo/dubbo-go-proxy/pkg/filter/logger"
_ "github.com/dubbogo/dubbo-go-proxy/pkg/filter/recovery"
_ "github.com/dubbogo/dubbo-go-proxy/pkg/filter/remote"
_ "github.com/dubbogo/dubbo-go-proxy/pkg/filter/response"
_ "github.com/dubbogo/dubbo-go-proxy/pkg/filter/timeout"
)

// Version proxy version
Expand Down
61 changes: 28 additions & 33 deletions configs/api_config.yaml
Original file line number Diff line number Diff line change
@@ -1,43 +1,38 @@
name: api name
description: api description
name: proxy
description: proxy sample
resources:
- path: '/'
- path: '/api/v1/test-dubbo/user'
type: restful
description: resource documentation
filters:
- filter0
description: user
methods:
- httpVerb: GET
onAir: true
timeout: 1000ms
inboundRequest:
requestType: http
queryStrings:
- name: id
required: false
- name: name
required: true
integrationRequest:
requestType: dubbo
requestType: http
host: 127.0.0.1:8889
path: /UserProvider/GetUserByName
mappingParams:
- name: queryStrings.id
mapTo: 1
applicationName: "BDTService"
interface: "com.ikurento.user.UserProvider"
method: "GetUser"
clusterName: "test_dubbo"

definitions:
- name: modelDefinition
schema: >-
{
"type" : "object",
"properties" : {
"id" : {
"type" : "integer"
},
"type" : {
"type" : "string"
},
"price" : {
"type" : "number"
}
}
}
- name: queryStrings.name
mapTo: queryStrings.name
group: "test"
version: 1.0.0
- httpVerb: POST
onAir: true
timeout: 1000ms
inboundRequest:
requestType: http
queryStrings:
- name: name
required: true
integrationRequest:
requestType: http
host: 127.0.0.1:8889
path: /UserProvider/CreateUser
group: "test"
version: 1.0.0
5 changes: 4 additions & 1 deletion configs/conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static_resources:
- name: "X-DGP-WAY"
value: "dubbo"
route:
cluster: "test_dubbo"
cluster: "test-dubbo"
cluster_not_found_response_code: 505
cors:
allow_origin:
Expand Down Expand Up @@ -75,3 +75,6 @@ static_resources:
socket_address:
address: "0.0.0.0"
port: 6060
accessLog:
enable: true
outputpath: C:\Users\60125\Desktop\dubbo-go\logs\dubbo-go-proxy-access
2 changes: 1 addition & 1 deletion docs/developer/filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Response result or err.

#### Common result

[reference](../sample/dubbogo-body.md)
[reference](../sample/dubbo-body.md)

### Host filter

Expand Down
3 changes: 2 additions & 1 deletion docs/sample/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Samples


[中文](./zh-cn/README.md)
* [dubbo](dubbo.md)
* [http](http.md)
* [mock](mock.md)
59 changes: 59 additions & 0 deletions docs/sample/dubbo-body(http).md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Get the parameter from the body

> POST request
## Passthroughs

### Api Config

```yaml
name: proxy
description: proxy sample
resources:
- path: '/api/v1/test-dubbo/user'
type: restful
description: user
methods:
- httpVerb: POST
onAir: true
timeout: 1000ms
inboundRequest:
requestType: http
queryStrings:
- name: name
required: true
integrationRequest:
requestType: http
host: 127.0.0.1:8889
path: /UserProvider/CreateUser
group: "test"
version: 1.0.0
```
### Request
```bash
curl host:port/api/v1/test-dubbo/user -X POST -d '{"name": "tiecheng","id": "0002","code": 3,"age": 18}' --header "Content-Type: application/json"
```
### Response
- If first add, return like:
```json
{
"id": "0002",
"code": 3,
"name": "tiecheng",
"age": 18,
"time": "0001-01-01T00:00:00Z"
}
```

- If you add user multi, return like:

```json
{
"message": "data is exist"
}
```
128 changes: 128 additions & 0 deletions docs/sample/dubbo-body.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Get the parameter from the body

> POST request [samples](https://github.com/dubbogo/dubbo-go-proxy/tree/develop/samples/dubbogo/simple/body)
## Passthroughs

### Api Config

```yaml
name: proxy
description: proxy sample
resources:
- path: '/api/v1/test-dubbo/user'
type: restful
description: user
methods:
- httpVerb: POST
onAir: true
timeout: 10s
inboundRequest:
requestType: http
integrationRequest:
requestType: dubbo
mappingParams:
- name: requestBody._all
mapTo: 0
applicationName: "UserProvider"
interface: "com.dubbogo.proxy.UserService"
method: "CreateUser"
paramTypes: [ "object" ]
group: "test"
version: 1.0.0
clusterName: "test_dubbo"
- httpVerb: PUT
onAir: true
timeout: 10s
inboundRequest:
requestType: http
integrationRequest:
requestType: dubbo
mappingParams:
- name: requestBody._all
mapTo: 0
applicationName: "UserProvider"
interface: "com.dubbogo.proxy.UserService"
method: "UpdateUser"
paramTypes: [ "object" ]
group: "test"
version: 1.0.0
clusterName: "test_dubbo"
- path: '/api/v1/test-dubbo/user2'
type: restful
description: user
methods:
- httpVerb: PUT
onAir: true
timeout: 1000ms
inboundRequest:
requestType: http
integrationRequest:
requestType: dubbo
mappingParams:
- name: requestBody.name
mapTo: 0
- name: requestBody.user
mapTo: 1
applicationName: "UserService"
interface: "com.dubbogo.proxy.UserService"
method: "UpdateUserByName"
paramTypes: [ "string", "object" ]
group: "test"
version: 1.0.0
clusterName: "test_dubbo"
```
> when passthroughs, mapTo: 0 needed
### Test
- passthroughs
```bash
curl host:port/api/v1/test-dubbo/user -X POST -d '{"id":"0003","code":3,"name":"dubbogo","age":99}' --header "Content-Type: application/json"
```
If first add, return like:
```json
{
"age": 99,
"code": 3,
"iD": "0003",
"name": "dubbogo"
}
```
If you add user multi, return like:

```json
{
"message": "data is exist"
}
```

- update

```bash
curl host:port/api/v1/test-dubbo/user -X PUT -d '{"id":"0003","code":3,"name":"dubbogo","age":99}' --header "Content-Type: application/json"
```

result

```bash
true
```

- body parse multi params

```bash
curl host:port/api/v1/test-dubbo/user2 -X PUT -d '{"name":"tc","user":{"id":"0001","code":1,"name":"tc","age":99}}' --header "Content-Type: application/json"
```

result

```bash
true
```

[Previous](./dubbo.md)
2 changes: 2 additions & 0 deletions docs/sample/dubbo-error.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ Return value
```bash
2020-11-20T15:56:59.011+0800 ERROR remote/call.go:112 [dubbo-go-proxy] client call err:Failed to invoke the method $invoke. No provider available for the service dubbo://:@:/?interface=com.ic.user.UserProvider&group=test&version=1.0.0 from registry zookeeper://127.0.0.1:2181?group=&registry=zookeeper&registry.label=true&registry.preferred=false&registry.role=0&registry.timeout=3s&registry.ttl=&registry.weight=0&registry.zone=&simplified=false on the consumer 30.11.176.51 using the dubbo version 1.3.0 .Please check if the providers have been started and registered.!
```
[Previous](./dubbo.md)
6 changes: 4 additions & 2 deletions docs/sample/dubbo-incomplete.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type User struct {
}
```

Although User struct has Time value, generic invoke will return nil. [the simple response](dubbogo-query.md#simple) time field is disappear.
Although User struct has Time value, generic invoke will return nil. [the simple response](dubbo-query.md#simple) time field is disappear.

So I suggest you can use string to time type for a short time.
So I suggest you can use string to time type for a short time.

[Previous](./dubbo.md)
Loading

0 comments on commit 1f7a957

Please sign in to comment.