You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by il...@apache.org on 2020/10/27 03:55:22 UTC
[dubbo-go-samples] branch makefile updated: use makefile for
helloworld client and server
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 681e209 use makefile for helloworld client and server
681e209 is described below
commit 681e209ca5ebb4127a273108206a840dc9bf7ea2
Author: Ian Luo <ia...@gmail.com>
AuthorDate: Tue Oct 27 11:54:56 2020 +0800
use makefile for helloworld client and server
---
{helloworld/dubbo/go-server => build}/Makefile | 35 ++--
helloworld/dubbo/go-client/app/version.go | 22 ---
helloworld/dubbo/go-client/assembly.tar | Bin 40960 -> 0 bytes
helloworld/dubbo/go-client/assembly.zip | Bin 12137 -> 0 bytes
helloworld/dubbo/go-client/assembly/bin/load.sh | 205 ---------------------
.../dubbo/go-client/assembly/common/app.properties | 23 ---
.../dubbo/go-client/assembly/common/build.sh | 79 --------
helloworld/dubbo/go-client/assembly/linux/dev.sh | 36 ----
.../dubbo/go-client/assembly/linux/release.sh | 35 ----
helloworld/dubbo/go-client/assembly/linux/test.sh | 35 ----
helloworld/dubbo/go-client/assembly/mac/dev.sh | 36 ----
helloworld/dubbo/go-client/assembly/mac/release.sh | 34 ----
helloworld/dubbo/go-client/assembly/mac/test.sh | 34 ----
helloworld/dubbo/go-client/assembly/windows/dev.sh | 34 ----
.../dubbo/go-client/assembly/windows/release.sh | 34 ----
.../dubbo/go-client/assembly/windows/test.sh | 34 ----
helloworld/dubbo/go-client/{app => cmd}/client.go | 32 ++--
.../go-client/{profiles/dev => conf}/client.yml | 16 +-
.../dubbo/go-client/{profiles/dev => conf}/log.yml | 56 +++---
helloworld/dubbo/go-client/integration_testing.sh | 31 ----
helloworld/dubbo/go-client/{app => pkg}/user.go | 16 +-
.../dubbo/go-client/profiles/release/client.yml | 60 ------
.../dubbo/go-client/profiles/release/log.yml | 28 ---
.../dubbo/go-client/profiles/test/client.yml | 59 ------
helloworld/dubbo/go-client/profiles/test/log.yml | 28 ---
helloworld/dubbo/go-server/cmd/server.go | 1 +
26 files changed, 72 insertions(+), 931 deletions(-)
diff --git a/helloworld/dubbo/go-server/Makefile b/build/Makefile
similarity index 89%
rename from helloworld/dubbo/go-server/Makefile
rename to build/Makefile
index dd846bc..fa543d5 100644
--- a/helloworld/dubbo/go-server/Makefile
+++ b/build/Makefile
@@ -56,6 +56,15 @@ endif
OUT_DIR := $(BASE_DIR)/$(GOOS)_$(GOARCH)/$(BUILD_TYPE)
LOG_FILE := $(OUT_DIR)/$(PROJECT_NAME).log
+.PHONY: all
+all: help
+help: $(realpath $(firstword $(MAKEFILE_LIST)))
+ @echo
+ @echo " Choose a command run in "$(PROJECT_NAME)":"
+ @echo
+ @sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
+ @echo
+
## build: Build application's binaries
.PHONY: build
build: $(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME)
@@ -83,14 +92,20 @@ clean: stop
$(info > Cleanning up binaries and logs)
@rm -rf $(OUT_DIR)
-## start: Start to run the application
+## start: Start the application (for server)
.PHONY: start
start: build
$(info > Starting application $(PROJECT_NAME), output is redirected to $(LOG_FILE))
@-$(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME) > $(LOG_FILE) 2>&1 & echo $$! > $(PID)
@cat $(PID) | sed "/^/s/^/ \> PID: /"
-## stop: Stop running the application
+## run: Run the application (for client)
+.PHONY: run
+run: build
+ $(info > Running application $(PROJECT_NAME), output is redirected to $(LOG_FILE))
+ @-$(OUT_DIR)/$(PROJECT_NAME)$(EXT_NAME) 2>&1 | tee $(LOG_FILE)
+
+## stop: Stop running the application (for server)
.PHONY: stop
stop:
$(info > Stopping the application $(PROJECT_NAME))
@@ -101,18 +116,4 @@ stop:
integration:
$(info > Running integration test for application $(PROJECT_NAME))
@go clean -testcache
- @go test -tags integration -v ./tests/...
-
-.PHONY: help
-all: help
-help: Makefile
- @echo
- @echo " Choose a command run in "$(PROJECT_NAME)":"
- @echo
- @sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
- @echo
-
-
-
-
-
+ @go test -tags integration -v ./tests/...
\ No newline at end of file
diff --git a/helloworld/dubbo/go-client/app/version.go b/helloworld/dubbo/go-client/app/version.go
deleted file mode 100644
index ae51f45..0000000
--- a/helloworld/dubbo/go-client/app/version.go
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package main
-
-var (
- Version = "2.7.5"
-)
diff --git a/helloworld/dubbo/go-client/assembly.tar b/helloworld/dubbo/go-client/assembly.tar
deleted file mode 100644
index 180a5a7..0000000
Binary files a/helloworld/dubbo/go-client/assembly.tar and /dev/null differ
diff --git a/helloworld/dubbo/go-client/assembly.zip b/helloworld/dubbo/go-client/assembly.zip
deleted file mode 100644
index 1359bb7..0000000
Binary files a/helloworld/dubbo/go-client/assembly.zip and /dev/null differ
diff --git a/helloworld/dubbo/go-client/assembly/bin/load.sh b/helloworld/dubbo/go-client/assembly/bin/load.sh
deleted file mode 100644
index 6d41032..0000000
--- a/helloworld/dubbo/go-client/assembly/bin/load.sh
+++ /dev/null
@@ -1,205 +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}
- R=$?
- 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
- return $R
-}
-
-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/helloworld/dubbo/go-client/assembly/common/app.properties b/helloworld/dubbo/go-client/assembly/common/app.properties
deleted file mode 100644
index f77f8bd..0000000
--- a/helloworld/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.
-
-
-TARGET_EXEC_NAME="user_info_client"
-# BUILD_PACKAGE="dubbogo-examples/user-info/client/app"
-BUILD_PACKAGE="app"
-
-TARGET_CONF_FILE="conf/client.yml"
-TARGET_LOG_CONF_FILE="conf/log.yml"
diff --git a/helloworld/dubbo/go-client/assembly/common/build.sh b/helloworld/dubbo/go-client/assembly/common/build.sh
deleted file mode 100644
index 4e68306..0000000
--- a/helloworld/dubbo/go-client/assembly/common/build.sh
+++ /dev/null
@@ -1,79 +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" -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" -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/helloworld/dubbo/go-client/assembly/linux/dev.sh b/helloworld/dubbo/go-client/assembly/linux/dev.sh
deleted file mode 100644
index d830ac9..0000000
--- a/helloworld/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
-
-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/helloworld/dubbo/go-client/assembly/linux/release.sh b/helloworld/dubbo/go-client/assembly/linux/release.sh
deleted file mode 100644
index 10eb3d7..0000000
--- a/helloworld/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/helloworld/dubbo/go-client/assembly/linux/test.sh b/helloworld/dubbo/go-client/assembly/linux/test.sh
deleted file mode 100644
index 78b650c..0000000
--- a/helloworld/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/helloworld/dubbo/go-client/assembly/mac/dev.sh b/helloworld/dubbo/go-client/assembly/mac/dev.sh
deleted file mode 100644
index c828476..0000000
--- a/helloworld/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/helloworld/dubbo/go-client/assembly/mac/release.sh b/helloworld/dubbo/go-client/assembly/mac/release.sh
deleted file mode 100644
index 91c2dfe..0000000
--- a/helloworld/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/helloworld/dubbo/go-client/assembly/mac/test.sh b/helloworld/dubbo/go-client/assembly/mac/test.sh
deleted file mode 100644
index a7853f5..0000000
--- a/helloworld/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/helloworld/dubbo/go-client/assembly/windows/dev.sh b/helloworld/dubbo/go-client/assembly/windows/dev.sh
deleted file mode 100644
index 6487b30..0000000
--- a/helloworld/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=windows
-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/helloworld/dubbo/go-client/assembly/windows/release.sh b/helloworld/dubbo/go-client/assembly/windows/release.sh
deleted file mode 100644
index 21af573..0000000
--- a/helloworld/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/helloworld/dubbo/go-client/assembly/windows/test.sh b/helloworld/dubbo/go-client/assembly/windows/test.sh
deleted file mode 100644
index 2104da8..0000000
--- a/helloworld/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/helloworld/dubbo/go-client/app/client.go b/helloworld/dubbo/go-client/cmd/client.go
similarity index 80%
rename from helloworld/dubbo/go-client/app/client.go
rename to helloworld/dubbo/go-client/cmd/client.go
index a500599..b72518b 100644
--- a/helloworld/dubbo/go-client/app/client.go
+++ b/helloworld/dubbo/go-client/cmd/client.go
@@ -24,37 +24,37 @@ import (
)
import (
+ hessian "github.com/apache/dubbo-go-hessian2"
+ "github.com/apache/dubbo-samples/golang/helloworld/dubbo/go-client/pkg"
"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/proxy/proxy_factory"
"github.com/apache/dubbo-go/config"
+ _ "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/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(3e9)
+ 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 {
gxlog.CError("error: %v\n", err)
@@ -62,4 +62,4 @@ func main() {
return
}
gxlog.CInfo("response result: %v\n", user)
-}
\ No newline at end of file
+}
diff --git a/helloworld/dubbo/go-client/profiles/dev/client.yml b/helloworld/dubbo/go-client/conf/client.yml
similarity index 80%
rename from helloworld/dubbo/go-client/profiles/dev/client.yml
rename to helloworld/dubbo/go-client/conf/client.yml
index 55bc924..3d8870f 100644
--- a/helloworld/dubbo/go-client/profiles/dev/client.yml
+++ b/helloworld/dubbo/go-client/conf/client.yml
@@ -1,6 +1,5 @@
# dubbo client yaml configure file
-
check: true
# client
request_timeout : "3s"
@@ -9,13 +8,13 @@ connect_timeout : "3s"
# application config
application:
- organization : "ikurento.com"
- name : "BDTService"
- module : "dubbogo user-info client"
+ organization : "dubbo.io"
+ name : "UserInfoServer"
+ module : "dubbo-go user-info client"
version : "0.0.1"
- owner : "ZX"
environment : "dev"
+# registry config
registries :
"demoZk":
protocol: "zookeeper"
@@ -24,19 +23,18 @@ registries :
username: ""
password: ""
-
+# reference config
references:
"UserProvider":
- # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册
registry: "demoZk"
protocol : "dubbo"
- interface : "com.ikurento.user.UserProvider"
+ interface : "org.apache.dubbo.UserProvider"
cluster: "failover"
methods :
- name: "GetUser"
retries: 3
-
+# protocol config
protocol_conf:
dubbo:
reconnect_interval: 0
diff --git a/helloworld/dubbo/go-client/profiles/dev/log.yml b/helloworld/dubbo/go-client/conf/log.yml
similarity index 88%
rename from helloworld/dubbo/go-client/profiles/dev/log.yml
rename to helloworld/dubbo/go-client/conf/log.yml
index 59fa427..d0400fe 100644
--- a/helloworld/dubbo/go-client/profiles/dev/log.yml
+++ b/helloworld/dubbo/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/helloworld/dubbo/go-client/integration_testing.sh b/helloworld/dubbo/go-client/integration_testing.sh
deleted file mode 100755
index 49f7b49..0000000
--- a/helloworld/dubbo/go-client/integration_testing.sh
+++ /dev/null
@@ -1,31 +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.
-
-#!/bin/bash
-
-set -e
-set -x
-
-rm -rf assembly
-cp -r $1/.integration/testing/$2/assembly .
-assembly/linux/dev.sh
-cd target/*/*/
-# is async
-if [[ $3 ]]; then
- nohup bin/load.sh start > a.out&
-else
- bin/load.sh start
-fi
\ No newline at end of file
diff --git a/helloworld/dubbo/go-client/app/user.go b/helloworld/dubbo/go-client/pkg/user.go
similarity index 80%
rename from helloworld/dubbo/go-client/app/user.go
rename to helloworld/dubbo/go-client/pkg/user.go
index ff4486f..75c964f 100644
--- a/helloworld/dubbo/go-client/app/user.go
+++ b/helloworld/dubbo/go-client/pkg/user.go
@@ -15,25 +15,13 @@
* limitations under the License.
*/
-package main
+package pkg
import (
"context"
"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
@@ -50,5 +38,5 @@ func (u *UserProvider) Reference() string {
}
func (User) JavaClassName() string {
- return "com.ikurento.user.User"
+ return "org.apache.dubbo.User"
}
diff --git a/helloworld/dubbo/go-client/profiles/release/client.yml b/helloworld/dubbo/go-client/profiles/release/client.yml
deleted file mode 100644
index baa4382..0000000
--- a/helloworld/dubbo/go-client/profiles/release/client.yml
+++ /dev/null
@@ -1,60 +0,0 @@
-# dubbo client yaml configure file
-
-
-check: true
-# client
-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 : "release"
-
-registries :
- "hangzhouzk":
- protocol: "zookeeper"
- timeout : "3s"
- address: "127.0.0.1:2181"
- username: ""
- password: ""
-
-
-references:
- "UserProvider":
- # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册
- registry: "hangzhouzk"
- protocol : "dubbo"
- interface : "com.ikurento.user.UserProvider"
- cluster: "failover"
- methods :
- - name: "GetUser"
- retries: 3
-
-protocol_conf:
- dubbo:
- reconnect_interval: 0
- connection_number: 1
- heartbeat_period: "5s"
- session_timeout: "180s"
- pool_size: 64
- pool_ttl: 600
- getty_session_param:
- compress_encoding: false
- tcp_no_delay: true
- tcp_keep_alive: true
- keep_alive_period: "120s"
- tcp_r_buf_size: 262144
- tcp_w_buf_size: 65536
- pkg_rq_size: 1024
- pkg_wq_size: 512
- tcp_read_timeout: "1s"
- tcp_write_timeout: "5s"
- wait_timeout: "1s"
- max_msg_len: 1024000
- session_name: "client"
diff --git a/helloworld/dubbo/go-client/profiles/release/log.yml b/helloworld/dubbo/go-client/profiles/release/log.yml
deleted file mode 100644
index e0514be..0000000
--- a/helloworld/dubbo/go-client/profiles/release/log.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-level: "warn"
-development: true
-disableCaller: true
-disableStacktrace: true
-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/helloworld/dubbo/go-client/profiles/test/client.yml b/helloworld/dubbo/go-client/profiles/test/client.yml
deleted file mode 100644
index 90d72a2..0000000
--- a/helloworld/dubbo/go-client/profiles/test/client.yml
+++ /dev/null
@@ -1,59 +0,0 @@
-# dubbo client yaml configure file
-
-
-check: true
-# client
-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 : "test"
-
-registries :
- "hangzhouzk":
- protocol: "zookeeper"
- timeout : "3s"
- address: "127.0.0.1:2181"
- username: ""
- password: ""
-
-references:
- "UserProvider":
- # 可以指定多个registry,使用逗号隔开;不指定默认向所有注册中心注册
- registry: "hangzhouzk"
- protocol : "dubbo"
- interface : "com.ikurento.user.UserProvider"
- cluster: "failover"
- methods :
- - name: "GetUser"
- retries: 3
-
-protocol_conf:
- dubbo:
- reconnect_interval: 0
- connection_number: 1
- heartbeat_period: "5s"
- session_timeout: "180s"
- pool_size: 64
- pool_ttl: 600
- getty_session_param:
- compress_encoding: false
- tcp_no_delay: true
- tcp_keep_alive: true
- keep_alive_period: "120s"
- tcp_r_buf_size: 262144
- tcp_w_buf_size: 65536
- pkg_rq_size: 1024
- pkg_wq_size: 512
- tcp_read_timeout: "1s"
- tcp_write_timeout: "5s"
- wait_timeout: "1s"
- max_msg_len: 1024000
- session_name: "client"
diff --git a/helloworld/dubbo/go-client/profiles/test/log.yml b/helloworld/dubbo/go-client/profiles/test/log.yml
deleted file mode 100644
index baee0b7..0000000
--- a/helloworld/dubbo/go-client/profiles/test/log.yml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-level: "info"
-development: false
-disableCaller: false
-disableStacktrace: true
-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/helloworld/dubbo/go-server/cmd/server.go b/helloworld/dubbo/go-server/cmd/server.go
index db85a0c..7d77af8 100644
--- a/helloworld/dubbo/go-server/cmd/server.go
+++ b/helloworld/dubbo/go-server/cmd/server.go
@@ -45,6 +45,7 @@ var (
survivalTimeout = int(3e9)
)
+// need to setup environment variable "CONF_PROVIDER_FILE_PATH" to "conf/server.yml" before run
func main() {
hessian.RegisterPOJO(&pkg.User{})
config.Load()