Skip to content
Permalink
Browse files
feat: 给nacos增加订阅
  • Loading branch information
godkun committed Jul 4, 2021
1 parent c66185c commit e478224a9a42b1224eea0532a0d4e1e0bf9b06f5
Showing 1 changed file with 11 additions and 9 deletions.
@@ -91,18 +91,20 @@ export class NacosRegistry
this.findDubboServiceUrl(dubboInterface)
)
)
this.emitData(this.dubboServiceUrlMap)
}

async findDubboServiceUrl(dubboInterface: string) {
const dubboServiceUrls = await this.client.getAllInstances(dubboInterface)
dlog('dubboServiceUrls => %O', dubboServiceUrls)
for (let { ip: hostname, port, metadata } of dubboServiceUrls) {
const url = `beehive://${hostname}:${port}/${dubboInterface}?${qs.stringify(
metadata
)}`
this.dubboServiceUrlMap.set(dubboInterface, [url])
}
this.client.subscribe(dubboInterface, (dubboServiceUrls) => {
dlog('dubboServiceUrls => %O', dubboServiceUrls)
const urls = dubboServiceUrls.map((item) => {
const { ip, port, serviceName, metadata } = item
const inf = serviceName.split('@@')[1]
return `beehive://${ip}:${port}/${inf}?${qs.stringify(metadata)}`
})
this.dubboServiceUrlMap.set(dubboInterface, urls)
dlog('urls => %O', urls)
this.emitData(this.dubboServiceUrlMap)
})
}

// 注册服务提供

0 comments on commit e478224

Please sign in to comment.