This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/main by this push:
new d48d7cfd feat: migrate apisix sample (#1023)
d48d7cfd is described below
commit d48d7cfd8173b96b0a7532ae4fc184ff3db3e343
Author: zbchi <[email protected]>
AuthorDate: Thu Jan 15 09:36:15 2026 +0800
feat: migrate apisix sample (#1023)
* feat: migrate apisix sample
* add link
---
README.md | 2 +-
README_CN.md | 2 +-
apisix/README.md | 156 +++++++++++++
apisix/README_zh.md | 157 +++++++++++++
apisix/build.sh | 22 ++
.../deploy}/apisix-compose/apisix_conf/config.yaml | 0
.../deploy}/apisix-compose/docker-compose.yml | 0
.../dashboard_conf/conf.yaml | 0
.../apisix-dashboard-compose/docker-compose.yml | 0
.../deploy}/etcd-compose/docker-compose.yml | 2 +-
.../deploy}/mysql5.7-compose/docker-compose.yml | 0
.../deploy}/mysql5.7-compose/mysql/Dockerfile | 0
.../deploy}/mysql5.7-compose/mysql/my.cnf | 0
.../deploy}/nacos2.0.3-compose/docker-compose.yml | 2 +-
.../nacos_conf/custom.properties | 0
apisix/go-server/Dockerfile | 26 +++
apisix/go-server/cmd/server.go | 120 ++++++++++
.../helloworld.pb.go => apisix/proto/greet.pb.go | 149 ++++++------
.../helloworld.proto => apisix/proto/greet.proto | 4 +-
apisix/proto/greet.triple.go | 209 +++++++++++++++++
compatibility/apisix/README.md | 139 ------------
compatibility/apisix/helloworld/.gitignore | 2 -
compatibility/apisix/helloworld/Dockerfile | 19 --
compatibility/apisix/helloworld/README.md | 0
compatibility/apisix/helloworld/docker-compose.yml | 15 --
compatibility/apisix/helloworld/main.go | 68 ------
.../protobuf/helloworld/helloworld_triple.pb.go | 251 ---------------------
compatibility/apisix/mysql5.7-compose/README.md | 0
28 files changed, 769 insertions(+), 576 deletions(-)
diff --git a/README.md b/README.md
index dffcba40..292e5f35 100644
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@ A collection of runnable Dubbo-go examples covering
configuration, registries, o
### Samples
* `async`: Callback (asynchronous) and one-way RPC examples.
+* `apisix`: Example integrating Apache APISIX with Dubbo-go.
* `book-flight-ai-agent`: Example of booking flights using an AI agent.
* `config_center`: Demonstrates how to use different config centers (e.g.,
Nacos, Zookeeper) for configuration management.
* `config_yaml`: Shows how to configure Dubbo-go applications using YAML files.
@@ -49,7 +50,6 @@ A collection of runnable Dubbo-go examples covering
configuration, registries, o
### compatibility (legacy Dubbo-go samples)
-* `compatibility/apisix`: Example integrating Apache APISIX with Dubbo-go.
* `compatibility/generic`: Generic invocation example.
* `compatibility/polaris`: Dubbo-go integrate with polaris samples.
* `compatibility/polaris/limit`: Quickly experience Polaris' service
current limiting capabilities in dubbogo
diff --git a/README_CN.md b/README_CN.md
index 6f5ee71c..510f0d66 100644
--- a/README_CN.md
+++ b/README_CN.md
@@ -11,6 +11,7 @@
### 示例
* `async`:回调(异步)与单向 RPC 调用示例。
+* `apisix`:Dubbo-go 集成 Apache APISIX 的示例。
* `book-flight-ai-agent`:使用 AI Agent 实现机票预订的示例。
* `config_center`:演示如何使用不同配置中心(如 Nacos、Zookeeper)进行配置管理。
* `config_yaml`:展示如何使用 YAML 文件配置 Dubbo-go 应用。
@@ -49,7 +50,6 @@
### compatibility(旧版 Dubbo-go 示例)
-* `compatibility/apisix`:Dubbo-go 集成 Apache APISIX 的示例。
* `compatibility/generic`:泛化调用示例。
* `compatibility/polaris`: Dubbo-go 与 polaris 集成示例.
* `compatibility/polaris/limit`: 在 dubbogo 中快速体验北极星的服务限流能力
diff --git a/apisix/README.md b/apisix/README.md
new file mode 100644
index 00000000..2762d947
--- /dev/null
+++ b/apisix/README.md
@@ -0,0 +1,156 @@
+# APISIX Integration with Dubbo-Go
+
+[English](README.md) | [中文](README_zh.md)
+
+This example demonstrates how to use Apache APISIX as an API gateway for
Dubbo-Go services.
+
+## Overview
+
+Apache APISIX is a dynamic, real-time, high-performance API gateway. This
example shows how to:
+- Create Triple protocol services using Dubbo-Go 3.x new API
+- Use Nacos for service registration and discovery
+- Use APISIX gateway for HTTP to gRPC/Triple protocol conversion
+- Access Dubbo-Go services through APISIX routes
+
+## Requirements
+
+- Linux or macOS
+- Docker 20.10+
+- Docker Compose v2.0+
+- Go 1.18+ (for local development)
+
+## Architecture
+
+```
+Client (HTTP) -> APISIX Gateway -> Dubbo-Go Service (Triple/gRPC)
+ ↓ ↓
+ etcd Nacos Registry
+```
+
+## Quick Start
+
+### 1. Create Docker Network
+
+```bash
+docker network create default_network
+```
+
+### 2. Start Dependencies
+
+Start etcd, MySQL, Nacos, and APISIX in order:
+
+```bash
+# Start etcd (APISIX configuration center)
+cd ./deploy/etcd-compose
+docker compose up -d
+
+# Start MySQL (Nacos database)
+cd ../mysql5.7-compose
+docker compose up -d
+
+# Wait for MySQL to be ready (~10 seconds)
+sleep 10
+
+# Start Nacos
+cd ../nacos2.0.3-compose
+docker compose up -d
+
+# Wait for Nacos to be ready (~20 seconds)
+sleep 20
+
+# Start APISIX (API gateway)
+cd ../apisix-compose
+docker compose up -d
+
+cd ../../
+```
+
+### 3. Build and Start Dubbo-Go Service
+
+```bash
+# Build image
+./build.sh
+
+# Get Nacos container IP
+NACOS_IP=$(docker inspect -f '{{range
.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nacos)
+
+# Start Dubbo-Go service
+docker run -d \
+ --name dubbo-go-apisix-server \
+ --network default_network \
+ -e NACOS_ADDR=$NACOS_IP:8848 \
+ dubbo-go-apisix-server:latest
+```
+
+### 4. Configure APISIX
+
+#### 4.1 Configure Protocol Buffer
+
+```bash
+curl -X PUT
'http://127.0.0.1:80/apisix/admin/proto/1?api_key=edd1c9f034335fi23f87ad84b625c8f1'
\
+-H 'Content-Type: application/json' \
+-d '{
+ "content": "syntax = \"proto3\";\npackage helloworld;\n\noption go_package
= \"github.com/apache/dubbo-go-samples/apisix/proto;greet\";\n\nservice Greeter
{\n rpc SayHello (HelloRequest) returns (User) {}\n rpc SayHelloStream
(stream HelloRequest) returns (stream User) {}\n}\n\nmessage HelloRequest {\n
string name = 1;\n}\n\nmessage User {\n string name = 1;\n string id = 2;\n
int32 age = 3;\n}"
+}'
+```
+
+#### 4.2 Configure Route
+
+```bash
+curl -X PUT
'http://127.0.0.1:80/apisix/admin/routes/1?api_key=edd1c9f034335fi23f87ad84b625c8f1'
\
+-H 'Content-Type: application/json' \
+-d '{
+ "uri": "/helloworld",
+ "name": "helloworld",
+ "methods": ["GET", "POST"],
+ "plugins": {
+ "grpc-transcode": {
+ "method": "SayHello",
+ "proto_id": "1",
+ "service": "helloworld.Greeter"
+ }
+ },
+ "upstream": {
+ "type": "roundrobin",
+ "scheme": "grpc",
+ "discovery_type": "nacos",
+ "pass_host": "pass",
+ "service_name": "dubbo_apisix_server"
+ },
+ "status": 1
+}'
+```
+
+### 5. Test
+
+```bash
+curl 'http://127.0.0.1:80/helloworld?name=World'
+```
+
+Expected output:
+
+```json
+{
+ "age": 21,
+ "id": "12345",
+ "name": "Hello World"
+}
+```
+
+## Verify Service Registration
+
+Access Nacos console to check service registration:
+
+```
+http://localhost:8848/nacos
+Username: nacos
+Password: nacos
+```
+
+You should see the `providers:helloworld.Greeter::` service in the service
list.
+
+## References
+
+- [Apache APISIX
Documentation](https://apisix.apache.org/docs/apisix/getting-started)
+- [Dubbo-Go Documentation](https://dubbogo.apache.org/)
+- [Nacos Documentation](https://nacos.io/)
diff --git a/apisix/README_zh.md b/apisix/README_zh.md
new file mode 100644
index 00000000..9ea2810d
--- /dev/null
+++ b/apisix/README_zh.md
@@ -0,0 +1,157 @@
+# APISIX 整合 Dubbo-Go
+
+[English](README.md) | [中文](README_zh.md)
+
+本示例演示如何使用 Apache APISIX 作为 Dubbo-Go 服务的 API 网关。
+
+## 概述
+
+Apache APISIX 是一个动态、实时、高性能的 API 网关,本示例展示了如何:
+- 使用 Dubbo-Go 3.x 的新 API 创建 Triple 协议服务
+- 通过 Nacos 进行服务注册与发现
+- 使用 APISIX 网关进行 HTTP 到 gRPC/Triple 的协议转换
+- 通过 APISIX 路由访问 Dubbo-Go 服务
+
+## 环境要求
+
+- Linux 或 macOS
+- Docker 20.10+
+- Docker Compose v2.0+
+- Go 1.18+ (如需本地开发)
+
+## 架构说明
+
+```
+Client (HTTP) -> APISIX Gateway -> Dubbo-Go Service (Triple/gRPC)
+ ↓ ↓
+ etcd Nacos Registry
+```
+
+## 快速开始
+
+### 1. 创建 Docker 网络
+
+```bash
+docker network create default_network
+```
+
+### 2. 启动依赖服务
+
+按顺序启动 etcd、MySQL、Nacos 和 APISIX:
+
+```bash
+# 启动 etcd (APISIX 的配置中心)
+cd ./deploy/etcd-compose
+docker compose up -d
+
+# 启动 MySQL (Nacos 的数据库)
+cd ../mysql5.7-compose
+docker compose up -d
+
+# 等待 MySQL 启动完成 (约10秒)
+sleep 10
+
+# 启动 Nacos
+cd ../nacos2.0.3-compose
+docker compose up -d
+
+# 等待 Nacos 启动完成 (约20秒)
+sleep 20
+
+# 启动 APISIX (API 网关)
+cd ../apisix-compose
+docker compose up -d
+
+cd ../../
+```
+
+### 3. 构建并启动 Dubbo-Go 服务
+
+```bash
+# 构建镜像
+./build.sh
+
+# 获取 Nacos 容器 IP
+NACOS_IP=$(docker inspect -f '{{range
.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nacos203-compose-nacos-1)
+echo $NACOS_IP
+
+# 启动 Dubbo-Go 服务
+docker run -d \
+ --name dubbo-go-apisix-server \
+ --network default_network \
+ -e NACOS_ADDR=$NACOS_IP:8848 \
+ dubbo-go-apisix-server:latest
+```
+
+### 4. 配置 APISIX
+
+#### 4.1 配置 Protocol Buffer
+
+```bash
+curl -X PUT
'http://127.0.0.1:80/apisix/admin/proto/1?api_key=edd1c9f034335fi23f87ad84b625c8f1'
\
+-H 'Content-Type: application/json' \
+-d '{
+ "content": "syntax = \"proto3\";\npackage helloworld;\n\noption go_package
= \"github.com/apache/dubbo-go-samples/apisix/proto;greet\";\n\nservice Greeter
{\n rpc SayHello (HelloRequest) returns (User) {}\n rpc SayHelloStream
(stream HelloRequest) returns (stream User) {}\n}\n\nmessage HelloRequest {\n
string name = 1;\n}\n\nmessage User {\n string name = 1;\n string id = 2;\n
int32 age = 3;\n}"
+}'
+```
+
+#### 4.2 配置路由
+
+```bash
+curl -X PUT
'http://127.0.0.1:80/apisix/admin/routes/1?api_key=edd1c9f034335fi23f87ad84b625c8f1'
\
+-H 'Content-Type: application/json' \
+-d '{
+ "uri": "/helloworld",
+ "name": "helloworld",
+ "methods": ["GET", "POST"],
+ "plugins": {
+ "grpc-transcode": {
+ "method": "SayHello",
+ "proto_id": "1",
+ "service": "helloworld.Greeter"
+ }
+ },
+ "upstream": {
+ "type": "roundrobin",
+ "scheme": "grpc",
+ "discovery_type": "nacos",
+ "pass_host": "pass",
+ "service_name": "dubbo_apisix_server"
+ },
+ "status": 1
+}'
+```
+
+### 5. 测试
+
+```bash
+curl 'http://127.0.0.1:80/helloworld?name=World'
+```
+
+预期输出:
+
+```json
+{
+ "age": 21,
+ "id": "12345",
+ "name": "Hello World"
+}
+```
+
+## 验证服务注册
+
+访问 Nacos 控制台查看服务注册情况:
+
+```
+http://localhost:8848/nacos
+用户名: nacos
+密码: nacos
+```
+
+在服务列表中应该能看到 `providers:helloworld.Greeter::` 服务。
+
+## 参考文档
+
+- [Apache APISIX 文档](https://apisix.apache.org/zh/docs/apisix/getting-started)
+- [Dubbo-Go 官方文档](https://dubbogo.apache.org/)
+- [Nacos 官方文档](https://nacos.io/)
diff --git a/apisix/build.sh b/apisix/build.sh
new file mode 100755
index 00000000..12792e64
--- /dev/null
+++ b/apisix/build.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+# Build script for apisix example
+
+set -e
+
+echo "Building apisix server image..."
+
+# Build from repository root
+cd "$(dirname "$0")/.."
+
+# Build server image
+echo "Building server image..."
+docker build -f apisix/go-server/Dockerfile -t dubbo-go-apisix-server:latest .
+
+echo "Build completed successfully!"
+echo ""
+echo "To run the example:"
+echo " 1. Create docker network: docker network create default_network"
+echo " 2. Start etcd: docker-compose -f
apisix/deploy/etcd-compose/docker-compose.yml up -d"
+echo " 3. Start APISIX: docker-compose -f
apisix/deploy/apisix-compose/docker-compose.yml up -d"
+echo " 4. Start Nacos: docker-compose -f
apisix/deploy/nacos2.0.3-compose/docker-compose.yml up -d"
+echo " 5. Start the server: docker run -d --name dubbo-go-apisix-server
--network default_network -e NACOS_ADDR=<nacos_ip>:8848
dubbo-go-apisix-server:latest"
diff --git a/compatibility/apisix/apisix-compose/apisix_conf/config.yaml
b/apisix/deploy/apisix-compose/apisix_conf/config.yaml
similarity index 100%
rename from compatibility/apisix/apisix-compose/apisix_conf/config.yaml
rename to apisix/deploy/apisix-compose/apisix_conf/config.yaml
diff --git a/compatibility/apisix/apisix-compose/docker-compose.yml
b/apisix/deploy/apisix-compose/docker-compose.yml
similarity index 100%
rename from compatibility/apisix/apisix-compose/docker-compose.yml
rename to apisix/deploy/apisix-compose/docker-compose.yml
diff --git
a/compatibility/apisix/apisix-dashboard-compose/dashboard_conf/conf.yaml
b/apisix/deploy/apisix-dashboard-compose/dashboard_conf/conf.yaml
similarity index 100%
rename from
compatibility/apisix/apisix-dashboard-compose/dashboard_conf/conf.yaml
rename to apisix/deploy/apisix-dashboard-compose/dashboard_conf/conf.yaml
diff --git a/compatibility/apisix/apisix-dashboard-compose/docker-compose.yml
b/apisix/deploy/apisix-dashboard-compose/docker-compose.yml
similarity index 100%
rename from compatibility/apisix/apisix-dashboard-compose/docker-compose.yml
rename to apisix/deploy/apisix-dashboard-compose/docker-compose.yml
diff --git a/compatibility/apisix/etcd-compose/docker-compose.yml
b/apisix/deploy/etcd-compose/docker-compose.yml
similarity index 92%
rename from compatibility/apisix/etcd-compose/docker-compose.yml
rename to apisix/deploy/etcd-compose/docker-compose.yml
index 98022bf4..eb30f377 100644
--- a/compatibility/apisix/etcd-compose/docker-compose.yml
+++ b/apisix/deploy/etcd-compose/docker-compose.yml
@@ -1,7 +1,7 @@
version: "3"
services:
etcd:
- image: bitnami/etcd:3.4.9
+ image: quay.io/coreos/etcd:v3.4.9
user: root
restart: always
volumes:
diff --git a/compatibility/apisix/mysql5.7-compose/docker-compose.yml
b/apisix/deploy/mysql5.7-compose/docker-compose.yml
similarity index 100%
rename from compatibility/apisix/mysql5.7-compose/docker-compose.yml
rename to apisix/deploy/mysql5.7-compose/docker-compose.yml
diff --git a/compatibility/apisix/mysql5.7-compose/mysql/Dockerfile
b/apisix/deploy/mysql5.7-compose/mysql/Dockerfile
similarity index 100%
rename from compatibility/apisix/mysql5.7-compose/mysql/Dockerfile
rename to apisix/deploy/mysql5.7-compose/mysql/Dockerfile
diff --git a/compatibility/apisix/mysql5.7-compose/mysql/my.cnf
b/apisix/deploy/mysql5.7-compose/mysql/my.cnf
similarity index 100%
rename from compatibility/apisix/mysql5.7-compose/mysql/my.cnf
rename to apisix/deploy/mysql5.7-compose/mysql/my.cnf
diff --git a/compatibility/apisix/nacos2.0.3-compose/docker-compose.yml
b/apisix/deploy/nacos2.0.3-compose/docker-compose.yml
similarity index 95%
rename from compatibility/apisix/nacos2.0.3-compose/docker-compose.yml
rename to apisix/deploy/nacos2.0.3-compose/docker-compose.yml
index 9a6a7032..358f04f1 100644
--- a/compatibility/apisix/nacos2.0.3-compose/docker-compose.yml
+++ b/apisix/deploy/nacos2.0.3-compose/docker-compose.yml
@@ -1,7 +1,7 @@
version: "3"
services:
nacos:
- image: nacos/nacos-server:2.0.3
+ image: nacos/nacos-server:v2.2.3
environment:
- PREFER_HOST_MODE=hostname
- MODE=standalone
diff --git
a/compatibility/apisix/nacos2.0.3-compose/nacos_conf/custom.properties
b/apisix/deploy/nacos2.0.3-compose/nacos_conf/custom.properties
similarity index 100%
rename from compatibility/apisix/nacos2.0.3-compose/nacos_conf/custom.properties
rename to apisix/deploy/nacos2.0.3-compose/nacos_conf/custom.properties
diff --git a/apisix/go-server/Dockerfile b/apisix/go-server/Dockerfile
new file mode 100644
index 00000000..039ceb60
--- /dev/null
+++ b/apisix/go-server/Dockerfile
@@ -0,0 +1,26 @@
+FROM golang:1.24-alpine AS builder
+ENV TIMEZONE=Asia/Shanghai
+WORKDIR /app
+
+# Copy go mod files (build context is repo root)
+COPY go.mod go.sum ./
+
+# Copy only necessary source code (avoid copying deploy runtime data)
+COPY apisix/go-server ./apisix/go-server/
+COPY apisix/proto ./apisix/proto/
+
+# Download dependencies
+RUN go env -w GO111MODULE=on && \
+ go env -w GOPROXY=https://goproxy.cn,direct && \
+ go mod download
+
+# Build
+WORKDIR /app/apisix/go-server
+RUN go build -o /app/server ./cmd/server.go
+
+FROM alpine:3.19
+WORKDIR /app
+COPY --from=builder /app/server /app/server
+
+EXPOSE 20001
+ENTRYPOINT ["/app/server"]
diff --git a/apisix/go-server/cmd/server.go b/apisix/go-server/cmd/server.go
new file mode 100644
index 00000000..29e5d059
--- /dev/null
+++ b/apisix/go-server/cmd/server.go
@@ -0,0 +1,120 @@
+/*
+ * 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 main
+
+import (
+ "context"
+ "os"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+ "dubbo.apache.org/dubbo-go/v3/protocol"
+ "dubbo.apache.org/dubbo-go/v3/registry"
+
+ "github.com/dubbogo/gost/log/logger"
+)
+
+import (
+ greet "github.com/apache/dubbo-go-samples/apisix/proto"
+)
+
+type GreeterProvider struct{}
+
+func (s *GreeterProvider) SayHello(ctx context.Context, in
*greet.HelloRequest) (*greet.User, error) {
+ logger.Infof("Dubbo3 GreeterProvider get user name = %s\n", in.Name)
+ return &greet.User{Name: "Hello " + in.Name, Id: "12345", Age: 21}, nil
+}
+
+func (s *GreeterProvider) SayHelloStream(ctx context.Context, svr
greet.Greeter_SayHelloStreamServer) error {
+ c, err := svr.Recv()
+ if err != nil {
+ return err
+ }
+ logger.Infof("Dubbo-go3 GreeterProvider recv 1 user, name = %s\n",
c.Name)
+ c2, err := svr.Recv()
+ if err != nil {
+ return err
+ }
+ logger.Infof("Dubbo-go3 GreeterProvider recv 2 user, name = %s\n",
c2.Name)
+
+ err = svr.Send(&greet.User{
+ Name: "hello " + c.Name,
+ Age: 18,
+ Id: "123456789",
+ })
+ if err != nil {
+ return err
+ }
+ c3, err := svr.Recv()
+ if err != nil {
+ return err
+ }
+ logger.Infof("Dubbo-go3 GreeterProvider recv 3 user, name = %s\n",
c3.Name)
+
+ err = svr.Send(&greet.User{
+ Name: "hello " + c2.Name,
+ Age: 19,
+ Id: "123456789",
+ })
+ if err != nil {
+ return err
+ }
+ return nil
+}
+
+func main() {
+ // Get Nacos address from environment variable, default to
localhost:8848
+ nacosAddr := os.Getenv("NACOS_ADDR")
+ if nacosAddr == "" {
+ nacosAddr = "localhost:8848"
+ }
+
+ ins, err := dubbo.NewInstance(
+ dubbo.WithName("dubbo_apisix_server"),
+ dubbo.WithRegistry(
+ registry.WithNacos(),
+ registry.WithAddress(nacosAddr),
+ ),
+ dubbo.WithProtocol(
+ protocol.WithTriple(),
+ protocol.WithPort(20001),
+ ),
+ )
+ if err != nil {
+ logger.Errorf("new dubbo instance failed: %v", err)
+ panic(err)
+ }
+
+ srv, err := ins.NewServer()
+ if err != nil {
+ logger.Errorf("new server failed: %v", err)
+ panic(err)
+ }
+
+ if err := greet.RegisterGreeterHandler(srv, &GreeterProvider{}); err !=
nil {
+ logger.Errorf("register greeter handler failed: %v", err)
+ panic(err)
+ }
+
+ if err := srv.Serve(); err != nil {
+ logger.Errorf("server serve failed: %v", err)
+ panic(err)
+ }
+}
diff --git
a/compatibility/apisix/helloworld/protobuf/helloworld/helloworld.pb.go
b/apisix/proto/greet.pb.go
similarity index 50%
rename from compatibility/apisix/helloworld/protobuf/helloworld/helloworld.pb.go
rename to apisix/proto/greet.pb.go
index 1483c263..57aac782 100644
--- a/compatibility/apisix/helloworld/protobuf/helloworld/helloworld.pb.go
+++ b/apisix/proto/greet.pb.go
@@ -1,37 +1,32 @@
-/*
- * 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.
- */
+//
+// 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.
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
-// protoc-gen-go v1.26.0
-// protoc v3.19.3
-// source: helloworld.proto
+// protoc-gen-go v1.31.0
+// protoc v3.21.12
+// source: greet.proto
-package helloworld
-
-import (
- reflect "reflect"
- sync "sync"
-)
+package greet
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+ reflect "reflect"
+ sync "sync"
)
const (
@@ -53,7 +48,7 @@ type HelloRequest struct {
func (x *HelloRequest) Reset() {
*x = HelloRequest{}
if protoimpl.UnsafeEnabled {
- mi := &file_helloworld_proto_msgTypes[0]
+ mi := &file_greet_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -66,7 +61,7 @@ func (x *HelloRequest) String() string {
func (*HelloRequest) ProtoMessage() {}
func (x *HelloRequest) ProtoReflect() protoreflect.Message {
- mi := &file_helloworld_proto_msgTypes[0]
+ mi := &file_greet_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -79,7 +74,7 @@ func (x *HelloRequest) ProtoReflect() protoreflect.Message {
// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.
func (*HelloRequest) Descriptor() ([]byte, []int) {
- return file_helloworld_proto_rawDescGZIP(), []int{0}
+ return file_greet_proto_rawDescGZIP(), []int{0}
}
func (x *HelloRequest) GetName() string {
@@ -103,7 +98,7 @@ type User struct {
func (x *User) Reset() {
*x = User{}
if protoimpl.UnsafeEnabled {
- mi := &file_helloworld_proto_msgTypes[1]
+ mi := &file_greet_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@@ -116,7 +111,7 @@ func (x *User) String() string {
func (*User) ProtoMessage() {}
func (x *User) ProtoReflect() protoreflect.Message {
- mi := &file_helloworld_proto_msgTypes[1]
+ mi := &file_greet_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@@ -129,7 +124,7 @@ func (x *User) ProtoReflect() protoreflect.Message {
// Deprecated: Use User.ProtoReflect.Descriptor instead.
func (*User) Descriptor() ([]byte, []int) {
- return file_helloworld_proto_rawDescGZIP(), []int{1}
+ return file_greet_proto_rawDescGZIP(), []int{1}
}
func (x *User) GetName() string {
@@ -153,48 +148,50 @@ func (x *User) GetAge() int32 {
return 0
}
-var File_helloworld_proto protoreflect.FileDescriptor
-
-var file_helloworld_proto_rawDesc = []byte{
- 0x0a, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64,
0x2e, 0x70, 0x72, 0x6f,
- 0x74, 0x6f, 0x12, 0x0a, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72,
0x6c, 0x64, 0x22, 0x22,
- 0x0a, 0x0c, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x12, 0x12,
- 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x04, 0x6e, 0x61,
- 0x6d, 0x65, 0x22, 0x3c, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x12,
0x0a, 0x04, 0x6e, 0x61,
- 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61,
0x6d, 0x65, 0x12, 0x0e,
- 0x0a, 0x02, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
0x69, 0x64, 0x12, 0x10,
- 0x0a, 0x03, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52,
0x03, 0x61, 0x67, 0x65,
- 0x32, 0x87, 0x01, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72,
0x12, 0x38, 0x0a, 0x08,
- 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x18, 0x2e, 0x68,
0x65, 0x6c, 0x6c, 0x6f,
- 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52,
0x65, 0x71, 0x75, 0x65,
- 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f,
0x72, 0x6c, 0x64, 0x2e,
- 0x55, 0x73, 0x65, 0x72, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x0e, 0x53, 0x61,
0x79, 0x48, 0x65, 0x6c,
- 0x6c, 0x6f, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x68,
0x65, 0x6c, 0x6c, 0x6f,
- 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52,
0x65, 0x71, 0x75, 0x65,
- 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f,
0x72, 0x6c, 0x64, 0x2e,
- 0x55, 0x73, 0x65, 0x72, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x0f,
0x5a, 0x0d, 0x2e, 0x2f,
- 0x3b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x62,
0x06, 0x70, 0x72, 0x6f,
- 0x74, 0x6f, 0x33,
+var File_greet_proto protoreflect.FileDescriptor
+
+var file_greet_proto_rawDesc = []byte{
+ 0x0a, 0x0b, 0x67, 0x72, 0x65, 0x65, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x12, 0x0a, 0x68,
+ 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x22, 0x22, 0x0a,
0x0c, 0x48, 0x65, 0x6c,
+ 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a,
0x04, 0x6e, 0x61, 0x6d,
+ 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x22, 0x3c, 0x0a,
+ 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d,
0x65, 0x18, 0x01, 0x20,
+ 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a,
0x02, 0x69, 0x64, 0x18,
+ 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10, 0x0a,
0x03, 0x61, 0x67, 0x65,
+ 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x61, 0x67, 0x65, 0x32,
0x87, 0x01, 0x0a, 0x07,
+ 0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, 0x12, 0x38, 0x0a, 0x08, 0x53,
0x61, 0x79, 0x48, 0x65,
+ 0x6c, 0x6c, 0x6f, 0x12, 0x18, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77,
0x6f, 0x72, 0x6c, 0x64,
+ 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x10, 0x2e,
+ 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x55,
0x73, 0x65, 0x72, 0x22,
+ 0x00, 0x12, 0x42, 0x0a, 0x0e, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c,
0x6f, 0x53, 0x74, 0x72,
+ 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77,
0x6f, 0x72, 0x6c, 0x64,
+ 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x10, 0x2e,
+ 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x55,
0x73, 0x65, 0x72, 0x22,
+ 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x37, 0x5a, 0x35, 0x67, 0x69, 0x74,
0x68, 0x75, 0x62, 0x2e,
+ 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2f, 0x64,
0x75, 0x62, 0x62, 0x6f,
+ 0x2d, 0x67, 0x6f, 0x2d, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f,
0x61, 0x70, 0x69, 0x73,
+ 0x69, 0x78, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x3b, 0x67, 0x72, 0x65,
0x65, 0x74, 0x62, 0x06,
+ 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
- file_helloworld_proto_rawDescOnce sync.Once
- file_helloworld_proto_rawDescData = file_helloworld_proto_rawDesc
+ file_greet_proto_rawDescOnce sync.Once
+ file_greet_proto_rawDescData = file_greet_proto_rawDesc
)
-func file_helloworld_proto_rawDescGZIP() []byte {
- file_helloworld_proto_rawDescOnce.Do(func() {
- file_helloworld_proto_rawDescData =
protoimpl.X.CompressGZIP(file_helloworld_proto_rawDescData)
+func file_greet_proto_rawDescGZIP() []byte {
+ file_greet_proto_rawDescOnce.Do(func() {
+ file_greet_proto_rawDescData =
protoimpl.X.CompressGZIP(file_greet_proto_rawDescData)
})
- return file_helloworld_proto_rawDescData
+ return file_greet_proto_rawDescData
}
-var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
-var file_helloworld_proto_goTypes = []interface{}{
+var file_greet_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_greet_proto_goTypes = []interface{}{
(*HelloRequest)(nil), // 0: helloworld.HelloRequest
(*User)(nil), // 1: helloworld.User
}
-var file_helloworld_proto_depIdxs = []int32{
+var file_greet_proto_depIdxs = []int32{
0, // 0: helloworld.Greeter.SayHello:input_type ->
helloworld.HelloRequest
0, // 1: helloworld.Greeter.SayHelloStream:input_type ->
helloworld.HelloRequest
1, // 2: helloworld.Greeter.SayHello:output_type -> helloworld.User
@@ -206,13 +203,13 @@ var file_helloworld_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for field type_name
}
-func init() { file_helloworld_proto_init() }
-func file_helloworld_proto_init() {
- if File_helloworld_proto != nil {
+func init() { file_greet_proto_init() }
+func file_greet_proto_init() {
+ if File_greet_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
- file_helloworld_proto_msgTypes[0].Exporter = func(v
interface{}, i int) interface{} {
+ file_greet_proto_msgTypes[0].Exporter = func(v interface{}, i
int) interface{} {
switch v := v.(*HelloRequest); i {
case 0:
return &v.state
@@ -224,7 +221,7 @@ func file_helloworld_proto_init() {
return nil
}
}
- file_helloworld_proto_msgTypes[1].Exporter = func(v
interface{}, i int) interface{} {
+ file_greet_proto_msgTypes[1].Exporter = func(v interface{}, i
int) interface{} {
switch v := v.(*User); i {
case 0:
return &v.state
@@ -241,18 +238,18 @@ func file_helloworld_proto_init() {
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
- RawDescriptor: file_helloworld_proto_rawDesc,
+ RawDescriptor: file_greet_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 0,
NumServices: 1,
},
- GoTypes: file_helloworld_proto_goTypes,
- DependencyIndexes: file_helloworld_proto_depIdxs,
- MessageInfos: file_helloworld_proto_msgTypes,
+ GoTypes: file_greet_proto_goTypes,
+ DependencyIndexes: file_greet_proto_depIdxs,
+ MessageInfos: file_greet_proto_msgTypes,
}.Build()
- File_helloworld_proto = out.File
- file_helloworld_proto_rawDesc = nil
- file_helloworld_proto_goTypes = nil
- file_helloworld_proto_depIdxs = nil
+ File_greet_proto = out.File
+ file_greet_proto_rawDesc = nil
+ file_greet_proto_goTypes = nil
+ file_greet_proto_depIdxs = nil
}
diff --git
a/compatibility/apisix/helloworld/protobuf/helloworld/helloworld.proto
b/apisix/proto/greet.proto
similarity index 94%
rename from compatibility/apisix/helloworld/protobuf/helloworld/helloworld.proto
rename to apisix/proto/greet.proto
index c935264f..551fbfb7 100644
--- a/compatibility/apisix/helloworld/protobuf/helloworld/helloworld.proto
+++ b/apisix/proto/greet.proto
@@ -18,7 +18,7 @@
syntax = "proto3";
package helloworld;
-option go_package = "./;helloworld";
+option go_package = "github.com/apache/dubbo-go-samples/apisix/proto;greet";
// The greeting service definition.
service Greeter {
@@ -38,4 +38,4 @@ message User {
string name = 1;
string id = 2;
int32 age = 3;
-}
\ No newline at end of file
+}
diff --git a/apisix/proto/greet.triple.go b/apisix/proto/greet.triple.go
new file mode 100644
index 00000000..79161371
--- /dev/null
+++ b/apisix/proto/greet.triple.go
@@ -0,0 +1,209 @@
+// Code generated by protoc-gen-triple. DO NOT EDIT.
+//
+// Source: greet.proto
+package greet
+
+import (
+ "context"
+ "net/http"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3"
+ "dubbo.apache.org/dubbo-go/v3/client"
+ "dubbo.apache.org/dubbo-go/v3/common"
+ "dubbo.apache.org/dubbo-go/v3/common/constant"
+ "dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol"
+ "dubbo.apache.org/dubbo-go/v3/server"
+)
+
+// This is a compile-time assertion to ensure that this generated file and the
Triple package
+// are compatible. If you get a compiler error that this constant is not
defined, this code was
+// generated with a version of Triple newer than the one compiled into your
binary. You can fix the
+// problem by either regenerating this code with an older version of Triple or
updating the Triple
+// version compiled into your binary.
+const _ = triple_protocol.IsAtLeastVersion0_1_0
+
+const (
+ // GreeterName is the fully-qualified name of the Greeter service.
+ GreeterName = "helloworld.Greeter"
+)
+
+// These constants are the fully-qualified names of the RPCs defined in this
package. They're
+// exposed at runtime as procedure and as the final two segments of the HTTP
route.
+//
+// Note that these are different from the fully-qualified method names used by
+// google.golang.org/protobuf/reflect/protoreflect. To convert from these
constants to
+// reflection-formatted method names, remove the leading slash and convert the
remaining slash to a
+// period.
+const (
+ // GreeterSayHelloProcedure is the fully-qualified name of the
Greeter's SayHello RPC.
+ GreeterSayHelloProcedure = "/helloworld.Greeter/SayHello"
+ // GreeterSayHelloStreamProcedure is the fully-qualified name of the
Greeter's SayHelloStream RPC.
+ GreeterSayHelloStreamProcedure = "/helloworld.Greeter/SayHelloStream"
+)
+
+var (
+ _ Greeter = (*GreeterImpl)(nil)
+
+ _ Greeter_SayHelloStreamClient = (*GreeterSayHelloStreamClient)(nil)
+
+ _ Greeter_SayHelloStreamServer = (*GreeterSayHelloStreamServer)(nil)
+)
+
+// Greeter is a client for the helloworld.Greeter service.
+type Greeter interface {
+ SayHello(ctx context.Context, req *HelloRequest, opts
...client.CallOption) (*User, error)
+ SayHelloStream(ctx context.Context, opts ...client.CallOption)
(Greeter_SayHelloStreamClient, error)
+}
+
+// NewGreeter constructs a client for the greet.Greeter service.
+func NewGreeter(cli *client.Client, opts ...client.ReferenceOption) (Greeter,
error) {
+ conn, err := cli.DialWithInfo("helloworld.Greeter",
&Greeter_ClientInfo, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return &GreeterImpl{
+ conn: conn,
+ }, nil
+}
+
+func SetConsumerGreeter(srv common.RPCService) {
+ dubbo.SetConsumerServiceWithInfo(srv, &Greeter_ClientInfo)
+}
+
+// GreeterImpl implements Greeter.
+type GreeterImpl struct {
+ conn *client.Connection
+}
+
+func (c *GreeterImpl) SayHello(ctx context.Context, req *HelloRequest, opts
...client.CallOption) (*User, error) {
+ resp := new(User)
+ if err := c.conn.CallUnary(ctx, []interface{}{req}, resp, "SayHello",
opts...); err != nil {
+ return nil, err
+ }
+ return resp, nil
+}
+
+func (c *GreeterImpl) SayHelloStream(ctx context.Context, opts
...client.CallOption) (Greeter_SayHelloStreamClient, error) {
+ stream, err := c.conn.CallBidiStream(ctx, "SayHelloStream", opts...)
+ if err != nil {
+ return nil, err
+ }
+ rawStream := stream.(*triple_protocol.BidiStreamForClient)
+ return &GreeterSayHelloStreamClient{rawStream}, nil
+}
+
+type Greeter_SayHelloStreamClient interface {
+ Spec() triple_protocol.Spec
+ Peer() triple_protocol.Peer
+ Send(*HelloRequest) error
+ RequestHeader() http.Header
+ CloseRequest() error
+ Recv() (*User, error)
+ ResponseHeader() http.Header
+ ResponseTrailer() http.Header
+ CloseResponse() error
+}
+
+type GreeterSayHelloStreamClient struct {
+ *triple_protocol.BidiStreamForClient
+}
+
+func (cli *GreeterSayHelloStreamClient) Send(msg *HelloRequest) error {
+ return cli.BidiStreamForClient.Send(msg)
+}
+
+func (cli *GreeterSayHelloStreamClient) Recv() (*User, error) {
+ msg := new(User)
+ if err := cli.BidiStreamForClient.Receive(msg); err != nil {
+ return nil, err
+ }
+ return msg, nil
+}
+
+var Greeter_ClientInfo = client.ClientInfo{
+ InterfaceName: "helloworld.Greeter",
+ MethodNames: []string{"SayHello", "SayHelloStream"},
+ ConnectionInjectFunc: func(dubboCliRaw interface{}, conn
*client.Connection) {
+ dubboCli := dubboCliRaw.(*GreeterImpl)
+ dubboCli.conn = conn
+ },
+}
+
+// GreeterHandler is an implementation of the helloworld.Greeter service.
+type GreeterHandler interface {
+ SayHello(context.Context, *HelloRequest) (*User, error)
+ SayHelloStream(context.Context, Greeter_SayHelloStreamServer) error
+}
+
+func RegisterGreeterHandler(srv *server.Server, hdlr GreeterHandler, opts
...server.ServiceOption) error {
+ return srv.Register(hdlr, &Greeter_ServiceInfo, opts...)
+}
+
+func SetProviderGreeter(srv common.RPCService) {
+ dubbo.SetProviderServiceWithInfo(srv, &Greeter_ServiceInfo)
+}
+
+type Greeter_SayHelloStreamServer interface {
+ Send(*User) error
+ Recv() (*HelloRequest, error)
+ Spec() triple_protocol.Spec
+ Peer() triple_protocol.Peer
+ RequestHeader() http.Header
+ ResponseHeader() http.Header
+ ResponseTrailer() http.Header
+ Conn() triple_protocol.StreamingHandlerConn
+}
+
+type GreeterSayHelloStreamServer struct {
+ *triple_protocol.BidiStream
+}
+
+func (srv *GreeterSayHelloStreamServer) Send(msg *User) error {
+ return srv.BidiStream.Send(msg)
+}
+
+func (srv GreeterSayHelloStreamServer) Recv() (*HelloRequest, error) {
+ msg := new(HelloRequest)
+ if err := srv.BidiStream.Receive(msg); err != nil {
+ return nil, err
+ }
+ return msg, nil
+}
+
+var Greeter_ServiceInfo = server.ServiceInfo{
+ InterfaceName: "helloworld.Greeter",
+ ServiceType: (*GreeterHandler)(nil),
+ Methods: []server.MethodInfo{
+ {
+ Name: "SayHello",
+ Type: constant.CallUnary,
+ ReqInitFunc: func() interface{} {
+ return new(HelloRequest)
+ },
+ MethodFunc: func(ctx context.Context, args
[]interface{}, handler interface{}) (interface{}, error) {
+ req := args[0].(*HelloRequest)
+ res, err :=
handler.(GreeterHandler).SayHello(ctx, req)
+ if err != nil {
+ return nil, err
+ }
+ return triple_protocol.NewResponse(res), nil
+ },
+ },
+ {
+ Name: "SayHelloStream",
+ Type: constant.CallBidiStream,
+ StreamInitFunc: func(baseStream interface{})
interface{} {
+ return
&GreeterSayHelloStreamServer{baseStream.(*triple_protocol.BidiStream)}
+ },
+ MethodFunc: func(ctx context.Context, args
[]interface{}, handler interface{}) (interface{}, error) {
+ stream := args[0].(Greeter_SayHelloStreamServer)
+ if err :=
handler.(GreeterHandler).SayHelloStream(ctx, stream); err != nil {
+ return nil, err
+ }
+ return nil, nil
+ },
+ },
+ },
+}
diff --git a/compatibility/apisix/README.md b/compatibility/apisix/README.md
deleted file mode 100644
index 39fca5a1..00000000
--- a/compatibility/apisix/README.md
+++ /dev/null
@@ -1,139 +0,0 @@
-# APISIX 整合 Dubbo Go
-
-
-
-**[Demo](https://github.com/limerence-code/apisix-dubbo-go.git)**
-
-## 环境准备
-
-1. Linux
-2. docker
-3. docker-compose
-
-本文以 **Ubuntu 22.04 LTS** , **docker 20.10.14**, **docker-compose v2.2.2** 为例
-
-## 依赖
-
-1. APISIX
-2. APISIX Dashboard
-3. etcd
-4. helloword
-5. Nacos
-
-### APISIX
-
-APISIX 服务端
-
-### APISIX Dashboard (可选)
-
-APISIX 控制台,提供可视化控制
-
-### etcd
-
-APISIX 的注册中心
-
-### helloworld
-
-Dubbo Go 的测试 Demo
-
-### Nacos
-
-用于注册 Dubbo Go 服务,供 APISIX 网关调用
-
-## 启动
-
-### 创建 docker network
-
-```shell
-docker network create default_network
-```
-
-创建 default_network ,服务指定该网络;方便服务之间进行通讯
-
-### 依次启动服务
-
-按顺序启动 **etcd** 、**APISIX** 、 **Nacos** 、 **helloworld** 命令 **docker-compose
up --build -d**
-
-如果需要通过控制台进行协议路由配置则可以启动 **APISIX Dashboard** 本文介绍的是通过 HTTP 直接控制,因此无需启动
-
-**PS: 启动 helloworld 服务时,需要提前查询 Nacos 对应 default_network 中的 ip ,然后将 main.go 中
nacosConfig.Address 修改成对应的 Nacos 地址**
-
-```shell
-docker inspect --format='{{json .NetworkSettings.Networks}}' nacos
-```
-
-helloworld 启动成功后,在 Nacos 服务列表可以查看
-
-## 配置
-
-### 协议配置
-
-```apl
-curl --location --request PUT
'http://127.0.0.1:80/apisix/admin/proto/1?api_key=edd1c9f034335fi23f87ad84b625c8f1'
\
---header 'Content-Type: application/json' \
---data-raw '{
- "content": "syntax = \"proto3\";\npackage helloworld;\n\noption go_package
= \"./;helloworld\";\n\n// The greeting service definition.\nservice Greeter
{\n // Sends a greeting\n rpc SayHello (HelloRequest) returns (User) {}\n //
Sends a greeting via stream\n rpc SayHelloStream (stream HelloRequest) returns
(stream User) {}\n}\n\n// The request message containing the user'\''s
name.\nmessage HelloRequest {\n string name = 1;\n}\n\n// The response message
containing the greetings\ [...]
-}'
-```
-
-其中 content 内容就是 helloworld.proto 内容, api_key 在 apisix_conf 下面即可找到
-
-配置了协议 id 为1的协议,下面会用到
-
-### 路由转发
-
-```apl
-curl --location --request PUT
'http://127.0.0.1:80/apisix/admin/routes/1?api_key=edd1c9f034335fi23f87ad84b625c8f1'
\
---header 'Content-Type: application/json' \
---data-raw '{
- "uri": "/helloworld",
- "name": "helloworld",
- "methods": [
- "GET",
- "POST",
- "PUT",
- "DELETE",
- "PATCH",
- "HEAD",
- "OPTIONS",
- "CONNECT",
- "TRACE"
- ],
- "plugins": {
- "grpc-transcode": {
- "method": "SayHello",
- "proto_id": "1",
- "service": "helloworld.Greeter"
- }
- },
- "upstream": {
- "type": "roundrobin",
- "scheme": "grpc",
- "discovery_type": "nacos",
- "pass_host": "pass",
- "service_name": "providers:helloworld.Greeter::"
- },
- "status": 1
-}'
-```
-
-以上配置表示通过 /helloworld ,可以路由到 helloworld.Greeter 中的 SayHello 方法
-
-详细配置可查看 [APISIX](https://apisix.apache.org/zh/docs/apisix/getting-started)
-
-## 访问
-
-```api
-curl --location --request GET
'http://127.0.0.1:80/helloworld?api_key=edd1c9f034335f136f87ad84b625c8f1'
-```
-
-输出
-
-```json
-{
- "age": 21,
- "id": "12345",
- "name": "Hello "
-}
-```
-
diff --git a/compatibility/apisix/helloworld/.gitignore
b/compatibility/apisix/helloworld/.gitignore
deleted file mode 100644
index 333cfa1e..00000000
--- a/compatibility/apisix/helloworld/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/log
-/.idea
diff --git a/compatibility/apisix/helloworld/Dockerfile
b/compatibility/apisix/helloworld/Dockerfile
deleted file mode 100644
index f61a3a91..00000000
--- a/compatibility/apisix/helloworld/Dockerfile
+++ /dev/null
@@ -1,19 +0,0 @@
-FROM golang:1.18.0-alpine3.15 as builder
-ENV TIMEZONE Asia/Shanghai
-RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g'
/etc/apk/repositories \
-&& apk update && apk add git
-WORKDIR /aixichen/helloworld
-RUN mkdir -p /aixichen/helloworld
-#添加文件
-COPY ./ /aixichen/helloworld
-##编译
-RUN go env -w GO111MODULE=on && go env -w GOPROXY=https://goproxy.cn,direct \
-&& cd /aixichen/helloworld/ && go build -o aixichen-service
-
-FROM alpine:3.15
-RUN mkdir -p /aixichen/helloworld
-COPY --from=builder /aixichen/helloworld/aixichen-service /aixichen/helloworld
-WORKDIR /aixichen/helloworld
-
-EXPOSE 80
-ENTRYPOINT ["./aixichen-service"]
diff --git a/compatibility/apisix/helloworld/README.md
b/compatibility/apisix/helloworld/README.md
deleted file mode 100644
index e69de29b..00000000
diff --git a/compatibility/apisix/helloworld/docker-compose.yml
b/compatibility/apisix/helloworld/docker-compose.yml
deleted file mode 100644
index 4cdef180..00000000
--- a/compatibility/apisix/helloworld/docker-compose.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-version: "3"
-services :
- helloworld:
- build: ./ #编译
-# ports:
-# - 8084:80 # 绑定服务器端口:容器端口
- networks:
- default_network:
- restart: always
- environment:
- - TZ=Asia/Shanghai
-networks:
- default_network:
- external:
- name: default_network
diff --git a/compatibility/apisix/helloworld/main.go
b/compatibility/apisix/helloworld/main.go
deleted file mode 100644
index 89395d5d..00000000
--- a/compatibility/apisix/helloworld/main.go
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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 main
-
-import (
- "context"
-)
-
-import (
- "dubbo.apache.org/dubbo-go/v3/config"
- _ "dubbo.apache.org/dubbo-go/v3/imports"
-
- "github.com/dubbogo/gost/log/logger"
-)
-
-import (
-
"github.com/apache/dubbo-go-samples/compatibility/apisix/helloworld/protobuf/helloworld"
-)
-
-type GreeterProvider struct {
- helloworld.UnimplementedGreeterServer
-}
-
-func main() {
- config.SetProviderService(&GreeterProvider{})
-
- nacosConfig := config.NewRegistryConfigWithProtocolDefaultPort("nacos")
- nacosConfig.Address = "172.19.0.3:8848"
- rc := config.NewRootConfigBuilder().
- SetProvider(config.NewProviderConfigBuilder().
- AddService("GreeterProvider",
config.NewServiceConfigBuilder().Build()).
- Build()).
- AddProtocol("tripleProtocolKey",
config.NewProtocolConfigBuilder().
- SetName("tri").
- SetPort("20001").
- Build()).
- AddRegistry("registryKey", nacosConfig).
- Build()
-
- // start dubbo-go framework with configuration
- if err := config.Load(config.WithRootConfig(rc)); err != nil {
- logger.Infof("init ERR = %s\n", err.Error())
- }
-
- select {}
-}
-
-func (s *GreeterProvider) SayHello(ctx context.Context, in
*helloworld.HelloRequest) (*helloworld.User, error) {
- logger.Infof("SayHello in %s", in.String())
- helloworld := &helloworld.User{Name: "Hello " + in.Name, Id: "12345",
Age: 21}
- logger.Infof("SayHello out %s", helloworld.String())
- return helloworld, nil
-}
diff --git
a/compatibility/apisix/helloworld/protobuf/helloworld/helloworld_triple.pb.go
b/compatibility/apisix/helloworld/protobuf/helloworld/helloworld_triple.pb.go
deleted file mode 100644
index ba1ee168..00000000
---
a/compatibility/apisix/helloworld/protobuf/helloworld/helloworld_triple.pb.go
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * 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.
- */
-
-// Code generated by protoc-gen-go-triple. DO NOT EDIT.
-// versions:
-// - protoc-gen-go-triple v1.0.5
-// - protoc v3.19.3
-// source: helloworld.proto
-
-package helloworld
-
-import (
- context "context"
- fmt "fmt"
-)
-
-import (
- protocol "dubbo.apache.org/dubbo-go/v3/protocol"
- dubbo3 "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3"
- invocation "dubbo.apache.org/dubbo-go/v3/protocol/invocation"
-
- grpc_go "github.com/dubbogo/grpc-go"
- codes "github.com/dubbogo/grpc-go/codes"
- metadata "github.com/dubbogo/grpc-go/metadata"
- status "github.com/dubbogo/grpc-go/status"
-
- common "github.com/dubbogo/triple/pkg/common"
- constant "github.com/dubbogo/triple/pkg/common/constant"
- triple "github.com/dubbogo/triple/pkg/triple"
-)
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc_go.SupportPackageIsVersion7
-
-// GreeterClient is the client API for Greeter service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please
refer to
https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
-type GreeterClient interface {
- // Sends a greeting
- SayHello(ctx context.Context, in *HelloRequest, opts
...grpc_go.CallOption) (*User, common.ErrorWithAttachment)
- // Sends a greeting via stream
- SayHelloStream(ctx context.Context, opts ...grpc_go.CallOption)
(Greeter_SayHelloStreamClient, error)
-}
-
-type greeterClient struct {
- cc *triple.TripleConn
-}
-
-type GreeterClientImpl struct {
- SayHello func(ctx context.Context, in *HelloRequest) (*User,
error)
- SayHelloStream func(ctx context.Context) (Greeter_SayHelloStreamClient,
error)
-}
-
-func (c *GreeterClientImpl) GetDubboStub(cc *triple.TripleConn) GreeterClient {
- return NewGreeterClient(cc)
-}
-
-func (c *GreeterClientImpl) XXX_InterfaceName() string {
- return "helloworld.Greeter"
-}
-
-func NewGreeterClient(cc *triple.TripleConn) GreeterClient {
- return &greeterClient{cc}
-}
-
-func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts
...grpc_go.CallOption) (*User, common.ErrorWithAttachment) {
- out := new(User)
- interfaceKey := ctx.Value(constant.InterfaceKey).(string)
- return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out)
-}
-
-func (c *greeterClient) SayHelloStream(ctx context.Context, opts
...grpc_go.CallOption) (Greeter_SayHelloStreamClient, error) {
- interfaceKey := ctx.Value(constant.InterfaceKey).(string)
- stream, err := c.cc.NewStream(ctx, "/"+interfaceKey+"/SayHelloStream",
opts...)
- if err != nil {
- return nil, err
- }
- x := &greeterSayHelloStreamClient{stream}
- return x, nil
-}
-
-type Greeter_SayHelloStreamClient interface {
- Send(*HelloRequest) error
- Recv() (*User, error)
- grpc_go.ClientStream
-}
-
-type greeterSayHelloStreamClient struct {
- grpc_go.ClientStream
-}
-
-func (x *greeterSayHelloStreamClient) Send(m *HelloRequest) error {
- return x.ClientStream.SendMsg(m)
-}
-
-func (x *greeterSayHelloStreamClient) Recv() (*User, error) {
- m := new(User)
- if err := x.ClientStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-// GreeterServer is the server API for Greeter service.
-// All implementations must embed UnimplementedGreeterServer
-// for forward compatibility
-type GreeterServer interface {
- // Sends a greeting
- SayHello(context.Context, *HelloRequest) (*User, error)
- // Sends a greeting via stream
- SayHelloStream(Greeter_SayHelloStreamServer) error
- mustEmbedUnimplementedGreeterServer()
-}
-
-// UnimplementedGreeterServer must be embedded to have forward compatible
implementations.
-type UnimplementedGreeterServer struct {
- proxyImpl protocol.Invoker
-}
-
-func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest)
(*User, error) {
- return nil, status.Errorf(codes.Unimplemented, "method SayHello not
implemented")
-}
-func (UnimplementedGreeterServer) SayHelloStream(Greeter_SayHelloStreamServer)
error {
- return status.Errorf(codes.Unimplemented, "method SayHelloStream not
implemented")
-}
-func (s *UnimplementedGreeterServer) XXX_SetProxyImpl(impl protocol.Invoker) {
- s.proxyImpl = impl
-}
-
-func (s *UnimplementedGreeterServer) XXX_GetProxyImpl() protocol.Invoker {
- return s.proxyImpl
-}
-
-func (s *UnimplementedGreeterServer) XXX_ServiceDesc() *grpc_go.ServiceDesc {
- return &Greeter_ServiceDesc
-}
-func (s *UnimplementedGreeterServer) XXX_InterfaceName() string {
- return "helloworld.Greeter"
-}
-
-func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {}
-
-// UnsafeGreeterServer may be embedded to opt out of forward compatibility for
this service.
-// Use of this interface is not recommended, as added methods to GreeterServer
will
-// result in compilation errors.
-type UnsafeGreeterServer interface {
- mustEmbedUnimplementedGreeterServer()
-}
-
-func RegisterGreeterServer(s grpc_go.ServiceRegistrar, srv GreeterServer) {
- s.RegisterService(&Greeter_ServiceDesc, srv)
-}
-
-func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec
func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor)
(interface{}, error) {
- in := new(HelloRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- base := srv.(dubbo3.Dubbo3GrpcService)
- args := []interface{}{}
- args = append(args, in)
- md, _ := metadata.FromIncomingContext(ctx)
- invAttachment := make(map[string]interface{}, len(md))
- for k, v := range md {
- invAttachment[k] = v
- }
- invo := invocation.NewRPCInvocation("SayHello", args, invAttachment)
- if interceptor == nil {
- result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
- return result, result.Error()
- }
- info := &grpc_go.UnaryServerInfo{
- Server: srv,
- FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
- }
- handler := func(ctx context.Context, req interface{}) (interface{},
error) {
- result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
- return result, result.Error()
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _Greeter_SayHelloStream_Handler(srv interface{}, stream
grpc_go.ServerStream) error {
- _, ok := srv.(dubbo3.Dubbo3GrpcService)
- invo := invocation.NewRPCInvocation("SayHelloStream", nil, nil)
- if !ok {
- fmt.Println(invo)
- return nil
- }
- return
srv.(GreeterServer).SayHelloStream(&greeterSayHelloStreamServer{stream})
-}
-
-type Greeter_SayHelloStreamServer interface {
- Send(*User) error
- Recv() (*HelloRequest, error)
- grpc_go.ServerStream
-}
-
-type greeterSayHelloStreamServer struct {
- grpc_go.ServerStream
-}
-
-func (x *greeterSayHelloStreamServer) Send(m *User) error {
- return x.ServerStream.SendMsg(m)
-}
-
-func (x *greeterSayHelloStreamServer) Recv() (*HelloRequest, error) {
- m := new(HelloRequest)
- if err := x.ServerStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-// Greeter_ServiceDesc is the grpc_go.ServiceDesc for Greeter service.
-// It's only intended for direct use with grpc_go.RegisterService,
-// and not to be introspected or modified (even as a copy)
-var Greeter_ServiceDesc = grpc_go.ServiceDesc{
- ServiceName: "helloworld.Greeter",
- HandlerType: (*GreeterServer)(nil),
- Methods: []grpc_go.MethodDesc{
- {
- MethodName: "SayHello",
- Handler: _Greeter_SayHello_Handler,
- },
- },
- Streams: []grpc_go.StreamDesc{
- {
- StreamName: "SayHelloStream",
- Handler: _Greeter_SayHelloStream_Handler,
- ServerStreams: true,
- ClientStreams: true,
- },
- },
- Metadata: "helloworld.proto",
-}
diff --git a/compatibility/apisix/mysql5.7-compose/README.md
b/compatibility/apisix/mysql5.7-compose/README.md
deleted file mode 100644
index e69de29b..00000000