You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2022/05/14 01:57:58 UTC
[dubbo-go-samples] branch master updated: apisix (#337)
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/master by this push:
new ba66a384 apisix (#337)
ba66a384 is described below
commit ba66a384c8e1ed519c4fb2bfff45524359ed1354
Author: gaoh <37...@users.noreply.github.com>
AuthorDate: Sat May 14 09:57:53 2022 +0800
apisix (#337)
* apisix
* license
* 添加 apache license
* 格式修改
* APISIX 格式修改
* import fmt update
* 删掉demo的go.mod
Co-authored-by: gaoh <ga...@xiaoantech.com>
---
apisix/README.md | 139 +++++++++++
apisix/apisix-compose/apisix_conf/config.yaml | 32 +++
apisix/apisix-compose/docker-compose.yml | 27 +++
.../dashboard_conf/conf.yaml | 85 +++++++
apisix/apisix-dashboard-compose/docker-compose.yml | 22 ++
apisix/etcd-compose/docker-compose.yml | 22 ++
apisix/helloworld/.gitignore | 2 +
apisix/helloworld/Dockerfile | 19 ++
apisix/helloworld/README.md | 0
apisix/helloworld/docker-compose.yml | 15 ++
apisix/helloworld/main.go | 67 ++++++
.../protobuf/helloworld/helloworld.pb.go | 257 +++++++++++++++++++++
.../protobuf/helloworld/helloworld.proto | 41 ++++
.../protobuf/helloworld/helloworld_triple.pb.go | 249 ++++++++++++++++++++
apisix/mysql5.7-compose/README.md | 0
apisix/mysql5.7-compose/docker-compose.yml | 12 +
apisix/mysql5.7-compose/mysql/Dockerfile | 18 ++
apisix/mysql5.7-compose/mysql/my.cnf | 11 +
apisix/nacos2.0.3-compose/docker-compose.yml | 35 +++
.../nacos_conf/custom.properties | 19 ++
20 files changed, 1072 insertions(+)
diff --git a/apisix/README.md b/apisix/README.md
new file mode 100644
index 00000000..39fca5a1
--- /dev/null
+++ b/apisix/README.md
@@ -0,0 +1,139 @@
+# 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/apisix/apisix-compose/apisix_conf/config.yaml b/apisix/apisix-compose/apisix_conf/config.yaml
new file mode 100644
index 00000000..228f353d
--- /dev/null
+++ b/apisix/apisix-compose/apisix_conf/config.yaml
@@ -0,0 +1,32 @@
+apisix:
+ node_listen: 9080 # APISIX listening port
+ enable_ipv6: false
+
+ allow_admin: # http://nginx.org/en/docs/http/ngx_http_access_module.html#allow
+ - 0.0.0.0/0 # We need to restrict ip access rules for security. 0.0.0.0/0 is for test.
+
+ admin_key:
+ - name: "admin"
+ key: edd1c9f034335fi23f87ad84b625c8f1
+ role: admin # admin: manage all configuration data
+ # viewer: only can view configuration data
+ - name: "viewer"
+ key: 4054f7cf07e344asdcd3f287985e76a2
+ role: viewer
+etcd:
+ host: # it's possible to define multiple etcd hosts addresses of the same etcd cluster.
+ - "http://etcd:2379" # multiple etcd address
+ prefix: "/apisix" # apisix configurations prefix
+ timeout: 30 # 30 seconds
+
+plugin_attr:
+ request-id:
+ snowflake:
+ enable: true
+ snowflake_epoc: 1648044426000
+ data_machine_bits: 10
+ sequence_bits: 12
+discovery:
+ nacos:
+ host:
+ - "http://nacos:8848"
diff --git a/apisix/apisix-compose/docker-compose.yml b/apisix/apisix-compose/docker-compose.yml
new file mode 100644
index 00000000..ce41fd23
--- /dev/null
+++ b/apisix/apisix-compose/docker-compose.yml
@@ -0,0 +1,27 @@
+version: "3"
+services:
+ apisix:
+ image: apache/apisix:2.13.1-alpine
+ restart: always
+ volumes:
+ - ./apisix_log:/usr/local/apisix/logs
+ - ./apisix_conf/config.yaml:/usr/local/apisix/conf/config.yaml:ro
+ ports:
+ - "80:9080/tcp"
+ - "9091:9091/tcp"
+ - "443:9443/tcp"
+ networks:
+ apisix:
+ default_network:
+ etcd:
+ environment:
+ - TZ=Asia/Shanghai
+networks:
+ apisix:
+ driver: bridge
+ default_network:
+ external:
+ name: default_network
+ etcd:
+ external:
+ name: etcd-compose_etcd
diff --git a/apisix/apisix-dashboard-compose/dashboard_conf/conf.yaml b/apisix/apisix-dashboard-compose/dashboard_conf/conf.yaml
new file mode 100644
index 00000000..4d0e3604
--- /dev/null
+++ b/apisix/apisix-dashboard-compose/dashboard_conf/conf.yaml
@@ -0,0 +1,85 @@
+conf:
+ listen:
+ host: 0.0.0.0 # `manager api` listening ip or host name
+ port: 9000 # `manager api` listening port
+ allow_list: # If we don't set any IP list, then any IP access is allowed by default.
+ - 0.0.0.0/0
+ etcd:
+ endpoints: # supports defining multiple etcd host addresses for an etcd cluster
+ - "http://etcd:2379"
+ # yamllint disable rule:comments-indentation
+ # etcd basic auth info
+ # username: "root" # ignore etcd username if not enable etcd auth
+ # password: "123456" # ignore etcd password if not enable etcd auth
+ mtls:
+ key_file: "" # Path of your self-signed client side key
+ cert_file: "" # Path of your self-signed client side cert
+ ca_file: "" # Path of your self-signed ca cert, the CA is used to sign callers' certificates
+ # prefix: /apisix # apisix config's prefix in etcd, /apisix by default
+ log:
+ error_log:
+ level: warn # supports levels, lower to higher: debug, info, warn, error, panic, fatal
+ file_path:
+ logs/error.log # supports relative path, absolute path, standard output
+ # such as: logs/error.log, /tmp/logs/error.log, /dev/stdout, /dev/stderr
+ access_log:
+ file_path:
+ logs/access.log # supports relative path, absolute path, standard output
+ # such as: logs/access.log, /tmp/logs/access.log, /dev/stdout, /dev/stderr
+ # log example: 2020-12-09T16:38:09.039+0800 INFO filter/logging.go:46 /apisix/admin/routes/r1 {"status": 401, "host": "127.0.0.1:9000", "query": "asdfsafd=adf&a=a", "requestId": "3d50ecb8-758c-46d1-af5b-cd9d1c820156", "latency": 0, "remoteIP": "127.0.0.1", "method": "PUT", "errs": []}
+authentication:
+ secret:
+ secret # secret for jwt token generation.
+ # NOTE: Highly recommended to modify this value to protect `manager api`.
+ # if it's default value, when `manager api` start, it will generate a random string to replace it.
+ expire_time: 3600 # jwt token expire time, in second
+ users: # yamllint enable rule:comments-indentation
+ - username: admin # username and password for login `manager api`
+ password: mdv@123456789
+
+plugins: # plugin list (sorted in alphabetical order)
+ - api-breaker
+ - authz-keycloak
+ - basic-auth
+ - batch-requests
+ - consumer-restriction
+ - cors
+ # - dubbo-proxy
+ - echo
+ # - error-log-logger
+ # - example-plugin
+ - fault-injection
+ - grpc-transcode
+ - hmac-auth
+ - http-logger
+ - ip-restriction
+ - jwt-auth
+ - kafka-logger
+ - key-auth
+ - limit-conn
+ - limit-count
+ - limit-req
+ # - log-rotate
+ # - node-status
+ - openid-connect
+ - prometheus
+ - proxy-cache
+ - proxy-mirror
+ - proxy-rewrite
+ - redirect
+ - referer-restriction
+ - request-id
+ - request-validation
+ - response-rewrite
+ - serverless-post-function
+ - serverless-pre-function
+ # - skywalking
+ - sls-logger
+ - syslog
+ - tcp-logger
+ - udp-logger
+ - uri-blocker
+ - wolf-rbac
+ - zipkin
+ - server-info
+ - traffic-split
diff --git a/apisix/apisix-dashboard-compose/docker-compose.yml b/apisix/apisix-dashboard-compose/docker-compose.yml
new file mode 100644
index 00000000..5e3f0c8c
--- /dev/null
+++ b/apisix/apisix-dashboard-compose/docker-compose.yml
@@ -0,0 +1,22 @@
+version: "3"
+services:
+ apisix-dashboard:
+ image: apache/apisix-dashboard:2.11-alpine
+ restart: always
+ volumes:
+ - ./dashboard_conf/conf.yaml:/usr/local/apisix-dashboard/conf/conf.yaml
+ ports:
+ - "9000:9000"
+ networks:
+ apisix:
+ etcd:
+ environment:
+ - TZ=Asia/Shanghai
+networks:
+ apisix:
+ external:
+ name: apisix-compose_apisix
+ etcd:
+ external:
+ name: etcd-compose_etcd
+
diff --git a/apisix/etcd-compose/docker-compose.yml b/apisix/etcd-compose/docker-compose.yml
new file mode 100644
index 00000000..98022bf4
--- /dev/null
+++ b/apisix/etcd-compose/docker-compose.yml
@@ -0,0 +1,22 @@
+version: "3"
+services:
+ etcd:
+ image: bitnami/etcd:3.4.9
+ user: root
+ restart: always
+ volumes:
+ - ./etcd_data:/etcd_data
+ environment:
+ ETCD_DATA_DIR: /etcd_data
+ ETCD_ENABLE_V2: "true"
+ ALLOW_NONE_AUTHENTICATION: "yes"
+ ETCD_ADVERTISE_CLIENT_URLS: "http://0.0.0.0:2379"
+ ETCD_LISTEN_CLIENT_URLS: "http://0.0.0.0:2379"
+ TZ: "Asia/Shanghai"
+ ports:
+ - "2379:2379/tcp"
+ networks:
+ etcd:
+networks:
+ etcd:
+ driver: bridge
diff --git a/apisix/helloworld/.gitignore b/apisix/helloworld/.gitignore
new file mode 100644
index 00000000..333cfa1e
--- /dev/null
+++ b/apisix/helloworld/.gitignore
@@ -0,0 +1,2 @@
+/log
+/.idea
diff --git a/apisix/helloworld/Dockerfile b/apisix/helloworld/Dockerfile
new file mode 100644
index 00000000..f61a3a91
--- /dev/null
+++ b/apisix/helloworld/Dockerfile
@@ -0,0 +1,19 @@
+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/apisix/helloworld/README.md b/apisix/helloworld/README.md
new file mode 100644
index 00000000..e69de29b
diff --git a/apisix/helloworld/docker-compose.yml b/apisix/helloworld/docker-compose.yml
new file mode 100644
index 00000000..4cdef180
--- /dev/null
+++ b/apisix/helloworld/docker-compose.yml
@@ -0,0 +1,15 @@
+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/apisix/helloworld/main.go b/apisix/helloworld/main.go
new file mode 100644
index 00000000..18af5240
--- /dev/null
+++ b/apisix/helloworld/main.go
@@ -0,0 +1,67 @@
+/*
+ * 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/common/logger"
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+)
+
+import (
+ "github.com/apache/dubbo-go-samples/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/apisix/helloworld/protobuf/helloworld/helloworld.pb.go b/apisix/helloworld/protobuf/helloworld/helloworld.pb.go
new file mode 100644
index 00000000..87fe7a8a
--- /dev/null
+++ b/apisix/helloworld/protobuf/helloworld/helloworld.pb.go
@@ -0,0 +1,257 @@
+/*
+ * 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
+
+package helloworld
+
+import (
+ reflect "reflect"
+ sync "sync"
+)
+
+import (
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+)
+
+const (
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+// The request message containing the user's name.
+type HelloRequest struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+}
+
+func (x *HelloRequest) Reset() {
+ *x = HelloRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_helloworld_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *HelloRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*HelloRequest) ProtoMessage() {}
+
+func (x *HelloRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_helloworld_proto_msgTypes[0]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.
+func (*HelloRequest) Descriptor() ([]byte, []int) {
+ return file_helloworld_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *HelloRequest) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
+// The response message containing the greetings
+type User struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
+ Age int32 `protobuf:"varint,3,opt,name=age,proto3" json:"age,omitempty"`
+}
+
+func (x *User) Reset() {
+ *x = User{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_helloworld_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *User) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*User) ProtoMessage() {}
+
+func (x *User) ProtoReflect() protoreflect.Message {
+ mi := &file_helloworld_proto_msgTypes[1]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
+ }
+ return mi.MessageOf(x)
+}
+
+// Deprecated: Use User.ProtoReflect.Descriptor instead.
+func (*User) Descriptor() ([]byte, []int) {
+ return file_helloworld_proto_rawDescGZIP(), []int{1}
+}
+
+func (x *User) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
+}
+
+func (x *User) GetId() string {
+ if x != nil {
+ return x.Id
+ }
+ return ""
+}
+
+func (x *User) GetAge() int32 {
+ if x != nil {
+ return x.Age
+ }
+ 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_helloworld_proto_rawDescOnce sync.Once
+ file_helloworld_proto_rawDescData = file_helloworld_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)
+ })
+ return file_helloworld_proto_rawDescData
+}
+
+var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_helloworld_proto_goTypes = []interface{}{
+ (*HelloRequest)(nil), // 0: helloworld.HelloRequest
+ (*User)(nil), // 1: helloworld.User
+}
+var file_helloworld_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
+ 1, // 3: helloworld.Greeter.SayHelloStream:output_type -> helloworld.User
+ 2, // [2:4] is the sub-list for method output_type
+ 0, // [0:2] is the sub-list for method input_type
+ 0, // [0:0] is the sub-list for extension type_name
+ 0, // [0:0] is the sub-list for extension extendee
+ 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 {
+ return
+ }
+ if !protoimpl.UnsafeEnabled {
+ file_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*HelloRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*User); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ }
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_helloworld_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,
+ }.Build()
+ File_helloworld_proto = out.File
+ file_helloworld_proto_rawDesc = nil
+ file_helloworld_proto_goTypes = nil
+ file_helloworld_proto_depIdxs = nil
+}
diff --git a/apisix/helloworld/protobuf/helloworld/helloworld.proto b/apisix/helloworld/protobuf/helloworld/helloworld.proto
new file mode 100644
index 00000000..c935264f
--- /dev/null
+++ b/apisix/helloworld/protobuf/helloworld/helloworld.proto
@@ -0,0 +1,41 @@
+/*
+ * 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.
+ */
+
+syntax = "proto3";
+package helloworld;
+
+option go_package = "./;helloworld";
+
+// The greeting service definition.
+service Greeter {
+ // Sends a greeting
+ rpc SayHello (HelloRequest) returns (User) {}
+ // Sends a greeting via stream
+ rpc SayHelloStream (stream HelloRequest) returns (stream User) {}
+}
+
+// The request message containing the user's name.
+message HelloRequest {
+ string name = 1;
+}
+
+// The response message containing the greetings
+message User {
+ string name = 1;
+ string id = 2;
+ int32 age = 3;
+}
\ No newline at end of file
diff --git a/apisix/helloworld/protobuf/helloworld/helloworld_triple.pb.go b/apisix/helloworld/protobuf/helloworld/helloworld_triple.pb.go
new file mode 100644
index 00000000..27d88f70
--- /dev/null
+++ b/apisix/helloworld/protobuf/helloworld/helloworld_triple.pb.go
@@ -0,0 +1,249 @@
+/*
+ * 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/apisix/mysql5.7-compose/README.md b/apisix/mysql5.7-compose/README.md
new file mode 100644
index 00000000..e69de29b
diff --git a/apisix/mysql5.7-compose/docker-compose.yml b/apisix/mysql5.7-compose/docker-compose.yml
new file mode 100644
index 00000000..5cae9e81
--- /dev/null
+++ b/apisix/mysql5.7-compose/docker-compose.yml
@@ -0,0 +1,12 @@
+version: "3"
+services :
+ mysql:
+ build: ./mysql #编译./mysql下的Dockerfile
+ restart: always
+ ports:
+ - "3306:3306" # 绑定服务器端口:容器端口
+ volumes:
+ - ./data/mysql:/var/lib/mysql
+ environment:
+ - MYSQL_ROOT_PASSWORD=123456
+ - TZ=Asia/Shanghai
diff --git a/apisix/mysql5.7-compose/mysql/Dockerfile b/apisix/mysql5.7-compose/mysql/Dockerfile
new file mode 100644
index 00000000..f2d7311e
--- /dev/null
+++ b/apisix/mysql5.7-compose/mysql/Dockerfile
@@ -0,0 +1,18 @@
+from mysql:5.7.25
+maintainer mandarava
+#run mv /etc/mysql/conf.d/my.conf /etc/mysql/conf.d/my.conf.bak
+run echo "Asia/Shanghai" > /etc/timezone \
+&& cp -a /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
+
+add my.cnf /etc
+user root
+#mkdir -p /var/mysql/logs && mkdir -p /var/mysql/data
+#docker run -p 3306:3306 --name mymysql -v /var/mysql/logs:/logs -v /var/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d registry.cn-hangzhou.aliyuncs.com/mandarava/mysql-docker:latest
+#进入容器
+#docker exec -it 833 /bin/bash
+#允许远程访问
+#use mysql;
+#GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root";
+#flush privileges;
+#select host,user from user; //查看修改是否成功。
+
diff --git a/apisix/mysql5.7-compose/mysql/my.cnf b/apisix/mysql5.7-compose/mysql/my.cnf
new file mode 100644
index 00000000..5f0b6d85
--- /dev/null
+++ b/apisix/mysql5.7-compose/mysql/my.cnf
@@ -0,0 +1,11 @@
+[mysqld]
+skip-name-resolve
+max_allowed_packet = 100M
+innodb_buffer_pool_size=100M
+explicit_defaults_for_timestamp=true
+max_connections=500
+bind-address=0.0.0.0
+default-time-zone = '+8:00'
+#解决不监听ipv4
+sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES
+#ANSI_QUOTES 解决双引号导入失败问题
diff --git a/apisix/nacos2.0.3-compose/docker-compose.yml b/apisix/nacos2.0.3-compose/docker-compose.yml
new file mode 100644
index 00000000..9a6a7032
--- /dev/null
+++ b/apisix/nacos2.0.3-compose/docker-compose.yml
@@ -0,0 +1,35 @@
+version: "3"
+services:
+ nacos:
+ image: nacos/nacos-server:2.0.3
+ environment:
+ - PREFER_HOST_MODE=hostname
+ - MODE=standalone
+ - SPRING_DATASOURCE_PLATFORM=derby
+ - JVM_XMS=128m
+ - JVM_XMX=128m
+ # - SPRING_DATASOURCE_PLATFORM=mysql
+ # - MYSQL_SERVICE_HOST=mysql
+ # - MYSQL_SERVICE_DB_NAME=nacos_config_apisix
+ # - MYSQL_SERVICE_PORT=3306
+ # - MYSQL_SERVICE_USER=root
+ # - MYSQL_SERVICE_PASSWORD=123456
+ - TZ=Asia/Shanghai
+ volumes:
+ - ./logs/:/home/nacos/logs
+ - ./nacos_conf/custom.properties:/home/nacos/init.d/custom.properties
+ ports:
+ - "8848:8848"
+ - "9848:9848"
+ - "9555:9555"
+ restart: always
+ networks:
+ #mysql_network:
+ default_network:
+networks:
+ default_network:
+ external:
+ name: default_network
+ # mysql_network:
+ # external:
+ # name: mysql57-compose_default
diff --git a/apisix/nacos2.0.3-compose/nacos_conf/custom.properties b/apisix/nacos2.0.3-compose/nacos_conf/custom.properties
new file mode 100644
index 00000000..b9ad82e8
--- /dev/null
+++ b/apisix/nacos2.0.3-compose/nacos_conf/custom.properties
@@ -0,0 +1,19 @@
+#spring.security.enabled=false
+#management.security=false
+#security.basic.enabled=false
+#nacos.security.ignore.urls=/**
+#management.metrics.export.elastic.host=http://localhost:9200
+# metrics for prometheus
+management.endpoints.web.exposure.include=*
+
+# metrics for elastic search
+#management.metrics.export.elastic.enabled=false
+#management.metrics.export.elastic.host=http://localhost:9200
+
+# metrics for influx
+#management.metrics.export.influx.enabled=false
+#management.metrics.export.influx.db=springboot
+#management.metrics.export.influx.uri=http://localhost:8086
+#management.metrics.export.influx.auto-create-db=true
+#management.metrics.export.influx.consistency=one
+#management.metrics.export.influx.compressed=true
\ No newline at end of file