Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

配置CreateNamingClient是通的而NewNamingClient是不通的 #743

Open
yangyile1990 opened this issue Apr 8, 2024 · 0 comments
Open

Comments

@yangyile1990
Copy link

yangyile1990 commented Apr 8, 2024

这样是好的,但是无论是从GoLand直接右键运行,还是go run main.go 结果都是cache目录不正确,不是我想要的 /tmp/nacos/cache 同理 log 目录也不正确。

sc := []constant.ServerConfig{
		{
			IpAddr: "127.0.0.1",
			Port:   8848,
		},
	}

	cc := &constant.ClientConfig{
		NamespaceId:         "namespace-001",
		TimeoutMs:           500000,
		NotLoadCacheAtStart: true,
		LogDir:              "/tmp/nacos/log",
		CacheDir:            "/tmp/nacos/cache",
		LogLevel:            "debug",
	}

	client, err := clients.CreateNamingClient(map[string]interface{}{
		"serverConfigs": sc,
		"clientConfig":  cc,
	})

这样,调用这个函数创建客户端,虽然cache目录是正确的,但真正去注册的时候,注册不到服务端。

	client, err := clients.NewNamingClient(vo.NacosClientParam{
		ClientConfig:  cc,
		ServerConfigs: sc,
	})

这样连就是错的,具体原因未知,像服务端发注册就是注册不上的,目前事实确实如此,但我没分析出原因。

哎,我只是个苦逼的打工者,技术菜,能力弱,你们不要这样搞我呀。

理论上两个配置应该是一样的,认为使用NewNamingClient更符合go语言的习惯,即已经确定的字段就不要让用户以map的形式再去填key-value,而知只让用户填value,但是当我使用NewNamingClient的时候,结果就是不对的。

        github.com/nacos-group/nacos-sdk-go/v2 v2.2.5
	"github.com/nacos-group/nacos-sdk-go/v2/clients"
	"github.com/nacos-group/nacos-sdk-go/v2/common/constant"
	"github.com/nacos-group/nacos-sdk-go/v2/vo"
@yangyile1990 yangyile1990 changed the title 这里配置又不知道是怎么回事 配置CreateNamingClient是好的而NewNamingClient是不行的 Apr 8, 2024
@yangyile1990 yangyile1990 changed the title 配置CreateNamingClient是好的而NewNamingClient是不行的 配置CreateNamingClient是通的而NewNamingClient是不通的 Apr 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant