You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2020/05/05 15:46:52 UTC

[GitHub] [dubbo-go] yiduwangkai opened a new pull request #503: FileSystemServiceDiscovery

yiduwangkai opened a new pull request #503:
URL: https://github.com/apache/dubbo-go/pull/503


   <!--  Thanks for sending a pull request! 
   -->
   **What this PR does**:
   FileSystemServiceDiscovery, the implementation of ServiceDiscovery based on file system.
   
   **Which issue(s) this PR fixes**:
   #426 FileSystemServiceDiscovery 
   Fixes #
   
   **Special notes for your reviewer**:
   
   **Does this PR introduce a user-facing change?**:
   
   ```release-note
   
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] AlexStocks commented on pull request #503: FileSystemServiceDiscovery

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on pull request #503:
URL: https://github.com/apache/dubbo-go/pull/503#issuecomment-643630796


   will some guy accept this task to complete it?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] hxmhlt commented on a change in pull request #503: FileSystemServiceDiscovery

Posted by GitBox <gi...@apache.org>.
hxmhlt commented on a change in pull request #503:
URL: https://github.com/apache/dubbo-go/pull/503#discussion_r422660605



##########
File path: registry/filesystem/file.go
##########
@@ -0,0 +1,43 @@
+/*
+ * 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 filesystem
+
+import (
+	perrors "github.com/pkg/errors"
+	"os"
+)
+
+type File struct {
+	Path         string   //路径
+	fileWriter   *os.File //写入文件
+}
+
+// 创建文件锁,配合 defer f.Release() 来使用
+func (file *File)Create() (f *Filelock, e error) {

Review comment:
       每一个func前都需要添加注释,格式为
   // Create(the first word have to be same as your func name)...

##########
File path: registry/filesystem/file.go
##########
@@ -0,0 +1,43 @@
+/*
+ * 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 filesystem
+
+import (
+	perrors "github.com/pkg/errors"
+	"os"
+)
+
+type File struct {
+	Path         string   //路径
+	fileWriter   *os.File //写入文件
+}
+
+// 创建文件锁,配合 defer f.Release() 来使用
+func (file *File)Create() (f *Filelock, e error) {
+	if file == nil || file.Path == "" {
+		return nil, perrors.Errorf("cannot create flock on empty path")
+	}
+	lock, e := os.Create(file.Path)

Review comment:
       len(file.Path)==0 来判断字符串是否为空更好

##########
File path: registry/filesystem/file_lock.go
##########
@@ -0,0 +1,83 @@
+/*
+ * 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 filesystem
+
+import (
+	"github.com/apache/dubbo-go/common/logger"

Review comment:
       import需要分段,看下其他文件的依赖导入格式吧~




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] AlexStocks commented on a change in pull request #503: FileSystemServiceDiscovery

Posted by GitBox <gi...@apache.org>.
AlexStocks commented on a change in pull request #503:
URL: https://github.com/apache/dubbo-go/pull/503#discussion_r420603552



##########
File path: registry/filesystem/file.go
##########
@@ -0,0 +1,43 @@
+/*
+ * 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 filesystem
+
+import (
+	perrors "github.com/pkg/errors"
+	"os"
+)
+
+type File struct {
+	Path         string   //路径
+	fileWriter   *os.File //写入文件
+}
+
+// 创建文件锁,配合 defer f.Release() 来使用
+func (file *File)Create() (f *Filelock, e error) {

Review comment:
       hey, guy, there are two improvements to do. Numnber 1, pls do not use Chinese in comment. Number 2, pls move the fundamental funcs to github.com/gost. 
   
   as this func, pls submit it to the github.com/gost/os. and if this dir do not exist, pls create it.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] flycash commented on a change in pull request #503: FileSystemServiceDiscovery

Posted by GitBox <gi...@apache.org>.
flycash commented on a change in pull request #503:
URL: https://github.com/apache/dubbo-go/pull/503#discussion_r422992404



##########
File path: registry/filesystem/file.go
##########
@@ -0,0 +1,43 @@
+/*
+ * 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 filesystem
+
+import (
+	perrors "github.com/pkg/errors"
+	"os"
+)
+
+type File struct {
+	Path         string   //路径
+	fileWriter   *os.File //写入文件
+}
+
+// 创建文件锁,配合 defer f.Release() 来使用
+func (file *File)Create() (f *Filelock, e error) {

Review comment:
       it would be better to use English. :)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] yiduwangkai commented on a change in pull request #503: FileSystemServiceDiscovery

Posted by GitBox <gi...@apache.org>.
yiduwangkai commented on a change in pull request #503:
URL: https://github.com/apache/dubbo-go/pull/503#discussion_r424826199



##########
File path: registry/filesystem/file.go
##########
@@ -0,0 +1,43 @@
+/*
+ * 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 filesystem
+
+import (
+	perrors "github.com/pkg/errors"
+	"os"
+)
+
+type File struct {
+	Path         string   //路径
+	fileWriter   *os.File //写入文件
+}
+
+// 创建文件锁,配合 defer f.Release() 来使用
+func (file *File)Create() (f *Filelock, e error) {

Review comment:
       OK




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] AlexStocks closed pull request #503: FileSystemServiceDiscovery

Posted by GitBox <gi...@apache.org>.
AlexStocks closed pull request #503:
URL: https://github.com/apache/dubbo-go/pull/503


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-go] flycash commented on a change in pull request #503: FileSystemServiceDiscovery

Posted by GitBox <gi...@apache.org>.
flycash commented on a change in pull request #503:
URL: https://github.com/apache/dubbo-go/pull/503#discussion_r426247359



##########
File path: registry/filesystem/service_discovery.go
##########
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package filesystem
+
+import (
+	"bytes"
+	"github.com/dubbogo/gost/container/set"
+	"github.com/dubbogo/gost/page"
+	perrors "github.com/pkg/errors"
+	"os"
+	"os/exec"
+	"os/user"
+	"runtime"
+	"strings"
+)
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/registry"
+)
+
+const (
+	name = "file-system"
+	paramNamePrefix = "dubbo.config-center."
+	configCenterDirParamName = paramNamePrefix + "dir"
+	configCenterEncodingParamName = paramNamePrefix + "encoding"
+	defaultConfigCenterEncoding = "UTF-8"
+)
+
+func init() {
+	extension.SetServiceDiscovery(name, newFileSystemServiceDiscovery)
+}
+
+func newFileSystemServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error){

Review comment:
       Should it be a singleton?

##########
File path: registry/filesystem/service_discovery.go
##########
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package filesystem
+
+import (
+	"bytes"
+	"github.com/dubbogo/gost/container/set"
+	"github.com/dubbogo/gost/page"
+	perrors "github.com/pkg/errors"
+	"os"
+	"os/exec"
+	"os/user"
+	"runtime"
+	"strings"
+)
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/registry"
+)
+
+const (
+	name = "file-system"
+	paramNamePrefix = "dubbo.config-center."
+	configCenterDirParamName = paramNamePrefix + "dir"
+	configCenterEncodingParamName = paramNamePrefix + "encoding"
+	defaultConfigCenterEncoding = "UTF-8"
+)
+
+func init() {
+	extension.SetServiceDiscovery(name, newFileSystemServiceDiscovery)
+}
+
+func newFileSystemServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error){
+	instance := &FilleSystemServiceDiscovery{
+		fileLocksCache: make(map[*File]*Filelock, 4),
+		listeners: make([]*registry.ServiceInstancesChangedListener, 0, 2),
+	}
+	return instance,nil
+}
+
+func createFile(url *common.URL) (*File, string, error) {
+	userHome, _ := home()
+	path := userHome + "/" + ".dubbo" + "/" + "registry"
+	url.AddParam(configCenterDirParamName, path)
+	file, error := initDirectory(url, userHome)
+	if error != nil {
+		return nil, "", error
+	}
+	encoding :=url.GetParam(configCenterEncodingParamName, defaultConfigCenterEncoding)
+	return file, encoding, nil
+}
+
+func initDirectory(url *common.URL, userHome string) (*File, error) {
+	directoryPath := url.GetParam(configCenterDirParamName, url.Path)
+	var rootDirectory string
+	if directoryPath == "" || len(directoryPath) == 0 {
+		rootDirectory = string(os.PathSeparator) + directoryPath
+	}
+
+	if directoryPath == "" {
+		if result, _ := exists(directoryPath); !result {
+			// If the directory does not exist
+			rootDirectory = userHome + "/" + ".dubbo" + "/" + "config-center"
+		}
+	}
+
+	if result,_ := exists(rootDirectory); !result {
+		if _, err :=os.Create(rootDirectory); err != nil {
+			return nil, perrors.WithStack(err)
+		}
+	}
+	return &File{Path: rootDirectory}, nil
+}
+
+func exists(path string) (bool, error) {
+	_, err := os.Stat(path)
+	if err == nil { return true, nil }
+	if os.IsNotExist(err) { return false, nil }
+	return true, err
+}
+
+// FilleSystemServiceDiscovery is an implementation based on memory.
+// Usually you will not use this implementation except for tests.
+type FilleSystemServiceDiscovery struct {
+	fileLocksCache map[*File]*Filelock
+	listeners      []*registry.ServiceInstancesChangedListener
+	encoding       string
+	rootDirectory  *File
+}
+
+func (i *FilleSystemServiceDiscovery) String() string {
+	return name
+}
+
+// Destroy doesn't destroy the instance, it just clear the instances
+func (i *FilleSystemServiceDiscovery) Destroy() error {

Review comment:
       I think it should remove the files.

##########
File path: registry/filesystem/service_discovery.go
##########
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package filesystem
+
+import (
+	"bytes"
+	"github.com/dubbogo/gost/container/set"
+	"github.com/dubbogo/gost/page"
+	perrors "github.com/pkg/errors"
+	"os"
+	"os/exec"
+	"os/user"
+	"runtime"
+	"strings"
+)
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/registry"
+)
+
+const (
+	name = "file-system"
+	paramNamePrefix = "dubbo.config-center."
+	configCenterDirParamName = paramNamePrefix + "dir"
+	configCenterEncodingParamName = paramNamePrefix + "encoding"
+	defaultConfigCenterEncoding = "UTF-8"
+)
+
+func init() {
+	extension.SetServiceDiscovery(name, newFileSystemServiceDiscovery)
+}
+
+func newFileSystemServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error){
+	instance := &FilleSystemServiceDiscovery{
+		fileLocksCache: make(map[*File]*Filelock, 4),
+		listeners: make([]*registry.ServiceInstancesChangedListener, 0, 2),
+	}
+	return instance,nil
+}
+
+func createFile(url *common.URL) (*File, string, error) {
+	userHome, _ := home()
+	path := userHome + "/" + ".dubbo" + "/" + "registry"
+	url.AddParam(configCenterDirParamName, path)
+	file, error := initDirectory(url, userHome)
+	if error != nil {
+		return nil, "", error
+	}
+	encoding :=url.GetParam(configCenterEncodingParamName, defaultConfigCenterEncoding)
+	return file, encoding, nil
+}
+
+func initDirectory(url *common.URL, userHome string) (*File, error) {
+	directoryPath := url.GetParam(configCenterDirParamName, url.Path)
+	var rootDirectory string
+	if directoryPath == "" || len(directoryPath) == 0 {
+		rootDirectory = string(os.PathSeparator) + directoryPath
+	}
+
+	if directoryPath == "" {
+		if result, _ := exists(directoryPath); !result {
+			// If the directory does not exist
+			rootDirectory = userHome + "/" + ".dubbo" + "/" + "config-center"
+		}
+	}
+
+	if result,_ := exists(rootDirectory); !result {
+		if _, err :=os.Create(rootDirectory); err != nil {
+			return nil, perrors.WithStack(err)
+		}
+	}
+	return &File{Path: rootDirectory}, nil
+}
+
+func exists(path string) (bool, error) {
+	_, err := os.Stat(path)
+	if err == nil { return true, nil }
+	if os.IsNotExist(err) { return false, nil }
+	return true, err
+}
+
+// FilleSystemServiceDiscovery is an implementation based on memory.

Review comment:
       based on file system

##########
File path: registry/filesystem/service_discovery.go
##########
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package filesystem
+
+import (
+	"bytes"
+	"github.com/dubbogo/gost/container/set"
+	"github.com/dubbogo/gost/page"
+	perrors "github.com/pkg/errors"
+	"os"
+	"os/exec"
+	"os/user"
+	"runtime"
+	"strings"
+)
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/extension"
+	"github.com/apache/dubbo-go/registry"
+)
+
+const (
+	name = "file-system"
+	paramNamePrefix = "dubbo.config-center."
+	configCenterDirParamName = paramNamePrefix + "dir"
+	configCenterEncodingParamName = paramNamePrefix + "encoding"
+	defaultConfigCenterEncoding = "UTF-8"
+)
+
+func init() {
+	extension.SetServiceDiscovery(name, newFileSystemServiceDiscovery)
+}
+
+func newFileSystemServiceDiscovery(url *common.URL) (registry.ServiceDiscovery, error){
+	instance := &FilleSystemServiceDiscovery{
+		fileLocksCache: make(map[*File]*Filelock, 4),
+		listeners: make([]*registry.ServiceInstancesChangedListener, 0, 2),
+	}
+	return instance,nil
+}
+
+func createFile(url *common.URL) (*File, string, error) {
+	userHome, _ := home()
+	path := userHome + "/" + ".dubbo" + "/" + "registry"
+	url.AddParam(configCenterDirParamName, path)
+	file, error := initDirectory(url, userHome)
+	if error != nil {
+		return nil, "", error
+	}
+	encoding :=url.GetParam(configCenterEncodingParamName, defaultConfigCenterEncoding)
+	return file, encoding, nil
+}
+
+func initDirectory(url *common.URL, userHome string) (*File, error) {
+	directoryPath := url.GetParam(configCenterDirParamName, url.Path)
+	var rootDirectory string
+	if directoryPath == "" || len(directoryPath) == 0 {
+		rootDirectory = string(os.PathSeparator) + directoryPath
+	}
+
+	if directoryPath == "" {
+		if result, _ := exists(directoryPath); !result {
+			// If the directory does not exist
+			rootDirectory = userHome + "/" + ".dubbo" + "/" + "config-center"
+		}
+	}
+
+	if result,_ := exists(rootDirectory); !result {
+		if _, err :=os.Create(rootDirectory); err != nil {
+			return nil, perrors.WithStack(err)
+		}
+	}
+	return &File{Path: rootDirectory}, nil
+}
+
+func exists(path string) (bool, error) {
+	_, err := os.Stat(path)
+	if err == nil { return true, nil }
+	if os.IsNotExist(err) { return false, nil }
+	return true, err
+}
+
+// FilleSystemServiceDiscovery is an implementation based on memory.
+// Usually you will not use this implementation except for tests.
+type FilleSystemServiceDiscovery struct {
+	fileLocksCache map[*File]*Filelock
+	listeners      []*registry.ServiceInstancesChangedListener
+	encoding       string
+	rootDirectory  *File
+}
+
+func (i *FilleSystemServiceDiscovery) String() string {
+	return name
+}
+
+// Destroy doesn't destroy the instance, it just clear the instances
+func (i *FilleSystemServiceDiscovery) Destroy() error {
+	// reset to empty
+	i.fileLocksCache = nil
+	i.listeners = nil
+	return nil
+}
+
+// Register will store the instance using its id as key
+func (i *FilleSystemServiceDiscovery) Register(instance registry.ServiceInstance) error {
+	return nil

Review comment:
       Do nothing?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org