Skip to content

Commit

Permalink
chore:use wasm filter build tags add wasm and docs (#567)
Browse files Browse the repository at this point in the history
Co-authored-by: baerwang <[email protected]>
  • Loading branch information
baerwang and baerwang authored Jun 18, 2023
1 parent 4182648 commit c0bf34e
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ENV GO111MODULE=on \
GOOS=linux \
GOARCH=amd64

RUN go build -ldflags '-r ./lib -s -w' -trimpath -o dubbo-go-pixiu ./cmd/pixiu/*.go
RUN go build -ldflags '-r ./lib -s -w' -tags="wasm" -trimpath -o dubbo-go-pixiu ./cmd/pixiu/*.go

### alpine
FROM amd64/pingcap/alpine-glibc:latest
Expand Down
86 changes: 67 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,77 +18,124 @@ It is an open source Dubbo ecosystem API gateway, and also a sidecar to let othe

## Quick Start

#### Requirment
1. go 1.17 or higher
2. docker or docker-desktop

you can find out all demo in https://github.com/apache/dubbo-go-pixiu-samples.
download it and operate as below.
```shell
git clone https://github.com/apache/dubbo-go-pixiu-samples.git
```

#### update pixiu to latest version
```shell
go get github.com/apache/[email protected]
```

#### cd samples dir

```
```shell
cd dubbogo/simple
```

we can use start.sh to run samples quickly. for more info, execute command as below for more help

```
```shell
./start.sh [action] [project]
./start.sh help
```

we run body samples below step
we run [direct] samples step by step as follows.

#### prepare config file and docker

prepare command will prepare dubbo-server and pixiu config file and start docker container needed
'prepare' command will prepare dubbo-server and pixiu config file firstly, and then start docker container.

```
./start.sh prepare body
```shell
./start.sh prepare direct
```

if prepare config file manually, notice:
- modify $PROJECT_DIR in conf.yaml to absolute path in your compute
- modify $PROJECT_DIR in conf.yaml to absolute path

#### start dubbo or http server

```
./start.sh startServer body
```shell
./start.sh startServer direct
```

#### start pixiu

```
./start.sh startPixiu body
```shell
./start.sh startPixiu direct
```

if run pixiu manually in pixiu project, use command as below.

```shell
go run cmd/pixiu/*.go gateway start -c /[absolute-path]/dubbo-go-pixiu/samples/dubbogo/simple/direct/pixiu/conf.yaml
```
go run cmd/pixiu/*.go gateway start -c /[absolute-path]/dubbo-go-pixiu/samples/dubbogo/simple/body/pixiu/conf.yaml

if run pixiu manually in pixiu project and wasm feature, use command as below.

build pixiu project use command operate

```shell
go build -tags wasm -o pixiu cmd/pixiu/*.go
```

run pixiu app binary

```shell
go build cmd/pixiu/*.go
./pixiu gateway start -c /[absolute-path]/dubbo-go-pixiu/samples/dubbogo/simple/direct/pixiu/conf.yaml
```

#### Try a request

use curl to try or use unit test

```bash
curl -X POST 'localhost:8881/api/v1/test-dubbo/user' -d '{"id":"0003","code":3,"name":"dubbogo","age":99}' --header 'Content-Type: application/json'
```shell
curl http://localhost:8883/UserService/com.dubbogo.pixiu.UserService/GetUserByCode \
-H "x-dubbo-http1.1-dubbo-version:1.0.0" -H "x-dubbo-service-protocol:dubbo" \
-H "x-dubbo-service-version:1.0.0" -H "x-dubbo-service-group:test" \
-H "Content-Type:application/json" \
-d '[1]'
```
```shell
curl http://localhost:8883/UserService/com.dubbogo.pixiu.UserService/UpdateUserByName \
-H "x-dubbo-http1.1-dubbo-version:1.0.0" -H "x-dubbo-service-protocol:dubbo" \
-H "x-dubbo-service-version:1.0.0" -H "x-dubbo-service-group:test" \
-H "Content-Type:application/json" \
-d '["tc",{"id":"0002","code":1,"name":"tc","age":15}]'
```
```shell
curl http://localhost:8883/UserService/com.dubbogo.pixiu.UserService/GetUserByCode \
-H "x-dubbo-http1.1-dubbo-version:1.0.0" -H "x-dubbo-service-protocol:dubbo" \
-H "x-dubbo-service-version:1.0.0" -H "x-dubbo-service-group:test" \
-H "Content-Type:application/json" \
-d '[1]'
```

```shell
./start.sh startTest body
```

#### Clean

```
./start.sh clean body
```shell
./start.sh clean direct
```

## Start Docker

####
```shell
docker run --name pixiu-gateway -p 8888:8888 dubbogopixiu/dubbo-go-pixiu:latest

```
```

```shell
docker run --name pixiu-gateway -p 8888:8888 \
-v /yourpath/conf.yaml:/etc/pixiu/conf.yaml \
-v /yourpath/log.yml:/etc/pixiu/log.yml \
Expand All @@ -112,8 +159,9 @@ The pixiu control plane is forked from [istio](https://github.com/istio/istio) v

The project is under intensively iteration, you are more than welcome to use, suggest and contribute codes.


### Community

**DingDing Group (31203920):**

[![flowchart](./docs/images/group-pixiu-dingding.jpg)](docs/images/group-pixiu-dingding.jpg)
Expand Down
91 changes: 71 additions & 20 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[![Pixiu Logo](docs/images/pixiu-logo-v4.png)](http://alexstocks.github.io/html/dubbogo.html)


[![Language](https://img.shields.io/badge/Language-Go-blue.svg)](https://golang.org/)
[![Build Status](https://travis-ci.org/dubbogo/dubbo-go-pixiu.svg?branch=master)](https://travis-ci.org/dubbogo/dubbo-go-pixiu)

Expand All @@ -9,72 +10,119 @@

**Dubbo-Go-Pixiu**(官网: https://dubbo.apache.org/zh/docs3-v2/dubbo-go-pixiu/) 是一款 Dubbo 生态下的高性能 API 网关和多语言解决方案 Sidecar


![](https://dubbo-go-pixiu.github.io/img/pixiu-dubbo-ecosystem.png)

Pixiu 是一款开源的 Dubbo 生态的 API 网关和 接入 dubbo 集群的语言解决方案。作为 API 网关形态, Pixiu 能接收外界的网络请求,将其转换为 dubbo 等协议请求,转发给背后集群;作为 Sidecar,Pixiu 期望可以代替代理服务注册到 Dubbo 集群,让多语言服务接入 Dubbo 集群提供更快捷的解决方案


## 快速开始

你可以在 https://github.com/apache/dubbo-go-pixiu-samples 中找到所有有关 pixiu 功能的案例,可以按照如下的步骤进行操作。
#### 环境准备
1. go 1.17或者更高
2. docker或者docker-desktop

#### 进入示例代码目录
#### 下载simples
你可以在 https://github.com/apache/dubbo-go-pixiu-samples 中找到所有有关 pixiu 功能的案例,可以按照如下的步骤进行操作。
```shell
git clone https://github.com/apache/dubbo-go-pixiu-samples.git
```

#### 更新pixiu到最新版本
```shell
go get github.com/apache/[email protected]
```

#### 进入示例代码目录
```shell
cd dubbogo/simple
```

可以使用 start.sh 脚本快速启动案例项目,可以执行如下命令来获得更多信息

```
```shell
./start.sh [action] [project]
./start.sh help
```

下列步骤中,我们将启动 body 案例项目
下列步骤中,我们将启动简单代理[direct]案例项目

#### 准备配置文件和外部依赖 docker
#### 准备配置文件

使用 start.sh 的 prepare 命令来准备配置文件和外部docker依赖

```
./start.sh prepare body
```shell
./start.sh prepare direct
```

如果想要手动准备文件,需要注意:
- 将 conf.yaml 中的 $PROJECT_DIR 修改为本地绝对路径

#### 启动 dubbo 服务或者 http 服务
#### 启动 dubbo 服务或者 http 服务,本地需要有docker环境,

```
./start.sh startServer body
```shell
./start.sh startServer direct
```

#### 启动 pixiu
#### 开启另一个终端,启动 pixiu

```
./start.sh startPixiu body
```shell
./start.sh startPixiu direct
```

可以使用下列命令来手动启动 pixiu
使用下列命令来手动启动 pixiu

```shell
go run cmd/pixiu/*.go gateway start -c /[absolute-path]/dubbo-go-pixiu/samples/dubbogo/simple/direct/pixiu/conf.yaml
```
go run cmd/pixiu/*.go gateway start -c /[absolute-path]/dubbo-go-pixiu/samples/dubbogo/simple/body/pixiu/conf.yaml

如果希望启用wasm ,使用下列命令来手动启动 pixiu

```shell
go build -tags wasm -o pixiu cmd/pixiu/*.go
```

手动编译并启动pixiu:

```shell
go build cmd/pixiu/*.go
./pixiu gateway start -c /[absolute-path]/dubbo-go-pixiu/samples/dubbogo/simple/direct/pixiu/conf.yaml
```

#### 尝试请求

可以使用 curl 或者执行单元测试来验证一下

```shell
curl http://localhost:8883/UserService/com.dubbogo.pixiu.UserService/GetUserByCode \
-H "x-dubbo-http1.1-dubbo-version:1.0.0" -H "x-dubbo-service-protocol:dubbo" \
-H "x-dubbo-service-version:1.0.0" -H "x-dubbo-service-group:test" \
-H "Content-Type:application/json" \
-d '[1]'
```
```shell
curl http://localhost:8883/UserService/com.dubbogo.pixiu.UserService/UpdateUserByName \
-H "x-dubbo-http1.1-dubbo-version:1.0.0" -H "x-dubbo-service-protocol:dubbo" \
-H "x-dubbo-service-version:1.0.0" -H "x-dubbo-service-group:test" \
-H "Content-Type:application/json" \
-d '["tc",{"id":"0002","code":1,"name":"tc","age":15}]'
```
curl -X POST 'localhost:8881/api/v1/test-dubbo/user' -d '{"id":"0003","code":3,"name":"dubbogo","age":99}' --header 'Content-Type: application/json'
```shell
curl http://localhost:8883/UserService/com.dubbogo.pixiu.UserService/GetUserByCode \
-H "x-dubbo-http1.1-dubbo-version:1.0.0" -H "x-dubbo-service-protocol:dubbo" \
-H "x-dubbo-service-version:1.0.0" -H "x-dubbo-service-group:test" \
-H "Content-Type:application/json" \
-d '[1]'
```

```shell
./start.sh startTest body
```

#### 清除

```
./start.sh clean body
./start.sh clean direct
```


Expand All @@ -84,14 +132,14 @@ curl -X POST 'localhost:8881/api/v1/test-dubbo/user' -d '{"id":"0003","code":3,"
```shell
docker pull dubbogopixiu/dubbo-go-pixiu:latest
```
```
docker run --name pixiuname -p 8888:8888 \

```shell
docker run --name pixiu-gateway -p 8888:8888 \
-v /yourpath/conf.yaml:/etc/pixiu/conf.yaml \
-v /yourpath/log.yml:/etc/pixiu/log.yml \
dubbogopixiu/dubbo-go-pixiu:latest
```


## 特性

- 多协议支持:目前已支持 Http、Dubbo2、Triple、gRPC 协议代理和转换,其他协议持续集成中
Expand All @@ -115,6 +163,9 @@ Pixiu 控制面是 frok 自 [istio](https://github.com/istio/istio) v1.14.3 版
**官方钉钉群(31203920)**:

[![flowchart](./docs/images/group-pixiu-dingding.jpg)](docs/images/group-pixiu-dingding.jpg)

We welcome the friends who can give us constructing suggestions instead of known-nothing.

## License

Apache License, Version 2.0
22 changes: 22 additions & 0 deletions pixiu/pkg/pluginregistry/proxywasm_register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//go:build wasm

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package pluginregistry

import _ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/filter/http/proxywasm"
1 change: 0 additions & 1 deletion pixiu/pkg/pluginregistry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
_ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/filter/http/httpproxy"
_ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/filter/http/loadbalancer"
_ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/filter/http/proxyrewrite"
_ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/filter/http/proxywasm"
_ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/filter/http/remote"
_ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/filter/metric"
_ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/filter/network/dubboproxy"
Expand Down

0 comments on commit c0bf34e

Please sign in to comment.