W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
Kitex 支持自定義注冊模塊,使用者可自行擴展集成其他注冊中心,該擴展定義在 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 指定自己的注冊模塊和自定義的注冊信息。注意注冊需要服務(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號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: