You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/01/10 13:12:29 UTC

[dubbo-go] branch develop updated (603f989 -> 794ab77)

This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a change to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git.


 discard 603f989  Merge pull request #932 from cityiron/feature/fix-config_center-file
     new 794ab77  Merge pull request #932 from cityiron/feature/fix-config_center-file

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (603f989)
            \
             N -- N -- N   refs/heads/develop (794ab77)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 go.sum | 2 --
 1 file changed, 2 deletions(-)


[dubbo-go] 01/01: Merge pull request #932 from cityiron/feature/fix-config_center-file

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git

commit 794ab77916f1cc60fb5ab6a988ae4c4bfa1b2eaa
Merge: 374a01a cc7fb2e
Author: Xin.Zh <dr...@foxmail.com>
AuthorDate: Sun Jan 10 17:07:31 2021 +0800

    Merge pull request #932 from cityiron/feature/fix-config_center-file
    
    [Fix] file service discovery path can run in windows

 config_center/file/impl.go         | 110 +++++++++++++++++++++++++++----------
 go.sum                             |   2 -
 registry/file/service_discovery.go |   2 +-
 3 files changed, 81 insertions(+), 33 deletions(-)

diff --cc config_center/file/impl.go
index 9afe7c6,0233f63..6489a07
--- a/config_center/file/impl.go
+++ b/config_center/file/impl.go
@@@ -41,13 -40,29 +40,21 @@@ import 
  	"github.com/apache/dubbo-go/config_center/parser"
  )
  
 -var osType string
 -var path string
++var (
++	osType = runtime.GOOS
++)
+ 
+ const (
 -	windows = "windows"
++	windowsOS = "windows"
+ )
+ 
  const (
- 	PARAM_NAME_PREFIX                 = "dubbo.config-center."
- 	CONFIG_CENTER_DIR_PARAM_NAME      = PARAM_NAME_PREFIX + "dir"
- 	CONFIG_CENTER_ENCODING_PARAM_NAME = PARAM_NAME_PREFIX + "encoding"
- 	DEFAULT_CONFIG_CENTER_ENCODING    = "UTF-8"
+ 	ParamNamePrefix               = "dubbo.config-center."
+ 	ConfigCenterDirParamName      = ParamNamePrefix + "dir"
+ 	ConfigCenterEncodingParamName = ParamNamePrefix + "encoding"
+ 	defaultConfigCenterEncoding   = "UTF-8"
  )
  
 -func init() {
 -	osType = runtime.GOOS
 -	if os.IsPathSeparator('\\') {
 -		path = "\\"
 -	} else {
 -		path = "/"
 -	}
 -}
 -
  // FileSystemDynamicConfiguration
  type FileSystemDynamicConfiguration struct {
  	config_center.BaseDynamicConfiguration
@@@ -206,7 -211,7 +203,7 @@@ func (fsdc *FileSystemDynamicConfigurat
  }
  
  func (fsdc *FileSystemDynamicConfiguration) deleteDelay(path string) (bool, error) {
--	if path == "" {
++	if len(path) == 0 {
  		return false, nil
  	}
  
@@@ -226,9 -231,9 +223,7 @@@ func (fsdc *FileSystemDynamicConfigurat
  }
  
  func forceMkdirParent(fp string) error {
--	pd := getParentDirectory(fp)
--
--	return createDir(pd)
++	return createDir(getParentDirectory(fp))
  }
  
  func createDir(path string) error {
@@@ -250,6 -255,6 +245,7 @@@ func substr(s string, pos, length int) 
  	if l > len(runes) {
  		l = len(runes)
  	}
++
  	return string(runes[pos:l])
  }
  
@@@ -264,7 -269,7 +260,7 @@@ func Home() (string, error) 
  	}
  
  	// cross compile support
--	if "windows" == runtime.GOOS {
++	if windowsOS == osType {
  		return homeWindows()
  	}
  
@@@ -287,7 -292,7 +283,7 @@@ func homeUnix() (string, error) 
  	}
  
  	result := strings.TrimSpace(stdout.String())
--	if result == "" {
++	if len(result) == 0 {
  		return "", errors.New("blank output when reading home directory")
  	}
  
@@@ -298,12 -303,66 +294,66 @@@ func homeWindows() (string, error) 
  	drive := os.Getenv("HOMEDRIVE")
  	homePath := os.Getenv("HOMEPATH")
  	home := drive + homePath
--	if drive == "" || homePath == "" {
++	if len(drive) == 0 || len(homePath) == 0 {
  		home = os.Getenv("USERPROFILE")
  	}
--	if home == "" {
++	if len(home) == 0 {
  		return "", errors.New("HOMEDRIVE, HOMEPATH, and USERPROFILE are blank")
  	}
  
  	return home, nil
  }
+ 
+ func mkdirIfNecessary(urlRoot string) (string, error) {
+ 	if !legalPath(urlRoot) {
+ 		// not exist, use default, mac is: /XXX/xx/.dubbo/config-center
+ 		rp, err := Home()
+ 		if err != nil {
+ 			return "", perrors.WithStack(err)
+ 		}
+ 
+ 		urlRoot = adapterUrl(rp)
+ 	}
+ 
+ 	if _, err := os.Stat(urlRoot); err != nil {
+ 		// it must be dir, if not exist, will create
+ 		if err = createDir(urlRoot); err != nil {
+ 			return "", perrors.WithStack(err)
+ 		}
+ 	}
+ 
+ 	return urlRoot, nil
+ }
+ 
+ func legalPath(path string) bool {
+ 	if len(path) == 0 {
+ 		return false
+ 	}
+ 	if _, err := os.Stat(path); err != nil {
+ 		return false
+ 	}
+ 
+ 	return true
+ }
+ 
+ func adapterUrl(rp string) string {
 -	if osType == windows {
++	if osType == windowsOS {
+ 		return filepath.Join(rp, "_dubbo", "config-center")
+ 	}
+ 
+ 	return filepath.Join(rp, ".dubbo", "config-center")
+ }
+ 
+ // used for GetPath. param key default is instance's id.
+ // e.g: (ip:port) 127.0.0.1:20081, in windows env, will change to 127_0_0_1_20081
+ func adapterKey(key string) string {
+ 	if len(key) == 0 {
+ 		return ""
+ 	}
+ 
 -	if osType == windows {
++	if osType == windowsOS {
+ 		return strings.ReplaceAll(strings.ReplaceAll(key, ".", "_"), ":", "_")
+ 	}
+ 
+ 	return key
+ }
diff --cc go.sum
index bc0b1ec,201f03e..78bccb6
--- a/go.sum
+++ b/go.sum
@@@ -62,7 -79,7 +62,6 @@@ github.com/RoaringBitmap/roaring v0.5.
  github.com/RoaringBitmap/roaring v0.5.5/go.mod h1:puNo5VdzwbaIQxSiDIwfXl4Hnc+fbovcX4IW/dSTtUk=
  github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
  github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
--github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
  github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
  github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
  github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
@@@ -234,7 -314,7 +233,6 @@@ github.com/go-logfmt/logfmt v0.3.0/go.m
  github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
  github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
  github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7sIas=
--github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E=
  github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8=
  github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI=
  github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM=