This is an automated email from the ASF dual-hosted git repository. iluo pushed a commit to branch makefile in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/makefile by this push: new 20e4f90 make integration test works for nacos 20e4f90 is described below commit 20e4f90cb7bdb2892d608d3172847e93fc003c01 Author: Ian Luo <ian....@gmail.com> AuthorDate: Fri Oct 30 11:43:37 2020 +0800 make integration test works for nacos --- configcenter/apollo/README.md | 38 ---- configcenter/nacos/README.md | 11 -- .../nacos/dubbo/go-client/assembly/bin/load.sh | 203 --------------------- .../dubbo/go-client/assembly/common/app.properties | 23 --- .../nacos/dubbo/go-client/assembly/common/build.sh | 83 --------- .../nacos/dubbo/go-client/assembly/linux/dev.sh | 36 ---- .../dubbo/go-client/assembly/linux/release.sh | 35 ---- .../nacos/dubbo/go-client/assembly/linux/test.sh | 35 ---- .../nacos/dubbo/go-client/assembly/mac/dev.sh | 36 ---- .../nacos/dubbo/go-client/assembly/mac/release.sh | 34 ---- .../nacos/dubbo/go-client/assembly/mac/test.sh | 34 ---- .../nacos/dubbo/go-client/assembly/windows/dev.sh | 34 ---- .../dubbo/go-client/assembly/windows/release.sh | 34 ---- .../nacos/dubbo/go-client/assembly/windows/test.sh | 34 ---- .../dubbo/config/user-info-client/dubbo.properties | 1 - .../nacos/dubbo/go-server/assembly/bin/load.sh | 151 --------------- .../dubbo/go-server/assembly/common/app.properties | 23 --- .../nacos/dubbo/go-server/assembly/common/build.sh | 80 -------- .../nacos/dubbo/go-server/assembly/linux/dev.sh | 36 ---- .../dubbo/go-server/assembly/linux/release.sh | 36 ---- .../nacos/dubbo/go-server/assembly/linux/test.sh | 36 ---- .../nacos/dubbo/go-server/assembly/mac/dev.sh | 36 ---- .../nacos/dubbo/go-server/assembly/mac/release.sh | 36 ---- .../nacos/dubbo/go-server/assembly/mac/test.sh | 36 ---- .../nacos/dubbo/go-server/assembly/windows/dev.sh | 36 ---- .../dubbo/go-server/assembly/windows/release.sh | 36 ---- .../nacos/dubbo/go-server/assembly/windows/test.sh | 36 ---- .../dubbo/config/user-info-server/dubbo.properties | 4 - .../go-client/app => go-client/cmd}/client.go | 65 ++----- .../profiles/dev => go-client/conf}/client.yml | 41 +++-- .../profiles/dev => go-client/conf}/log.yml | 56 +++--- .../{dubbo/go-client/app => go-client/pkg}/user.go | 38 ++-- .../nacos/{dubbo => }/go-server/app/server.go | 0 .../nacos/{dubbo => }/go-server/app/user.go | 0 .../app/client.go => go-server/cmd/server.go} | 39 ++-- .../profiles/dev => go-server/conf}/client.yml | 41 +++-- .../profiles/dev => go-server/conf}/log.yml | 56 +++--- .../profiles/dev => go-server/conf}/server.yml | 34 ++-- .../nacos/go-server/docker/docker-compose.yml | 17 ++ .../{dubbo/go-client/app => go-server/pkg}/user.go | 23 ++- .../tests/integration/main_test.go} | 31 +++- .../tests/integration/userprovider_test.go} | 42 ++--- 42 files changed, 240 insertions(+), 1496 deletions(-) diff --git a/configcenter/apollo/README.md b/configcenter/apollo/README.md deleted file mode 100644 index 7f986f9..0000000 --- a/configcenter/apollo/README.md +++ /dev/null @@ -1,38 +0,0 @@ -### 1.Run apollo as config center - -* download this folder as below - -[docker-quick-start](https://github.com/ctripcorp/apollo/tree/master/scripts/docker-quick-start) - -* enter docker-quick-start folder and run - -```docker-compose up``` - -### 2.Run java server & java client following [README](https://github.com/dubbogo/dubbo-samples/blob/master/golang/README.md) - -* Set config item **app.id** in /resources/META-INF/app.properties like - -``` -app.id=application -``` - -* Set apollo meta url in /resources/META-INF/spring/dubbo.provider.xml and /resources/META-INF/spring/dubbo.consumer.xml like - -``` -<dubbo:config-center protocol="apollo" address="1.1.1.1:8080"/> -``` - -Build and run it , enjoy. - -### 3.Run java server & go client - -Stop java client. Copy go client configuration file [dubbo.properties](https://github.com/dubbogo/dubbo-samples/golang/blob/master/configcenter/apollo/dubbo/go-client/profiles/dev/dubbo/config/user-info-client/dubbo.properties) as -namespace dubbo.properties in apollo. - -Then start go client following [README](https://github.com/dubbogo/dubbo-samples/blob/master/golang/README.md). - -### 4.Run go server - -The same as step 3. Copy go server configuration file [dubbo.properties](https://github.com/dubbogo/dubbo-samples/blob/master/golang/configcenter/apollo/dubbo/go-server/profiles/dev/dubbo/config/user-info-server/dubbo.properties) as -namespace dubbo.properties in apollo. - diff --git a/configcenter/nacos/README.md b/configcenter/nacos/README.md deleted file mode 100644 index 614760e..0000000 --- a/configcenter/nacos/README.md +++ /dev/null @@ -1,11 +0,0 @@ -### 1.Run naocs as config center - -### 2.Add config (dataId=dubbo.properties group=dubbo) - dubbo.service.com.ikurento.user.UserProvider.cluster=failback - dubbo.service.com.ikurento.user.UserProvider.protocol=myDubbo - dubbo.protocols.myDubbo.port=20000 - dubbo.protocols.myDubbo.name=dubbo - -### 3.Run go server - -### 4.Run go client diff --git a/configcenter/nacos/dubbo/go-client/assembly/bin/load.sh b/configcenter/nacos/dubbo/go-client/assembly/bin/load.sh deleted file mode 100644 index ffa240b..0000000 --- a/configcenter/nacos/dubbo/go-client/assembly/bin/load.sh +++ /dev/null @@ -1,203 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - -APP_NAME="APPLICATION_NAME" -APP_ARGS="" -SLEEP_INTERVAL=5 -MAX_LIFETIME=4000 - -PROJECT_HOME="" -OS_NAME=`uname` -if [[ ${OS_NAME} != "Windows" ]]; then - PROJECT_HOME=`pwd` - PROJECT_HOME=${PROJECT_HOME}"/" -else - APP_NAME="APPLICATION_NAME.exe" -fi - -export CONF_CONSUMER_FILE_PATH=${PROJECT_HOME}"TARGET_CONF_FILE" -export APP_LOG_CONF_FILE=${PROJECT_HOME}"TARGET_LOG_CONF_FILE" -# export GOTRACEBACK=system -# export GODEBUG=gctrace=1 - -usage() { - echo "Usage: $0 start [conf suffix]" - echo " $0 stop" - echo " $0 term" - echo " $0 restart" - echo " $0 list" - echo " $0 monitor" - echo " $0 crontab" - exit -} - -start() { - arg=$1 - if [ "$arg" = "" ];then - echo "No registry type! Default client.yml!" - else - export CONF_CONSUMER_FILE_PATH=${CONF_CONSUMER_FILE_PATH//\.yml/\_$arg\.yml} - fi - if [ ! -f "${CONF_CONSUMER_FILE_PATH}" ];then - echo $CONF_CONSUMER_FILE_PATH" is not existing!" - return - fi - APP_LOG_PATH=${PROJECT_HOME}"logs/" - mkdir -p ${APP_LOG_PATH} - APP_BIN=${PROJECT_HOME}sbin/${APP_NAME} - chmod u+x ${APP_BIN} - # CMD="nohup ${APP_BIN} ${APP_ARGS} >>${APP_NAME}.nohup.out 2>&1 &" - CMD="${APP_BIN}" - eval ${CMD} - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - CUR=`date +%FT%T` - if [ "${PID}" != "" ]; then - for p in ${PID} - do - echo "start ${APP_NAME} ( pid =" ${p} ") at " ${CUR} - done - fi -} - -stop() { - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - if [ "${PID}" != "" ]; - then - for ps in ${PID} - do - echo "kill -SIGINT ${APP_NAME} ( pid =" ${ps} ")" - kill -2 ${ps} - done - fi -} - - -term() { - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - if [ "${PID}" != "" ]; - then - for ps in ${PID} - do - echo "kill -9 ${APP_NAME} ( pid =" ${ps} ")" - kill -9 ${ps} - done - fi -} - -list() { - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s\n", $1, $2, $9, $10)}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s,%s\n", $1, $4, $6, $7, $8)}'` - fi - - if [ "${PID}" != "" ]; then - echo "list ${APP_NAME}" - - if [[ ${OS_NAME} == "Linux" || ${OS_NAME} == "Darwin" ]]; then - echo "index: user, pid, start, duration" - else - echo "index: PID, WINPID, UID, STIME, COMMAND" - fi - idx=0 - for ps in ${PID} - do - echo "${idx}: ${ps}" - ((idx ++)) - done - fi -} - -monitor() { - idx=0 - while true; do - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - if [[ "${PID}" == "" ]]; then - start - idx=0 - fi - - ((LIFE=idx*${SLEEP_INTERVAL})) - echo "${APP_NAME} ( pid = " ${PID} ") has been working in normal state for " $LIFE " seconds." - ((idx ++)) - sleep ${SLEEP_INTERVAL} - done -} - -crontab() { - idx=0 - while true; do - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - if [[ "${PID}" == "" ]]; then - start - idx=0 - fi - - ((LIFE=idx*${SLEEP_INTERVAL})) - echo "${APP_NAME} ( pid = " ${PID} ") has been working in normal state for " $LIFE " seconds." - ((idx ++)) - sleep ${SLEEP_INTERVAL} - if [[ ${LIFE} -gt ${MAX_LIFETIME} ]]; then - kill -9 ${PID} - fi - done -} - -opt=$1 -case C"$opt" in - Cstart) - start $2 - ;; - Cstop) - stop - ;; - Cterm) - term - ;; - Crestart) - term - start $2 - ;; - Clist) - list - ;; - Cmonitor) - monitor - ;; - Ccrontab) - crontab - ;; - C*) - usage - ;; -esac - diff --git a/configcenter/nacos/dubbo/go-client/assembly/common/app.properties b/configcenter/nacos/dubbo/go-client/assembly/common/app.properties deleted file mode 100644 index e10868f..0000000 --- a/configcenter/nacos/dubbo/go-client/assembly/common/app.properties +++ /dev/null @@ -1,23 +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. - - -export TARGET_EXEC_NAME="user_info_client" -# BUILD_PACKAGE="dubbogo-examples/user-info/client/app" -export BUILD_PACKAGE="app" - -export TARGET_CONF_FILE="conf/client.yml" -export TARGET_LOG_CONF_FILE="conf/log.yml" diff --git a/configcenter/nacos/dubbo/go-client/assembly/common/build.sh b/configcenter/nacos/dubbo/go-client/assembly/common/build.sh deleted file mode 100644 index d38f889..0000000 --- a/configcenter/nacos/dubbo/go-client/assembly/common/build.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - -rm -rf target/ - -PROJECT_HOME=`pwd` -TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} - -TARGET_SBIN_NAME=${TARGET_EXEC_NAME} -version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` -if [[ ${GOOS} == "windows" ]]; then - TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe -fi -TARGET_NAME=${TARGET_FOLDER}/${TARGET_SBIN_NAME} -if [[ $PROFILE == "dev" || $PROFILE == "test" ]]; then - # GFLAGS=-gcflags "-N -l" -race -x -v # -x会把go build的详细过程输出 - # GFLAGS=-gcflags "-N -l" -race -v - # GFLAGS="-gcflags \"-N -l\" -v" - cd ${BUILD_PACKAGE} && GOOS=$GOOS GOARCH=$GOARCH GO111MODULE=on go build -gcflags "-N -l" -x -v -i -o ${TARGET_NAME} && cd - -else - # -s去掉符号表(然后panic时候的stack trace就没有任何文件名/行号信息了,这个等价于普通C/C++程序被strip的效果), - # -w去掉DWARF调试信息,得到的程序就不能用gdb调试了。-s和-w也可以分开使用,一般来说如果不打算用gdb调试, - # -w基本没啥损失。-s的损失就有点大了。 - cd ${BUILD_PACKAGE} && GOOS=$GOOS GOARCH=$GOARCH GO111MODULE=on go build -ldflags "-w" -x -v -i -o ${TARGET_NAME} && cd - -fi - -TAR_NAME=${TARGET_EXEC_NAME}-${version}-`date "+%Y%m%d-%H%M"`-${PROFILE} - -mkdir -p ${TARGET_FOLDER}/${TAR_NAME} - -SBIN_DIR=${TARGET_FOLDER}/${TAR_NAME}/sbin -BIN_DIR=${TARGET_FOLDER}/${TAR_NAME} -CONF_DIR=${TARGET_FOLDER}/${TAR_NAME}/conf - -mkdir -p ${SBIN_DIR} -mkdir -p ${CONF_DIR} - -mv ${TARGET_NAME} ${SBIN_DIR} -cp -r assembly/bin ${BIN_DIR} -cd ${BIN_DIR}/bin/ && mv load.sh load_${TARGET_EXEC_NAME}.sh && cd - - -platform=$(uname) -# modify APPLICATION_NAME -if [ ${platform} == "Darwin" ]; then - sed -i "" "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* -else - sed -i "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* -fi - -# modify TARGET_CONF_FILE -if [ ${platform} == "Darwin" ]; then - sed -i "" "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* -else - sed -i "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* -fi - -# modify TARGET_LOG_CONF_FILE -if [ ${platform} == "Darwin" ]; then - sed -i "" "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* -else - sed -i "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* -fi - -cp -r profiles/${PROFILE}/* ${CONF_DIR} - -cd ${TARGET_FOLDER} - -tar czf ${TAR_NAME}.tar.gz ${TAR_NAME}/* - diff --git a/configcenter/nacos/dubbo/go-client/assembly/linux/dev.sh b/configcenter/nacos/dubbo/go-client/assembly/linux/dev.sh deleted file mode 100644 index eada737..0000000 --- a/configcenter/nacos/dubbo/go-client/assembly/linux/dev.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -export PROFILE="dev" - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-client/assembly/linux/release.sh b/configcenter/nacos/dubbo/go-client/assembly/linux/release.sh deleted file mode 100644 index 10eb3d7..0000000 --- a/configcenter/nacos/dubbo/go-client/assembly/linux/release.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -export PROFILE="release" -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-client/assembly/linux/test.sh b/configcenter/nacos/dubbo/go-client/assembly/linux/test.sh deleted file mode 100644 index 78b650c..0000000 --- a/configcenter/nacos/dubbo/go-client/assembly/linux/test.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -export PROFILE="test" -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-client/assembly/mac/dev.sh b/configcenter/nacos/dubbo/go-client/assembly/mac/dev.sh deleted file mode 100644 index c828476..0000000 --- a/configcenter/nacos/dubbo/go-client/assembly/mac/dev.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=darwin -export GOARCH=amd64 - -export PROFILE="dev" - -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-client/assembly/mac/release.sh b/configcenter/nacos/dubbo/go-client/assembly/mac/release.sh deleted file mode 100644 index 91c2dfe..0000000 --- a/configcenter/nacos/dubbo/go-client/assembly/mac/release.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=darwin -export GOARCH=amd64 - -export PROFILE="release" -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-client/assembly/mac/test.sh b/configcenter/nacos/dubbo/go-client/assembly/mac/test.sh deleted file mode 100644 index a7853f5..0000000 --- a/configcenter/nacos/dubbo/go-client/assembly/mac/test.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - -set -e - -export GOOS=darwin -export GOARCH=amd64 - -export PROFILE="test" -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-client/assembly/windows/dev.sh b/configcenter/nacos/dubbo/go-client/assembly/windows/dev.sh deleted file mode 100644 index 10a3866..0000000 --- a/configcenter/nacos/dubbo/go-client/assembly/windows/dev.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -export PROFILE="dev" -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-client/assembly/windows/release.sh b/configcenter/nacos/dubbo/go-client/assembly/windows/release.sh deleted file mode 100644 index 21af573..0000000 --- a/configcenter/nacos/dubbo/go-client/assembly/windows/release.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=windows -export GOARCH=amd64 - -export PROFILE="release" -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-client/assembly/windows/test.sh b/configcenter/nacos/dubbo/go-client/assembly/windows/test.sh deleted file mode 100644 index 2104da8..0000000 --- a/configcenter/nacos/dubbo/go-client/assembly/windows/test.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=windows -export GOARCH=amd64 - -export PROFILE="test" -export PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then - . ${PROJECT_HOME}/assembly/common/app.properties -fi - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then - sh ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-client/profiles/dev/dubbo/config/user-info-client/dubbo.properties b/configcenter/nacos/dubbo/go-client/profiles/dev/dubbo/config/user-info-client/dubbo.properties deleted file mode 100644 index a7851e7..0000000 --- a/configcenter/nacos/dubbo/go-client/profiles/dev/dubbo/config/user-info-client/dubbo.properties +++ /dev/null @@ -1 +0,0 @@ -dubbo.service.com.ikurento.user.UserProvider.cluster=failover \ No newline at end of file diff --git a/configcenter/nacos/dubbo/go-server/assembly/bin/load.sh b/configcenter/nacos/dubbo/go-server/assembly/bin/load.sh deleted file mode 100644 index 90077c2..0000000 --- a/configcenter/nacos/dubbo/go-server/assembly/bin/load.sh +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - -APP_NAME="APPLICATION_NAME" -APP_ARGS="" - - -PROJECT_HOME="" -OS_NAME=`uname` -if [[ ${OS_NAME} != "Windows" ]]; then - PROJECT_HOME=`pwd` - PROJECT_HOME=${PROJECT_HOME}"/" -fi - -export CONF_PROVIDER_FILE_PATH=${PROJECT_HOME}"TARGET_CONF_FILE" -export APP_LOG_CONF_FILE=${PROJECT_HOME}"TARGET_LOG_CONF_FILE" - -usage() { - echo "Usage: $0 start [conf suffix]" - echo " $0 stop" - echo " $0 term" - echo " $0 restart" - echo " $0 list" - echo " $0 monitor" - echo " $0 crontab" - exit -} - -start() { - arg=$1 - if [ "$arg" = "" ];then - echo "No registry type! Default server.yml!" - else - export CONF_PROVIDER_FILE_PATH=${CONF_PROVIDER_FILE_PATH//\.yml/\_$arg\.yml} - fi - if [ ! -f "${CONF_PROVIDER_FILE_PATH}" ];then - echo $CONF_PROVIDER_FILE_PATH" is not existing!" - return - fi - APP_LOG_PATH="${PROJECT_HOME}logs/" - mkdir -p ${APP_LOG_PATH} - APP_BIN=${PROJECT_HOME}sbin/${APP_NAME} - chmod u+x ${APP_BIN} - # CMD="nohup ${APP_BIN} ${APP_ARGS} >>${APP_NAME}.nohup.out 2>&1 &" - CMD="${APP_BIN}" - eval ${CMD} - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - CUR=`date +%FT%T` - if [ "${PID}" != "" ]; then - for p in ${PID} - do - echo "start ${APP_NAME} ( pid =" ${p} ") at " ${CUR} - done - fi -} - -stop() { - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - if [ "${PID}" != "" ]; - then - for ps in ${PID} - do - echo "kill -SIGINT ${APP_NAME} ( pid =" ${ps} ")" - kill -2 ${ps} - done - fi -} - - -term() { - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'` - fi - if [ "${PID}" != "" ]; - then - for ps in ${PID} - do - echo "kill -9 ${APP_NAME} ( pid =" ${ps} ")" - kill -9 ${ps} - done - fi -} - -list() { - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s\n", $1, $2, $9, $10)}'` - if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then - PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s,%s\n", $1, $4, $6, $7, $8)}'` - fi - - if [ "${PID}" != "" ]; then - echo "list ${APP_NAME}" - - if [[ ${OS_NAME} == "Linux" || ${OS_NAME} == "Darwin" ]]; then - echo "index: user, pid, start, duration" - else - echo "index: PID, WINPID, UID, STIME, COMMAND" - fi - idx=0 - for ps in ${PID} - do - echo "${idx}: ${ps}" - ((idx ++)) - done - fi -} - -opt=$1 -case C"$opt" in - Cstart) - start $2 - ;; - Cstop) - stop - ;; - Cterm) - term - ;; - Crestart) - term - start $2 - ;; - Clist) - list - ;; - C*) - usage - ;; -esac - diff --git a/configcenter/nacos/dubbo/go-server/assembly/common/app.properties b/configcenter/nacos/dubbo/go-server/assembly/common/app.properties deleted file mode 100644 index 1f0827e..0000000 --- a/configcenter/nacos/dubbo/go-server/assembly/common/app.properties +++ /dev/null @@ -1,23 +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. - - -TARGET_EXEC_NAME="user_info_server" -# BUILD_PACKAGE="dubbogo-examples/user-info/server/app" -BUILD_PACKAGE="app" - -TARGET_CONF_FILE="conf/server.yml" -TARGET_LOG_CONF_FILE="conf/log.yml" diff --git a/configcenter/nacos/dubbo/go-server/assembly/common/build.sh b/configcenter/nacos/dubbo/go-server/assembly/common/build.sh deleted file mode 100644 index d90d026..0000000 --- a/configcenter/nacos/dubbo/go-server/assembly/common/build.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - -rm -rf target/ - -PROJECT_HOME=`pwd` -TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS} - -TARGET_SBIN_NAME=${TARGET_EXEC_NAME} -version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'` -if [[ ${GOOS} == "windows" ]]; then - TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe -fi -TARGET_NAME=${TARGET_FOLDER}/${TARGET_SBIN_NAME} -if [[ $PROFILE = "test" ]]; then - # GFLAGS=-gcflags "-N -l" -race -x -v # -x会把go build的详细过程输出 - # GFLAGS=-gcflags "-N -l" -race -v - # GFLAGS="-gcflags \"-N -l\" -v" - cd ${BUILD_PACKAGE} && GO111MODULE=on go build -gcflags "-N -l" -x -v -i -o ${TARGET_NAME} && cd - -else - # -s去掉符号表(然后panic时候的stack trace就没有任何文件名/行号信息了,这个等价于普通C/C++程序被strip的效果), - # -w去掉DWARF调试信息,得到的程序就不能用gdb调试了。-s和-w也可以分开使用,一般来说如果不打算用gdb调试, - # -w基本没啥损失。-s的损失就有点大了。 - cd ${BUILD_PACKAGE} && GO111MODULE=on go build -ldflags "-w" -x -v -i -o ${TARGET_NAME} && cd - -fi - -TAR_NAME=${TARGET_EXEC_NAME}-${version}-`date "+%Y%m%d-%H%M"`-${PROFILE} - -mkdir -p ${TARGET_FOLDER}/${TAR_NAME} - -SBIN_DIR=${TARGET_FOLDER}/${TAR_NAME}/sbin -BIN_DIR=${TARGET_FOLDER}/${TAR_NAME} -CONF_DIR=${TARGET_FOLDER}/${TAR_NAME}/conf - -mkdir -p ${SBIN_DIR} -mkdir -p ${CONF_DIR} - -mv ${TARGET_NAME} ${SBIN_DIR} -cp -r assembly/bin ${BIN_DIR} -# modify APPLICATION_NAME -# OS=`uname` -# if [[ $OS=="Darwin" ]]; then -if [ "$(uname)" == "Darwin" ]; then - sed -i "" "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* -else - sed -i "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/* -fi -# modify TARGET_CONF_FILE -if [ "$(uname)" == "Darwin" ]; then - sed -i "" "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* -else - sed -i "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/* -fi -# modify TARGET_LOG_CONF_FILE -if [ "$(uname)" == "Darwin" ]; then - sed -i "" "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* -else - sed -i "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/* -fi - -cp -r profiles/${PROFILE}/* ${CONF_DIR} - -cd ${TARGET_FOLDER} - -tar czf ${TAR_NAME}.tar.gz ${TAR_NAME}/* - diff --git a/configcenter/nacos/dubbo/go-server/assembly/linux/dev.sh b/configcenter/nacos/dubbo/go-server/assembly/linux/dev.sh deleted file mode 100644 index d830ac9..0000000 --- a/configcenter/nacos/dubbo/go-server/assembly/linux/dev.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -PROFILE=dev - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-server/assembly/linux/release.sh b/configcenter/nacos/dubbo/go-server/assembly/linux/release.sh deleted file mode 100644 index 9930380..0000000 --- a/configcenter/nacos/dubbo/go-server/assembly/linux/release.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -PROFILE=release - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-server/assembly/linux/test.sh b/configcenter/nacos/dubbo/go-server/assembly/linux/test.sh deleted file mode 100644 index 87144bb..0000000 --- a/configcenter/nacos/dubbo/go-server/assembly/linux/test.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=linux -export GOARCH=amd64 - -PROFILE=test - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-server/assembly/mac/dev.sh b/configcenter/nacos/dubbo/go-server/assembly/mac/dev.sh deleted file mode 100644 index 3a7659b..0000000 --- a/configcenter/nacos/dubbo/go-server/assembly/mac/dev.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=darwin -export GOARCH=amd64 - -PROFILE=dev - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-server/assembly/mac/release.sh b/configcenter/nacos/dubbo/go-server/assembly/mac/release.sh deleted file mode 100644 index 1c4bce4..0000000 --- a/configcenter/nacos/dubbo/go-server/assembly/mac/release.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=darwin -export GOARCH=amd64 - -PROFILE=release - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-server/assembly/mac/test.sh b/configcenter/nacos/dubbo/go-server/assembly/mac/test.sh deleted file mode 100644 index 69206e3..0000000 --- a/configcenter/nacos/dubbo/go-server/assembly/mac/test.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - -set -e - -export GOOS=darwin -export GOARCH=amd64 - -PROFILE=test - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi - diff --git a/configcenter/nacos/dubbo/go-server/assembly/windows/dev.sh b/configcenter/nacos/dubbo/go-server/assembly/windows/dev.sh deleted file mode 100644 index 011fb41..0000000 --- a/configcenter/nacos/dubbo/go-server/assembly/windows/dev.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=windows -export GOARCH=amd64 - -PROFILE=dev - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-server/assembly/windows/release.sh b/configcenter/nacos/dubbo/go-server/assembly/windows/release.sh deleted file mode 100644 index 679a26a..0000000 --- a/configcenter/nacos/dubbo/go-server/assembly/windows/release.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=windows -export GOARCH=amd64 - -PROFILE=release - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-server/assembly/windows/test.sh b/configcenter/nacos/dubbo/go-server/assembly/windows/test.sh deleted file mode 100644 index 4a36de0..0000000 --- a/configcenter/nacos/dubbo/go-server/assembly/windows/test.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env bash -# -# 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. - - - -set -e - -export GOOS=windows -export GOARCH=amd64 - -PROFILE=test - -PROJECT_HOME=`pwd` - -if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then -. ${PROJECT_HOME}/assembly/common/app.properties -fi - - -if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then -. ${PROJECT_HOME}/assembly/common/build.sh -fi diff --git a/configcenter/nacos/dubbo/go-server/profiles/dev/dubbo/config/user-info-server/dubbo.properties b/configcenter/nacos/dubbo/go-server/profiles/dev/dubbo/config/user-info-server/dubbo.properties deleted file mode 100644 index 54c19b1..0000000 --- a/configcenter/nacos/dubbo/go-server/profiles/dev/dubbo/config/user-info-server/dubbo.properties +++ /dev/null @@ -1,4 +0,0 @@ -dubbo.service.com.ikurento.user.UserProvider.cluster=failback -dubbo.service.com.ikurento.user.UserProvider.protocol=myDubbo -dubbo.protocols.myDubbo.port=20000 -dubbo.protocols.myDubbo.name=dubbo diff --git a/configcenter/nacos/dubbo/go-client/app/client.go b/configcenter/nacos/go-client/cmd/client.go similarity index 64% copy from configcenter/nacos/dubbo/go-client/app/client.go copy to configcenter/nacos/go-client/cmd/client.go index e457052..5cf3340 100644 --- a/configcenter/nacos/dubbo/go-client/app/client.go +++ b/configcenter/nacos/go-client/cmd/client.go @@ -19,75 +19,48 @@ package main import ( "context" - "fmt" "os" - "os/signal" - "syscall" "time" ) import ( + hessian "github.com/apache/dubbo-go-hessian2" + "github.com/apache/dubbo-samples/golang/helloworld/go-client/pkg" "github.com/dubbogo/gost/log" ) import ( - hessian "github.com/apache/dubbo-go-hessian2" - "github.com/apache/dubbo-go/common/logger" + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/config_center/nacos" + _ "github.com/apache/dubbo-go/filter/filter_impl" _ "github.com/apache/dubbo-go/protocol/dubbo" _ "github.com/apache/dubbo-go/registry/protocol" - - _ "github.com/apache/dubbo-go/filter/filter_impl" - - _ "github.com/apache/dubbo-go/cluster/cluster_impl" - _ "github.com/apache/dubbo-go/cluster/loadbalance" - _ "github.com/apache/dubbo-go/config_center/nacos" _ "github.com/apache/dubbo-go/registry/zookeeper" ) -var ( - survivalTimeout int = 10e9 -) +var userProvider = new(pkg.UserProvider) + +func init() { + config.SetConsumerService(userProvider) + hessian.RegisterPOJO(&pkg.User{}) +} -// they are necessary: -// export CONF_CONSUMER_FILE_PATH="xxx" -// export APP_LOG_CONF_FILE="xxx" +// need to setup environment variable "CONF_CONSUMER_FILE_PATH" to "conf/client.yml" before run func main() { - hessian.RegisterPOJO(&User{}) + hessian.RegisterPOJO(&pkg.User{}) config.Load() - time.Sleep(1e9) + time.Sleep(3 * time.Second) gxlog.CInfo("\n\n\nstart to test dubbo") - user := &User{} + user := &pkg.User{} err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user) if err != nil { - panic(err) + gxlog.CError("error: %v\n", err) + os.Exit(1) + return } gxlog.CInfo("response result: %v\n", user) - initSignal() -} - -func initSignal() { - signals := make(chan os.Signal, 1) - // It is not possible to block SIGKILL or syscall.SIGSTOP - signal.Notify(signals, os.Interrupt, os.Kill, 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("app exit now...") - return - } - } } diff --git a/configcenter/nacos/dubbo/go-client/profiles/dev/client.yml b/configcenter/nacos/go-client/conf/client.yml similarity index 67% copy from configcenter/nacos/dubbo/go-client/profiles/dev/client.yml copy to configcenter/nacos/go-client/conf/client.yml index 0657bcb..3472df0 100644 --- a/configcenter/nacos/dubbo/go-client/profiles/dev/client.yml +++ b/configcenter/nacos/go-client/conf/client.yml @@ -1,51 +1,52 @@ +# dubbo client yaml configure file check: true # client -request_timeout : "3s" +request_timeout: "3s" # connect timeout -connect_timeout : "3s" - -# application config -application: - organization : "ikurento.com" - name : "BDTService" - module : "dubbogo user-info client" - version : "0.0.1" - owner : "ZX" - environment : "dev" +connect_timeout: "3s" +# config center config config_center: protocol: "nacos" address: "127.0.0.1:8848" -registries : +# application config +application: + organization: "dubbo.io" + name: "UserInfoClient" + module: "dubbo-go user-info client" + version: "0.0.1" + environment: "dev" + +# registry config +registries: "demoZk": protocol: "zookeeper" - timeout : "3s" + timeout: "3s" address: "127.0.0.1:2181" username: "" password: "" - +# reference config references: "UserProvider": - # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 registry: "demoZk" - protocol : "dubbo" - interface : "com.ikurento.user.UserProvider" + protocol: "dubbo" + interface: "org.apache.dubbo.UserProvider" cluster: "failover" - methods : + methods: - name: "GetUser" retries: 3 - +# protocol config protocol_conf: dubbo: reconnect_interval: 0 connection_number: 1 heartbeat_period: "5s" session_timeout: "180s" - pool_size: 4 + pool_size: 64 pool_ttl: 600 getty_session_param: compress_encoding: false diff --git a/configcenter/nacos/dubbo/go-client/profiles/dev/log.yml b/configcenter/nacos/go-client/conf/log.yml similarity index 88% rename from configcenter/nacos/dubbo/go-client/profiles/dev/log.yml rename to configcenter/nacos/go-client/conf/log.yml index 59fa427..d0400fe 100644 --- a/configcenter/nacos/dubbo/go-client/profiles/dev/log.yml +++ b/configcenter/nacos/go-client/conf/log.yml @@ -1,28 +1,28 @@ - -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: + +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: "capital" + timeEncoder: "iso8601" + durationEncoder: "seconds" + callerEncoder: "short" + nameEncoder: "" + +outputPaths: + - "stderr" +errorOutputPaths: + - "stderr" +initialFields: diff --git a/configcenter/nacos/dubbo/go-client/app/user.go b/configcenter/nacos/go-client/pkg/user.go similarity index 60% copy from configcenter/nacos/dubbo/go-client/app/user.go copy to configcenter/nacos/go-client/pkg/user.go index ff4486f..abcad09 100644 --- a/configcenter/nacos/dubbo/go-client/app/user.go +++ b/configcenter/nacos/go-client/pkg/user.go @@ -15,25 +15,17 @@ * limitations under the License. */ -package main +package pkg import ( "context" + "github.com/apache/dubbo-go/common" + "github.com/apache/dubbo-go/protocol" + "github.com/apache/dubbo-go/remoting" + gxlog "github.com/dubbogo/gost/log" "time" ) -import ( - hessian "github.com/apache/dubbo-go-hessian2" - "github.com/apache/dubbo-go/config" -) - -var userProvider = new(UserProvider) - -func init() { - config.SetConsumerService(userProvider) - hessian.RegisterPOJO(&User{}) -} - type User struct { Id string Name string @@ -43,12 +35,30 @@ type User struct { type UserProvider struct { GetUser func(ctx context.Context, req []interface{}, rsp *User) error + Ch chan *User } func (u *UserProvider) Reference() string { return "UserProvider" } +// to enable async call: +// 1. need to implement AsyncCallbackService +// 2. need to specify references -> UserProvider -> async in conf/client.yml +func (u *UserProvider) CallBack(res common.CallbackResponse) { + gxlog.CInfo("CallBack res: %v", res) + if r, ok := res.(remoting.AsyncCallbackResponse); ok { + if reply, ok := r.Reply.(*remoting.Response); ok { + if result, ok := reply.Result.(*protocol.RPCResult); ok { + if user, ok := result.Rest.(*User); ok { + u.Ch <- user + } + } + } + } + u.Ch <- nil +} + func (User) JavaClassName() string { - return "com.ikurento.user.User" + return "org.apache.dubbo.User" } diff --git a/configcenter/nacos/dubbo/go-server/app/server.go b/configcenter/nacos/go-server/app/server.go similarity index 100% rename from configcenter/nacos/dubbo/go-server/app/server.go rename to configcenter/nacos/go-server/app/server.go diff --git a/configcenter/nacos/dubbo/go-server/app/user.go b/configcenter/nacos/go-server/app/user.go similarity index 100% rename from configcenter/nacos/dubbo/go-server/app/user.go rename to configcenter/nacos/go-server/app/user.go diff --git a/configcenter/nacos/dubbo/go-client/app/client.go b/configcenter/nacos/go-server/cmd/server.go similarity index 76% rename from configcenter/nacos/dubbo/go-client/app/client.go rename to configcenter/nacos/go-server/cmd/server.go index e457052..d2847dc 100644 --- a/configcenter/nacos/dubbo/go-client/app/client.go +++ b/configcenter/nacos/go-server/cmd/server.go @@ -18,7 +18,6 @@ package main import ( - "context" "fmt" "os" "os/signal" @@ -27,52 +26,38 @@ import ( ) import ( - "github.com/dubbogo/gost/log" -) - -import ( hessian "github.com/apache/dubbo-go-hessian2" + + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" "github.com/apache/dubbo-go/common/logger" _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/config_center/nacos" + _ "github.com/apache/dubbo-go/filter/filter_impl" _ "github.com/apache/dubbo-go/protocol/dubbo" _ "github.com/apache/dubbo-go/registry/protocol" - - _ "github.com/apache/dubbo-go/filter/filter_impl" - - _ "github.com/apache/dubbo-go/cluster/cluster_impl" - _ "github.com/apache/dubbo-go/cluster/loadbalance" - _ "github.com/apache/dubbo-go/config_center/nacos" _ "github.com/apache/dubbo-go/registry/zookeeper" + + "github.com/apache/dubbo-samples/golang/helloworld/go-server/pkg" ) var ( - survivalTimeout int = 10e9 + survivalTimeout = int(3e9) ) -// they are necessary: -// export CONF_CONSUMER_FILE_PATH="xxx" -// export APP_LOG_CONF_FILE="xxx" +// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to "conf/server.yml" before run func main() { - hessian.RegisterPOJO(&User{}) + hessian.RegisterPOJO(&pkg.User{}) config.Load() - time.Sleep(1e9) - gxlog.CInfo("\n\n\nstart to test dubbo") - user := &User{} - err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user) - if err != nil { - panic(err) - } - gxlog.CInfo("response result: %v\n", user) initSignal() } func initSignal() { signals := make(chan os.Signal, 1) // It is not possible to block SIGKILL or syscall.SIGSTOP - signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP, - syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT) + signal.Notify(signals, os.Interrupt, os.Kill, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT) for { sig := <-signals logger.Infof("get signal %s", sig.String()) @@ -86,7 +71,7 @@ func initSignal() { }) // The program exits normally or timeout forcibly exits. - fmt.Println("app exit now...") + fmt.Println("provider app exit now...") return } } diff --git a/configcenter/nacos/dubbo/go-client/profiles/dev/client.yml b/configcenter/nacos/go-server/conf/client.yml similarity index 67% rename from configcenter/nacos/dubbo/go-client/profiles/dev/client.yml rename to configcenter/nacos/go-server/conf/client.yml index 0657bcb..d917127 100644 --- a/configcenter/nacos/dubbo/go-client/profiles/dev/client.yml +++ b/configcenter/nacos/go-server/conf/client.yml @@ -1,51 +1,52 @@ +# dubbo client yaml configure file check: true # client -request_timeout : "3s" +request_timeout: "3s" # connect timeout -connect_timeout : "3s" - -# application config -application: - organization : "ikurento.com" - name : "BDTService" - module : "dubbogo user-info client" - version : "0.0.1" - owner : "ZX" - environment : "dev" +connect_timeout: "3s" +# config center config config_center: protocol: "nacos" address: "127.0.0.1:8848" -registries : +# application config +application: + organization: "dubbo.io" + name: "UserInfoTest" + module: "dubbo-go user-info client" + version: "0.0.1" + environment: "dev" + +# registry config +registries: "demoZk": protocol: "zookeeper" - timeout : "3s" + timeout: "3s" address: "127.0.0.1:2181" username: "" password: "" - +# reference config references: "UserProvider": - # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 registry: "demoZk" - protocol : "dubbo" - interface : "com.ikurento.user.UserProvider" + protocol: "dubbo" + interface: "org.apache.dubbo.UserProvider" cluster: "failover" - methods : + methods: - name: "GetUser" retries: 3 - +# protocol config protocol_conf: dubbo: reconnect_interval: 0 connection_number: 1 heartbeat_period: "5s" session_timeout: "180s" - pool_size: 4 + pool_size: 64 pool_ttl: 600 getty_session_param: compress_encoding: false diff --git a/configcenter/nacos/dubbo/go-server/profiles/dev/log.yml b/configcenter/nacos/go-server/conf/log.yml similarity index 88% rename from configcenter/nacos/dubbo/go-server/profiles/dev/log.yml rename to configcenter/nacos/go-server/conf/log.yml index 59fa427..d0400fe 100644 --- a/configcenter/nacos/dubbo/go-server/profiles/dev/log.yml +++ b/configcenter/nacos/go-server/conf/log.yml @@ -1,28 +1,28 @@ - -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: + +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: "capital" + timeEncoder: "iso8601" + durationEncoder: "seconds" + callerEncoder: "short" + nameEncoder: "" + +outputPaths: + - "stderr" +errorOutputPaths: + - "stderr" +initialFields: diff --git a/configcenter/nacos/dubbo/go-server/profiles/dev/server.yml b/configcenter/nacos/go-server/conf/server.yml similarity index 70% rename from configcenter/nacos/dubbo/go-server/profiles/dev/server.yml rename to configcenter/nacos/go-server/conf/server.yml index 955e132..d82d6e6 100644 --- a/configcenter/nacos/dubbo/go-server/profiles/dev/server.yml +++ b/configcenter/nacos/go-server/conf/server.yml @@ -1,33 +1,31 @@ # dubbo server yaml configure file - -# application config -application: - organization : "ikurento.com" - name : "BDTService" - module : "dubbogo user-info server" - version : "0.0.1" - owner : "ZX" - environment : "dev" - +# config center config config_center: protocol: "nacos" address: "127.0.0.1:8848" - -registries : +# application config +application: + organization: "dubbo.io" + name: "UserInfoServer" + module: "dubbo-go user-info server" + version: "0.0.1" + environment: "dev" + +# registry config +registries: "demoZk": protocol: "zookeeper" - timeout : "3s" + timeout: "3s" address: "127.0.0.1:2181" +# service config services: "UserProvider": - # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册 registry: "demoZk" - protocol : "dubbo" - # 相当于dubbo.xml中的interface - interface : "com.ikurento.user.UserProvider" + protocol: "dubbo" + interface: "org.apache.dubbo.UserProvider" loadbalance: "random" warmup: "100" cluster: "failover" @@ -36,12 +34,12 @@ services: retries: 1 loadbalance: "random" +# protocol config protocols: "dubbo": name: "dubbo" port: 20000 - protocol_conf: dubbo: session_number: 700 diff --git a/configcenter/nacos/go-server/docker/docker-compose.yml b/configcenter/nacos/go-server/docker/docker-compose.yml new file mode 100644 index 0000000..83e1311 --- /dev/null +++ b/configcenter/nacos/go-server/docker/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3' + +services: + zookeeper: + image: zookeeper + ports: + - 2181:2181 + restart: on-failure + + nacos: + image: nacos/nacos-server:latest + container_name: nacos-standalone + environment: + - PREFER_HOST_MODE=hostname + - MODE=standalone + ports: + - "8848:8848" \ No newline at end of file diff --git a/configcenter/nacos/dubbo/go-client/app/user.go b/configcenter/nacos/go-server/pkg/user.go similarity index 73% copy from configcenter/nacos/dubbo/go-client/app/user.go copy to configcenter/nacos/go-server/pkg/user.go index ff4486f..37fcb25 100644 --- a/configcenter/nacos/dubbo/go-client/app/user.go +++ b/configcenter/nacos/go-server/pkg/user.go @@ -15,7 +15,7 @@ * limitations under the License. */ -package main +package pkg import ( "context" @@ -23,14 +23,17 @@ import ( ) import ( + "github.com/dubbogo/gost/log" +) + +import ( hessian "github.com/apache/dubbo-go-hessian2" "github.com/apache/dubbo-go/config" ) -var userProvider = new(UserProvider) - func init() { - config.SetConsumerService(userProvider) + config.SetProviderService(new(UserProvider)) + // ------for hessian2------ hessian.RegisterPOJO(&User{}) } @@ -42,13 +45,19 @@ type User struct { } type UserProvider struct { - GetUser func(ctx context.Context, req []interface{}, rsp *User) error +} + +func (u *UserProvider) GetUser(ctx context.Context, req []interface{}) (*User, error) { + gxlog.CInfo("req:%#v", req) + rsp := User{"A001", "Alex Stocks", 18, time.Now()} + gxlog.CInfo("rsp:%#v", rsp) + return &rsp, nil } func (u *UserProvider) Reference() string { return "UserProvider" } -func (User) JavaClassName() string { - return "com.ikurento.user.User" +func (u User) JavaClassName() string { + return "org.apache.dubbo.User" } diff --git a/configcenter/nacos/dubbo/go-client/app/user.go b/configcenter/nacos/go-server/tests/integration/main_test.go similarity index 68% copy from configcenter/nacos/dubbo/go-client/app/user.go copy to configcenter/nacos/go-server/tests/integration/main_test.go index ff4486f..c42baa5 100644 --- a/configcenter/nacos/dubbo/go-client/app/user.go +++ b/configcenter/nacos/go-server/tests/integration/main_test.go @@ -1,3 +1,5 @@ +// +build integration + /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -15,23 +17,38 @@ * limitations under the License. */ -package main +package integration import ( - "context" - "time" + hessian "github.com/apache/dubbo-go-hessian2" + + _ "github.com/apache/dubbo-go/cluster/cluster_impl" + _ "github.com/apache/dubbo-go/cluster/loadbalance" + _ "github.com/apache/dubbo-go/common/proxy/proxy_factory" + "github.com/apache/dubbo-go/config" + _ "github.com/apache/dubbo-go/config_center/nacos" + _ "github.com/apache/dubbo-go/filter/filter_impl" + _ "github.com/apache/dubbo-go/protocol/dubbo" + _ "github.com/apache/dubbo-go/registry/protocol" + _ "github.com/apache/dubbo-go/registry/zookeeper" ) import ( - hessian "github.com/apache/dubbo-go-hessian2" - "github.com/apache/dubbo-go/config" + "context" + "os" + "testing" + "time" ) var userProvider = new(UserProvider) -func init() { +func TestMain(m *testing.M) { config.SetConsumerService(userProvider) hessian.RegisterPOJO(&User{}) + config.Load() + time.Sleep(3 * time.Second) + + os.Exit(m.Run()) } type User struct { @@ -50,5 +67,5 @@ func (u *UserProvider) Reference() string { } func (User) JavaClassName() string { - return "com.ikurento.user.User" + return "org.apache.dubbo.User" } diff --git a/configcenter/nacos/dubbo/go-client/app/user.go b/configcenter/nacos/go-server/tests/integration/userprovider_test.go similarity index 60% rename from configcenter/nacos/dubbo/go-client/app/user.go rename to configcenter/nacos/go-server/tests/integration/userprovider_test.go index ff4486f..7f2a4b8 100644 --- a/configcenter/nacos/dubbo/go-client/app/user.go +++ b/configcenter/nacos/go-server/tests/integration/userprovider_test.go @@ -1,3 +1,5 @@ +// +build integration + /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -15,40 +17,24 @@ * limitations under the License. */ -package main +package integration import ( "context" - "time" + "testing" ) - import ( - hessian "github.com/apache/dubbo-go-hessian2" - "github.com/apache/dubbo-go/config" -) -var userProvider = new(UserProvider) -func init() { - config.SetConsumerService(userProvider) - hessian.RegisterPOJO(&User{}) -} - -type User struct { - Id string - Name string - Age int32 - Time time.Time -} - -type UserProvider struct { - GetUser func(ctx context.Context, req []interface{}, rsp *User) error -} - -func (u *UserProvider) Reference() string { - return "UserProvider" -} + "github.com/stretchr/testify/assert" +) -func (User) JavaClassName() string { - return "com.ikurento.user.User" +func TestGetUser(t *testing.T) { + user := &User{} + err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user) + assert.Nil(t, err) + assert.Equal(t, "A001", user.Id) + assert.Equal(t, "Alex Stocks", user.Name) + assert.Equal(t, int32(18), user.Age) + assert.NotNil(t, user.Time) }