vipyxc-byte commented on issue #2981:
URL: https://github.com/apache/dubbo-go/issues/2981#issuecomment-3235479858
补充rpc服务加载逻辑(如需提供源码,再联系哦):
1. dubbogo.yaml是我通过koanf.Koanf加载的,序列化为rpcTransporter实例
2.
将Consumer转换GenericApi,初始化referenceCache的references,key是GenericApi的group+"/"+interfaceName+":"+version
3. 拿到reference实例后,调用reference的load方法加载rpc服务,并赋值给reference的rf属性
```
type rpcTransporter struct {
// Consumer不参与config.loadReference
// 获取registryIds/RequestTimeout/References
Consumer *config.ConsumerConfig `yaml:"consumer" json:"consumer"
property:"consumer"`
references *referenceCache
}
type referenceCache struct { // 自定义缓存
references map[string]*reference //
key:group+"/"+interfaceName+":"+version
lock sync.RWMutex // 保证 references 的并发安全
}
type reference struct { // 泛化服务的包装
lock sync.Mutex // 保证 rf 的并发安全
rf *config.ReferenceConfig // 泛化服务的引用
}
type GenericApi struct { // consumer转为自定义的GenericApi,进行rpc服务的加载
application string // 所属应用
protocol string // 协议,必须
interfaceName string // 接口名,必须
version string // 版本
group string // 分组
timeout string // 超时时间,注意要带单位,例如:5s
retries string // 重试次数
waitForInitSecond time.Duration //
静态注册的dubbo消费者初始化的时间,单位:秒,动态注册的api等待时间是固定值
}
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]