W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
Kitex 支持自定義注冊(cè)模塊,使用者可自行擴(kuò)展集成其他注冊(cè)中心,該擴(kuò)展定義在 pkg/registry 下。
// Registry is extension interface of service registry.
type Registry interface {
Register(info *Info) error
Deregister(info *Info) error
}
// Info is used for registry.
// The fields are just suggested, which is used depends on design.
type Info struct {
// ServiceName will be set in kitex by default
ServiceName string
// Addr will be set in kitex by default
Addr net.Addr
// PayloadCodec will be set in kitex by default, like thrift, protobuf
PayloadCodec string
Weight int
StartTime time.Time
WarmUp time.Duration
// extend other infos with Tags.
Tags map[string]string
}
通過 option 指定自己的注冊(cè)模塊和自定義的注冊(cè)信息。注意注冊(cè)需要服務(wù)信息,服務(wù)信息也是通過 option 指定。
option: ?WithServerBasicInfo
?
ebi := &rpcinfo.EndpointBasicInfo{
ServiceName: 'yourServiceName',
Tags: make(map[string]string),
}
ebi.Tags[idc] = "xxx"
svr := xxxservice.NewServer(handler, server.WithServerBasicInfo(ebi))
WithRegistry
?svr := xxxservice.NewServer(handler, server.WithServerBasicInfo(ebi), server.WithRegistry(yourRegistry))
WithRegistryInfo
?svr := xxxservice.NewServer(handler, server.WithRegistry(yourRegistry), server.WithRegistryInfo(yourRegistryInfo))
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: