kitex-contrib / registry-consul

Apache License 2.0
5 stars 11 forks source link

服务注册时使用了tags,但注册后在consul的meta里 #6

Closed booldesign closed 1 year ago

booldesign commented 1 year ago

我服务注册时使用了tags,但注册后在consul的meta里

func localOption() []server.Option {
    r, err := consul.NewConsulRegister(util.ConsulAddr())
    if err != nil {
        panic(err)
    }
    address, err := net.ResolveTCPAddr("tcp", constant.ServicesAccountServiceAddr)
    if err != nil {
        panic(err)
    }
    return []server.Option{
        server.WithSuite(trace.NewDefaultServerSuite()),
        server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: constant.ServicesAccountServiceName}),
        server.WithRegistry(r),
        server.WithRegistryInfo(&registry.Info{
            Addr:        address,
            ServiceName: constant.ServicesAccountServiceName,
            StartTime:   time.Now(),
            Tags: map[string]string{
                "version": "1.0",  // 这边注册tag
            }}),
        server.WithServiceAddr(address),
        server.WithLimit(&limit.Option{MaxConnections: constant.MaxConnections, MaxQPS: constant.MaxQPS}),
    }
}

在consul的后台,发现在meta里 image

看了registry-consul代码,tag也是当meta使用的

li-jin-gou commented 1 year ago

cc @baiyutang

li-jin-gou commented 1 year ago

image 我看到代码实现是这样的,不知道这里是否可以设置到 tags

Dup4 commented 1 year ago

我猜可能是因为 consul 的 注册服务接口 里的 Tags 字段是一个 array<string>,而 Metamap<string|string>

baiyutang commented 1 year ago

明天确定下回复两位

获取Outlook for Androidhttps://aka.ms/AAb9ysg


From: Dup4 @.> Sent: Tuesday, March 21, 2023 7:50:53 PM To: kitex-contrib/registry-consul @.> Cc: baiyutang @.>; Mention @.> Subject: Re: [kitex-contrib/registry-consul] 服务注册时使用了tags,但注册后在consul的meta里 (Issue #6)

我猜可能是因为 注册服务接口https://developer.hashicorp.com/consul/api-docs/agent/service#register-service 里的 Tagshttps://developer.hashicorp.com/consul/api-docs/agent/service#tags 字段是一个 array,而 Metahttps://developer.hashicorp.com/consul/api-docs/agent/service#meta 是 map<string|string>。

― Reply to this email directly, view it on GitHubhttps://github.com/kitex-contrib/registry-consul/issues/6#issuecomment-1477700917, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACSILZ7P4G3PEDMUICW2GCDW5GIZ3ANCNFSM6AAAAAAWCGPFZM. You are receiving this because you were mentioned.Message ID: @.***>

lilaoba123 commented 1 year ago

我也发现了这个问题,tag注册进去了,但服务发现不能指定到某个tag