Merge branch 'main' into feature/wasm
diff --git a/.gitignore b/.gitignore
index 7011556..9f981b5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,5 @@
*.exe
test
-!dubbogo/simple/prometheus/test
target/
diff --git a/go.mod b/go.mod
index 7f17e5f..f91cbe2 100644
--- a/go.mod
+++ b/go.mod
@@ -13,7 +13,8 @@
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.2
github.com/spf13/cobra v1.4.0
- github.com/stretchr/testify v1.7.2
+ github.com/stretchr/testify v1.8.0
+ github.com/tetratelabs/proxy-wasm-go-sdk v0.0.13
google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21
google.golang.org/grpc v1.49.0
google.golang.org/protobuf v1.28.1
diff --git a/go.sum b/go.sum
index ac411f1..ed93893 100644
--- a/go.sum
+++ b/go.sum
@@ -2065,8 +2065,9 @@
github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
-github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48=
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
+github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v0.0.0-20170130113145-4d4bfba8f1d1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
@@ -2078,8 +2079,9 @@
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
-github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
+github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/subosito/gotenv v1.3.0 h1:mjC+YW8QpAdXibNi+vNWgzmgBH4+5l5dCXv8cNysBLI=
github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs=
@@ -2097,6 +2099,8 @@
github.com/tetafro/godot v0.3.7/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0=
github.com/tetafro/godot v0.4.2/go.mod h1:/7NLHhv08H1+8DNj0MElpAACw1ajsCuf3TKNQxA5S+0=
github.com/tetafro/godot v1.4.11/go.mod h1:LR3CJpxDVGlYOWn3ZZg1PgNZdTUvzsZWu8xaEohUpn8=
+github.com/tetratelabs/proxy-wasm-go-sdk v0.0.13 h1:DOKidvWd0WTBvdzTvU6L7wtig+RktRj3S77ObF2YwNQ=
+github.com/tetratelabs/proxy-wasm-go-sdk v0.0.13/go.mod h1:y1ZQT4bQEBnR8Do4nSOzb3roczzPvcAp8UrF6NEYWNY=
github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0=
github.com/tevid/gohamcrest v1.1.1/go.mod h1:3UvtWlqm8j5JbwYZh80D/PVBt0mJ1eJiYgZMibh0H/k=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
diff --git a/wasm/data/filter.go b/wasm/data/filter.go
new file mode 100644
index 0000000..7ccf7ff
--- /dev/null
+++ b/wasm/data/filter.go
@@ -0,0 +1,75 @@
+/*
+ * 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 (
+ "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm"
+ "github.com/tetratelabs/proxy-wasm-go-sdk/proxywasm/types"
+)
+
+func main() {
+
+ proxywasm.SetNewHttpContext(newHttpContext)
+}
+
+type myHttpContext struct {
+ // you must embed the default context so that you need not to re-implement all the methods by yourself
+ proxywasm.DefaultHttpContext
+ contextID uint32
+}
+
+func newHttpContext(rootContextID, contextID uint32) proxywasm.HttpContext {
+ return &myHttpContext{contextID: contextID}
+}
+
+// override
+func (ctx *myHttpContext) OnHttpRequestHeaders(numHeaders int, endOfStream bool) types.Action {
+
+ // add single header
+ proxywasm.LogInfo("proxywasm add singe header...")
+
+ // fixme this value will return with the Response Body, it is not good
+ err := proxywasm.AddHttpRequestHeader("go-wasm-header", "pixiu-wasm")
+ if err != nil {
+ proxywasm.LogCriticalf("failed to add request headers: %v", err)
+ }
+
+ // get all header
+ proxywasm.LogInfo("proxywasm get request headers...")
+ hs, err := proxywasm.GetHttpRequestHeaders()
+ if err != nil {
+ proxywasm.LogCriticalf("failed to get request headers: %v", err)
+ }
+ for _, h := range hs {
+ proxywasm.LogInfof("request header from go wasm --> %s: %s", h[0], h[1])
+ }
+ return types.ActionContinue
+}
+
+// override
+func (ctx *myHttpContext) OnHttpRequestBody(bodySize int, endOfStream bool) types.Action {
+ // get request body
+ proxywasm.LogInfo("proxywasm get request body...")
+ bytes, err := proxywasm.GetHttpRequestBody(0, 100)
+ if err != nil {
+ proxywasm.LogCriticalf("failed to get request body: %v", err)
+ }
+ proxywasm.LogInfof("proxywasm.GetHttpRequestBody [%s]", string(bytes))
+
+ return types.ActionContinue
+}
diff --git a/wasm/data/filter.wasm b/wasm/data/filter.wasm
new file mode 100755
index 0000000..d87ed82
--- /dev/null
+++ b/wasm/data/filter.wasm
Binary files differ
diff --git a/wasm/data/makefile b/wasm/data/makefile
new file mode 100644
index 0000000..2611e16
--- /dev/null
+++ b/wasm/data/makefile
@@ -0,0 +1,29 @@
+#
+# Licensed to 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. Apache Software Foundation (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.
+#
+
+.PHONY: wasm
+
+wasm:
+ docker run -it -v $(shell pwd):/tmp/proxy-wasm-go -e GOPROXY=https://goproxy.cn tinygo/tinygo-dev:a304fb738f2376548e008fbc5c02abf3bdff7156 \
+ /bin/bash -c \
+ "git clone --depth 1 --branch v0.0.13 https://github.com/tetratelabs/proxy-wasm-go-sdk.git /tmp/proxy-wasm-go/sdk &> /dev/null; \
+ cp /tmp/proxy-wasm-go/${name}.go /tmp/proxy-wasm-go/sdk; \
+ cd /tmp/proxy-wasm-go/sdk; \
+ tinygo build -o /tmp/proxy-wasm-go/${name}.wasm -scheduler=none -target=wasi -wasm-abi=generic -tags 'abi_010' ./${name}.go; \
+ rm -rf /tmp/proxy-wasm-go/sdk"
\ No newline at end of file
diff --git a/wasm/docker/docker-compose.yml b/wasm/docker/docker-compose.yml
new file mode 100644
index 0000000..7ca8ee5
--- /dev/null
+++ b/wasm/docker/docker-compose.yml
@@ -0,0 +1,27 @@
+#
+# Licensed to 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. Apache Software Foundation (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.
+#
+
+version: '3'
+
+services:
+ zookeeper:
+ image: zookeeper
+ ports:
+ - 2181:2181
+ restart: on-failure
diff --git a/wasm/pixiu/conf.yaml b/wasm/pixiu/conf.yaml
new file mode 100644
index 0000000..69239ef
--- /dev/null
+++ b/wasm/pixiu/conf.yaml
@@ -0,0 +1,70 @@
+#
+# 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.
+#
+---
+static_resources:
+ listeners:
+ - name: "net/http"
+ protocol_type: "HTTP"
+ address:
+ socket_address:
+ address: "0.0.0.0"
+ port: 8883
+ filter_chains:
+ filters:
+ - name: dgp.filter.httpconnectionmanager
+ config:
+ route_config:
+ routes:
+ - match:
+ prefix: "*"
+ http_filters:
+ - name: dgp.filter.http.webassembly
+ config:
+ wasm_services:
+ - name: "wasm.header"
+ - name: dgp.filter.http.dubboproxy
+ config:
+ dubboProxyConfig:
+ auto_resolve: true
+ registries:
+ "zookeeper":
+ protocol: "zookeeper"
+ timeout: "3s"
+ address: "127.0.0.1:2181"
+ username: ""
+ password: ""
+ timeout_config:
+ connect_timeout: 5s
+ request_timeout: 5s
+
+ server_name: "test_http_dubbo"
+ generate_request_id: false
+ config:
+ idle_timeout: 5s
+ read_timeout: 5s
+ write_timeout: 5s
+ shutdown_config:
+ timeout: "60s"
+ step_timeout: "10s"
+ reject_policy: "immediacy"
+wasm:
+ services:
+ - name: "wasm.header"
+ config:
+ path: wasm/data/filter.wasm
\ No newline at end of file
diff --git a/wasm/server/app/server.go b/wasm/server/app/server.go
new file mode 100644
index 0000000..96d92cf
--- /dev/null
+++ b/wasm/server/app/server.go
@@ -0,0 +1,73 @@
+/*
+ * 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 (
+ "dubbo.apache.org/dubbo-go/v3/common/constant"
+ "fmt"
+ "os"
+ "os/signal"
+ "syscall"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/common/logger"
+ "dubbo.apache.org/dubbo-go/v3/config"
+ _ "dubbo.apache.org/dubbo-go/v3/imports"
+)
+
+// Version dubbo version
+const Version = "2.7.5"
+
+var survivalTimeout = int(3e9)
+
+func main() {
+
+ getwd, _ := os.Getwd()
+ err := os.Setenv(constant.ConfigFileEnvKey, getwd+"/wasm/server/profiles/dev/server.yml")
+ if err != nil {
+ return
+ }
+ config.Load()
+ logger.Infof("dubbo version is: %s", Version)
+ initSignal()
+}
+
+func initSignal() {
+ signals := make(chan os.Signal, 1)
+ // It is not possible to block SIGKILL or syscall.SIGSTOP
+ signal.Notify(signals, os.Interrupt, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
+ for {
+ sig := <-signals
+ logger.Infof("get signal %s", sig.String())
+ switch sig {
+ case syscall.SIGHUP:
+ // reload()
+ default:
+ time.AfterFunc(time.Duration(survivalTimeout), func() {
+ logger.Warnf("app exit now by force...")
+ os.Exit(1)
+ })
+
+ // The program exits normally or timeout forcibly exits.
+ fmt.Println("provider app exit now...")
+ return
+ }
+ }
+}
diff --git a/wasm/server/app/user.go b/wasm/server/app/user.go
new file mode 100644
index 0000000..35cc39b
--- /dev/null
+++ b/wasm/server/app/user.go
@@ -0,0 +1,280 @@
+/*
+ * 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"
+ "errors"
+ "fmt"
+ "sync"
+ "time"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/config"
+
+ hessian "github.com/apache/dubbo-go-hessian2"
+)
+
+func init() {
+ config.SetProviderService(new(UserProvider))
+ // ------for hessian2------
+ hessian.RegisterPOJO(&User{})
+
+ cache = newUserDB()
+
+ t1, _ := time.Parse(
+ time.RFC3339,
+ "2021-08-01T10:08:41+00:00")
+
+ cache.Add(&User{ID: "0001", Code: 1, Name: "tc", Age: 18, Time: t1})
+ cache.Add(&User{ID: "0002", Code: 2, Name: "ic", Age: 88, Time: t1})
+}
+
+var cache *userDB
+
+// userDB cache user.
+type userDB struct {
+ // key is name, value is user obj
+ nameIndex map[string]*User
+ // key is code, value is user obj
+ codeIndex map[int64]*User
+ lock sync.Mutex
+}
+
+// userDB create func
+func newUserDB() *userDB {
+ return &userDB{
+ nameIndex: make(map[string]*User, 16),
+ codeIndex: make(map[int64]*User, 16),
+ lock: sync.Mutex{},
+ }
+}
+
+// nolint
+func (db *userDB) Add(u *User) bool {
+ db.lock.Lock()
+ defer db.lock.Unlock()
+
+ if u.Name == "" || u.Code <= 0 {
+ return false
+ }
+
+ if !db.existName(u.Name) && !db.existCode(u.Code) {
+ return db.AddForName(u) && db.AddForCode(u)
+ }
+
+ return false
+}
+
+// nolint
+func (db *userDB) AddForName(u *User) bool {
+ if len(u.Name) == 0 {
+ return false
+ }
+
+ if _, ok := db.nameIndex[u.Name]; ok {
+ return false
+ }
+
+ db.nameIndex[u.Name] = u
+ return true
+}
+
+// nolint
+func (db *userDB) AddForCode(u *User) bool {
+ if u.Code <= 0 {
+ return false
+ }
+
+ if _, ok := db.codeIndex[u.Code]; ok {
+ return false
+ }
+
+ db.codeIndex[u.Code] = u
+ return true
+}
+
+// nolint
+func (db *userDB) GetByName(n string) (*User, bool) {
+ db.lock.Lock()
+ defer db.lock.Unlock()
+
+ r, ok := db.nameIndex[n]
+ return r, ok
+}
+
+// nolint
+func (db *userDB) GetByCode(n int64) (*User, bool) {
+ db.lock.Lock()
+ defer db.lock.Unlock()
+
+ r, ok := db.codeIndex[n]
+ return r, ok
+}
+
+func (db *userDB) existName(name string) bool {
+ if len(name) <= 0 {
+ return false
+ }
+
+ _, ok := db.nameIndex[name]
+ if ok {
+ return true
+ }
+
+ return false
+}
+
+func (db *userDB) existCode(code int64) bool {
+ if code <= 0 {
+ return false
+ }
+
+ _, ok := db.codeIndex[code]
+ if ok {
+ return true
+ }
+
+ return false
+}
+
+// User user obj.
+type User struct {
+ ID string `json:"id,omitempty"`
+ Code int64 `json:"code,omitempty"`
+ Name string `json:"name,omitempty"`
+ Age int32 `json:"age,omitempty"`
+ Time time.Time `json:"time,omitempty"`
+}
+
+// UserProvider the dubbo provider.
+// like: version: 1.0.0 group: test
+type UserProvider struct{}
+
+// CreateUser new user, PX config POST.
+func (u *UserProvider) CreateUser(ctx context.Context, user *User) (*User, error) {
+ outLn("Req CreateUser data:%#v", user)
+ if user == nil {
+ return nil, errors.New("not found")
+ }
+ _, ok := cache.GetByName(user.Name)
+ if ok {
+ return nil, errors.New("data is exist")
+ }
+
+ b := cache.Add(user)
+ if b {
+ return user, nil
+ }
+
+ return nil, errors.New("add error")
+}
+
+// GetUserByName query by name, single param, PX config GET.
+func (u *UserProvider) GetUserByName(ctx context.Context, name string) (*User, error) {
+ outLn("Req GetUserByName name:%#v", name)
+ r, ok := cache.GetByName(name)
+ if ok {
+ outLn("Req GetUserByName result:%#v", r)
+ return r, nil
+ }
+ return nil, nil
+}
+
+// GetUserByCode query by code, single param, PX config GET.
+func (u *UserProvider) GetUserByCode(ctx context.Context, code int64) (*User, error) {
+ outLn("Req GetUserByCode name:%#v", code)
+ r, ok := cache.GetByCode(code)
+ if ok {
+ outLn("Req GetUserByCode result:%#v", r)
+ return r, nil
+ }
+ return nil, nil
+}
+
+// GetUserTimeout query by name, will timeout for pixiu.
+func (u *UserProvider) GetUserTimeout(ctx context.Context, name string) (*User, error) {
+ outLn("Req GetUserByName name:%#v", name)
+ // sleep 10s, pixiu config less than 10s.
+ time.Sleep(10 * time.Second)
+ r, ok := cache.GetByName(name)
+ if ok {
+ outLn("Req GetUserByName result:%#v", r)
+ return r, nil
+ }
+ return nil, nil
+}
+
+// GetUserByNameAndAge query by name and age, two params, PX config GET.
+func (u *UserProvider) GetUserByNameAndAge(ctx context.Context, name string, age int32) (*User, error) {
+ outLn("Req GetUserByNameAndAge name:%s, age:%d", name, age)
+ r, ok := cache.GetByName(name)
+ if ok && r.Age == age {
+ outLn("Req GetUserByNameAndAge result:%#v", r)
+ return r, nil
+ }
+ return r, nil
+}
+
+// UpdateUser update by user struct, my be another struct, PX config POST or PUT.
+func (u *UserProvider) UpdateUser(ctx context.Context, user *User) (bool, error) {
+ outLn("Req UpdateUser data:%#v", user)
+ r, ok := cache.GetByName(user.Name)
+ if ok {
+ if user.ID != "" {
+ r.ID = user.ID
+ }
+ if user.Age >= 0 {
+ r.Age = user.Age
+ }
+ return true, nil
+ }
+ return false, errors.New("not found")
+}
+
+// UpdateUserByName update by user struct, my be another struct, PX config POST or PUT.
+func (u *UserProvider) UpdateUserByName(ctx context.Context, name string, user *User) (bool, error) {
+ outLn("Req UpdateUserByName data:%#v", user)
+ r, ok := cache.GetByName(name)
+ if ok {
+ if user.ID != "" {
+ r.ID = user.ID
+ }
+ if user.Age >= 0 {
+ r.Age = user.Age
+ }
+ return true, nil
+ }
+ return false, errors.New("not found")
+}
+
+// nolint
+func (u *UserProvider) Reference() string {
+ return "UserProvider"
+}
+
+// nolint
+func (u User) JavaClassName() string {
+ return "com.dubbogo.pixiu.User"
+}
+
+// nolint
+func outLn(format string, args ...interface{}) {
+ fmt.Printf("\033[32;40m"+format+"\033[0m\n", args...)
+}
diff --git a/wasm/server/profiles/dev/log.yml b/wasm/server/profiles/dev/log.yml
new file mode 100644
index 0000000..9330cda
--- /dev/null
+++ b/wasm/server/profiles/dev/log.yml
@@ -0,0 +1,45 @@
+#
+# 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.
+#
+level: "debug"
+development: true
+disableCaller: false
+disableStacktrace: false
+sampling:
+encoding: "console"
+
+# encoder
+encoderConfig:
+ messageKey: "message"
+ levelKey: "level"
+ timeKey: "time"
+ nameKey: "logger"
+ callerKey: "caller"
+ stacktraceKey: "stacktrace"
+ lineEnding: ""
+ levelEncoder: "capitalColor"
+ timeEncoder: "iso8601"
+ durationEncoder: "seconds"
+ callerEncoder: "short"
+ nameEncoder: ""
+
+outputPaths:
+ - "stderr"
+errorOutputPaths:
+ - "stderr"
+initialFields:
diff --git a/wasm/server/profiles/dev/server.yml b/wasm/server/profiles/dev/server.yml
new file mode 100644
index 0000000..17ac8bf
--- /dev/null
+++ b/wasm/server/profiles/dev/server.yml
@@ -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.
+#
+# dubbo server yaml configure file
+# application config
+dubbo:
+ application:
+ name: UserService
+ registries:
+ zk:
+ protocol: zookeeper
+ timeout: 3s
+ address: 127.0.0.1:2181
+ protocols:
+ dubbo:
+ name: dubbo
+ port: 20000
+ provider:
+ registry-ids: zk
+ services:
+ UserProvider:
+ group: test
+ version: 1.0.0
+ cluster: test_dubbo
+ serialization: hessian2
+ interface: com.dubbogo.pixiu.UserService
\ No newline at end of file
diff --git a/wasm/test/pixiu_test.go b/wasm/test/pixiu_test.go
new file mode 100644
index 0000000..092b431
--- /dev/null
+++ b/wasm/test/pixiu_test.go
@@ -0,0 +1,54 @@
+/*
+ * 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 test
+
+import (
+ "github.com/apache/dubbo-go-pixiu/pixiu/pkg/logger"
+ "io/ioutil"
+ "net/http"
+ "strings"
+ "testing"
+ "time"
+)
+
+import (
+ "github.com/stretchr/testify/assert"
+)
+
+func TestPost1(t *testing.T) {
+ url := "http://localhost:8883/UserService/com.dubbogo.pixiu.UserService/GetUserByName"
+ data := "{\"types\":\"string\",\"values\":\"tc\"}"
+ client := &http.Client{Timeout: 5 * time.Second}
+ req, err := http.NewRequest("POST", url, strings.NewReader(data))
+ assert.NoError(t, err)
+ req.Header.Add("Content-Type", "application/json")
+ req.Header.Add("x-dubbo-http1.1-dubbo-version", "1.0.0")
+ req.Header.Add("x-dubbo-service-protocol", "dubbo")
+ req.Header.Add("x-dubbo-service-version", "1.0.0")
+ req.Header.Add("x-dubbo-service-group", "test")
+ resp, err := client.Do(req)
+ assert.NoError(t, err)
+ assert.NotNil(t, resp)
+
+ assert.Equal(t, 200, resp.StatusCode)
+ s, _ := ioutil.ReadAll(resp.Body)
+ s2 := string(s)
+ assert.True(t, strings.Contains(s2, "0001"))
+ assert.True(t, strings.Contains(s2, "pixiu-wasm"))
+ logger.Info("result : %v", s2)
+}