Documentation ¶
Overview ¶
Package pb is a generated protocol buffer package.
It is generated from these files:
cnt2.proto
It has these top-level messages:
RegisterRequest RegisterResponse QueryRequest QueryResponse ResponseMessage ValueChangeResultRequest ValueChangeResultResponse
Index ¶
- Constants
- Variables
- func ChooseBestAddress(grpcServerInfos []GrpcServerInfo) ([]string, bool)
- func ExtractCntInfo(nodeKey string) (string, string, string, bool)
- func GenRegisterNodeKey(app, profile, nodeId string) string
- func GenWatchCnt2CommonKey(app string) string
- func GenWatchCnt2Key(app, profile string) string
- func GenWatchGrpcServerKey() string
- func GetMyIPInfo() []string
- func NewSource(opts ...source.Option) (source.Source, error)
- func RegisterConfigCenterServiceServer(s *grpc.Server, srv ConfigCenterServiceServer)
- func WithApp(n string) source.Option
- func WithCachePath(f string) source.Option
- func WithCommon(wc int) source.Option
- func WithEtcdAddrs(a string) source.Option
- func WithForceQueryAll(f bool) source.Option
- func WithProfile(a string) source.Option
- func WithTimeOut(to int) source.Option
- type ClientConfig
- type Cnt2Service
- func (c2 *Cnt2Service) Close()
- func (c2 *Cnt2Service) GetAllConfig() map[string]string
- func (c2 *Cnt2Service) GetConfig(key string) (string, bool)
- func (c2 *Cnt2Service) InitGrpcServer() (ConfigCenterServiceClient, error)
- func (c2 *Cnt2Service) WatchCnt2(configCenterClient ConfigCenterServiceClient)
- func (c2 *Cnt2Service) WatchCnt2Common(configCenterClient ConfigCenterServiceClient)
- func (c2 *Cnt2Service) WatchGrpcServer()
- type Config
- type ConfigCenterServiceClient
- type ConfigCenterServiceServer
- type ConfigPublishInfo
- type GrpcServerBalancer
- type GrpcServerChan
- type GrpcServerInfo
- type HostIP
- type HostInfo
- type LocalStore
- func (ls *LocalStore) Clean()
- func (ls *LocalStore) Del(app, profile, key string) error
- func (ls *LocalStore) Get(app, profile, key string) string
- func (ls *LocalStore) GetAll(app, profile string) map[string]string
- func (ls *LocalStore) GetConfig(app, profile, key string) (*Config, error)
- func (ls *LocalStore) Has(app, profile, key string) bool
- func (ls *LocalStore) Put(app, profile, key, value string) error
- func (ls *LocalStore) Recreate() error
- type NetType
- type Node
- type QueryRequest
- func (*QueryRequest) Descriptor() ([]byte, []int)
- func (m *QueryRequest) GetApp() string
- func (m *QueryRequest) GetKey() string
- func (m *QueryRequest) GetKeyVersion() int64
- func (m *QueryRequest) GetProfile() string
- func (*QueryRequest) ProtoMessage()
- func (m *QueryRequest) Reset()
- func (m *QueryRequest) String() string
- type QueryResponse
- type RegisterRequest
- func (*RegisterRequest) Descriptor() ([]byte, []int)
- func (m *RegisterRequest) GetApp() string
- func (m *RegisterRequest) GetPid() string
- func (m *RegisterRequest) GetProfile() string
- func (m *RegisterRequest) GetServerIp() string
- func (*RegisterRequest) ProtoMessage()
- func (m *RegisterRequest) Reset()
- func (m *RegisterRequest) String() string
- type RegisterResponse
- type ResponseMessage
- func (*ResponseMessage) Descriptor() ([]byte, []int)
- func (m *ResponseMessage) GetKey() string
- func (m *ResponseMessage) GetPath() string
- func (m *ResponseMessage) GetProfile() string
- func (m *ResponseMessage) GetValue() string
- func (m *ResponseMessage) GetVersion() int64
- func (*ResponseMessage) ProtoMessage()
- func (m *ResponseMessage) Reset()
- func (m *ResponseMessage) String() string
- type StringArray
- type ValueChangeResultRequest
- func (*ValueChangeResultRequest) Descriptor() ([]byte, []int)
- func (m *ValueChangeResultRequest) GetApp() string
- func (m *ValueChangeResultRequest) GetDeployId() string
- func (m *ValueChangeResultRequest) GetKey() string
- func (m *ValueChangeResultRequest) GetMsg() string
- func (m *ValueChangeResultRequest) GetNodeId() string
- func (m *ValueChangeResultRequest) GetProfile() string
- func (m *ValueChangeResultRequest) GetResult() ValueChangeResultRequest_ValueChangeResult
- func (m *ValueChangeResultRequest) GetVersion() int64
- func (*ValueChangeResultRequest) ProtoMessage()
- func (m *ValueChangeResultRequest) Reset()
- func (m *ValueChangeResultRequest) String() string
- type ValueChangeResultRequest_ValueChangeResult
- type ValueChangeResultResponse
- func (*ValueChangeResultResponse) Descriptor() ([]byte, []int)
- func (m *ValueChangeResultResponse) GetMsg() string
- func (m *ValueChangeResultResponse) GetStatus() int32
- func (*ValueChangeResultResponse) ProtoMessage()
- func (m *ValueChangeResultResponse) Reset()
- func (m *ValueChangeResultResponse) String() string
Constants ¶
View Source
const (
BUCKET_NAME = "cnt2_bucket"
)
View Source
const COMMON = "common"
View Source
const (
Node_TTL = int64(30)
)
*
- 流程:
- 1.到ETCD拿GrpcServer的信息
- 2.到ConfigCenter注册,拿到nodeId
- 3.到etcd注册临时节点(/${appName}/nodes/${nodeId})
- 4.到ConfigCenter查询当前profile下所有配置,写入本地副本
- 5.订阅节点变化(/${appName}/profiles/${profile}),在服务端配置发生变化时更新本地副本
- 6.配置发生变化是通知业务
- 7.如果注册失败则去读本地文件
Variables ¶
View Source
var ValueChangeResultRequest_ValueChangeResult_name = map[int32]string{
0: "FAILED",
1: "SUCCESS",
}
View Source
var ValueChangeResultRequest_ValueChangeResult_value = map[string]int32{
"FAILED": 0,
"SUCCESS": 1,
}
Functions ¶
func ChooseBestAddress ¶
func ChooseBestAddress(grpcServerInfos []GrpcServerInfo) ([]string, bool)
FIXME can be better?
func ExtractCntInfo ¶
* return app ,profile,key
func GenRegisterNodeKey ¶
func GenWatchCnt2CommonKey ¶
func GenWatchCnt2Key ¶
func GenWatchGrpcServerKey ¶
func GenWatchGrpcServerKey() string
func GetMyIPInfo ¶
func GetMyIPInfo() []string
func RegisterConfigCenterServiceServer ¶
func RegisterConfigCenterServiceServer(s *grpc.Server, srv ConfigCenterServiceServer)
func WithCommon ¶
func WithForceQueryAll ¶
func WithTimeOut ¶
Types ¶
type ClientConfig ¶
type Cnt2Service ¶
type Cnt2Service struct { *ClientConfig // contains filtered or unexported fields }
func NewCnt2Service ¶
func NewCnt2Service(ccfg *ClientConfig, forceQueryAll bool) (*Cnt2Service, error)
func (*Cnt2Service) Close ¶
func (c2 *Cnt2Service) Close()
func (*Cnt2Service) GetAllConfig ¶
func (c2 *Cnt2Service) GetAllConfig() map[string]string
func (*Cnt2Service) InitGrpcServer ¶
func (c2 *Cnt2Service) InitGrpcServer() (ConfigCenterServiceClient, error)
func (*Cnt2Service) WatchCnt2 ¶
func (c2 *Cnt2Service) WatchCnt2(configCenterClient ConfigCenterServiceClient)
监听Cnt2配置
func (*Cnt2Service) WatchCnt2Common ¶
func (c2 *Cnt2Service) WatchCnt2Common(configCenterClient ConfigCenterServiceClient)
监听Cnt2公共配置
type Config ¶
type ConfigCenterServiceClient ¶
type ConfigCenterServiceClient interface { // 根据appId,profile 查询 QueryAll(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error) // 根据appId,profile,key,keyVersion查询,keyVersion=0时,返回最新数据,否则返回指定版本数据 QueryKey(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*ResponseMessage, error) // 发布处理结果通知(灰度才会有这个回调通知) ValueChangeResultNotify(ctx context.Context, in *ValueChangeResultRequest, opts ...grpc.CallOption) (*ValueChangeResultResponse, error) // 启动的时候注册服务:获取服务id RegisterClient(ctx context.Context, in *RegisterRequest, opts ...grpc.CallOption) (*RegisterResponse, error) }
func NewConfigCenterServiceClient ¶
func NewConfigCenterServiceClient(cc *grpc.ClientConn) ConfigCenterServiceClient
type ConfigCenterServiceServer ¶
type ConfigCenterServiceServer interface { // 根据appId,profile 查询 QueryAll(context.Context, *QueryRequest) (*QueryResponse, error) // 根据appId,profile,key,keyVersion查询,keyVersion=0时,返回最新数据,否则返回指定版本数据 QueryKey(context.Context, *QueryRequest) (*ResponseMessage, error) // 发布处理结果通知(灰度才会有这个回调通知) ValueChangeResultNotify(context.Context, *ValueChangeResultRequest) (*ValueChangeResultResponse, error) // 启动的时候注册服务:获取服务id RegisterClient(context.Context, *RegisterRequest) (*RegisterResponse, error) }
type ConfigPublishInfo ¶
type ConfigPublishInfo struct { PublishId int64 `json:"publishId"` Key string `json:"key"` Version int64 `json:"version"` PublishNodes StringArray `json:"publishNodes"` }
type GrpcServerBalancer ¶
type GrpcServerBalancer struct {
// contains filtered or unexported fields
}
func (*GrpcServerBalancer) Init ¶
func (c *GrpcServerBalancer) Init()
type GrpcServerChan ¶
type GrpcServerChan struct {
// contains filtered or unexported fields
}
type GrpcServerInfo ¶
type GrpcServerInfo struct { ServerIP map[int]string `json:"serverIP"` Port int `json:"port"` GroupId int `json:"groupId"` }
func ParseGrpcServerInfoFromEtcd ¶
func ParseGrpcServerInfoFromEtcd(client *clientv3.Client) ([]GrpcServerInfo, error)
type HostInfo ¶
func InitHostInfo ¶
func InitHostInfo() HostInfo
type LocalStore ¶
func InitLocalStore ¶
func InitLocalStore(app, path string) (*LocalStore, error)
func (*LocalStore) Clean ¶
func (ls *LocalStore) Clean()
func (*LocalStore) Del ¶
func (ls *LocalStore) Del(app, profile, key string) error
func (*LocalStore) Get ¶
func (ls *LocalStore) Get(app, profile, key string) string
func (*LocalStore) GetConfig ¶
func (ls *LocalStore) GetConfig(app, profile, key string) (*Config, error)
func (*LocalStore) Has ¶
func (ls *LocalStore) Has(app, profile, key string) bool
func (*LocalStore) Put ¶
func (ls *LocalStore) Put(app, profile, key, value string) error
func (*LocalStore) Recreate ¶
func (ls *LocalStore) Recreate() error
type QueryRequest ¶
type QueryRequest struct { App string `protobuf:"bytes,1,opt,name=app" json:"app,omitempty"` Profile string `protobuf:"bytes,2,opt,name=profile" json:"profile,omitempty"` Key string `protobuf:"bytes,3,opt,name=key" json:"key,omitempty"` KeyVersion int64 `protobuf:"varint,4,opt,name=key_version,json=keyVersion" json:"key_version,omitempty"` }
func (*QueryRequest) Descriptor ¶
func (*QueryRequest) Descriptor() ([]byte, []int)
func (*QueryRequest) GetApp ¶
func (m *QueryRequest) GetApp() string
func (*QueryRequest) GetKey ¶
func (m *QueryRequest) GetKey() string
func (*QueryRequest) GetKeyVersion ¶
func (m *QueryRequest) GetKeyVersion() int64
func (*QueryRequest) GetProfile ¶
func (m *QueryRequest) GetProfile() string
func (*QueryRequest) ProtoMessage ¶
func (*QueryRequest) ProtoMessage()
func (*QueryRequest) Reset ¶
func (m *QueryRequest) Reset()
func (*QueryRequest) String ¶
func (m *QueryRequest) String() string
type QueryResponse ¶
type QueryResponse struct {
Result []*ResponseMessage `protobuf:"bytes,1,rep,name=result" json:"result,omitempty"`
}
func (*QueryResponse) Descriptor ¶
func (*QueryResponse) Descriptor() ([]byte, []int)
func (*QueryResponse) GetResult ¶
func (m *QueryResponse) GetResult() []*ResponseMessage
func (*QueryResponse) ProtoMessage ¶
func (*QueryResponse) ProtoMessage()
func (*QueryResponse) Reset ¶
func (m *QueryResponse) Reset()
func (*QueryResponse) String ¶
func (m *QueryResponse) String() string
type RegisterRequest ¶
type RegisterRequest struct { App string `protobuf:"bytes,1,opt,name=app" json:"app,omitempty"` Profile string `protobuf:"bytes,2,opt,name=profile" json:"profile,omitempty"` ServerIp string `protobuf:"bytes,3,opt,name=server_ip,json=serverIp" json:"server_ip,omitempty"` Pid string `protobuf:"bytes,4,opt,name=pid" json:"pid,omitempty"` }
func (*RegisterRequest) Descriptor ¶
func (*RegisterRequest) Descriptor() ([]byte, []int)
func (*RegisterRequest) GetApp ¶
func (m *RegisterRequest) GetApp() string
func (*RegisterRequest) GetPid ¶
func (m *RegisterRequest) GetPid() string
func (*RegisterRequest) GetProfile ¶
func (m *RegisterRequest) GetProfile() string
func (*RegisterRequest) GetServerIp ¶
func (m *RegisterRequest) GetServerIp() string
func (*RegisterRequest) ProtoMessage ¶
func (*RegisterRequest) ProtoMessage()
func (*RegisterRequest) Reset ¶
func (m *RegisterRequest) Reset()
func (*RegisterRequest) String ¶
func (m *RegisterRequest) String() string
type RegisterResponse ¶
type RegisterResponse struct { Result int32 `protobuf:"varint,1,opt,name=result" json:"result,omitempty"` NodeId string `protobuf:"bytes,2,opt,name=node_id,json=nodeId" json:"node_id,omitempty"` }
func (*RegisterResponse) Descriptor ¶
func (*RegisterResponse) Descriptor() ([]byte, []int)
func (*RegisterResponse) GetNodeId ¶
func (m *RegisterResponse) GetNodeId() string
func (*RegisterResponse) GetResult ¶
func (m *RegisterResponse) GetResult() int32
func (*RegisterResponse) ProtoMessage ¶
func (*RegisterResponse) ProtoMessage()
func (*RegisterResponse) Reset ¶
func (m *RegisterResponse) Reset()
func (*RegisterResponse) String ¶
func (m *RegisterResponse) String() string
type ResponseMessage ¶
type ResponseMessage struct { Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` Profile string `protobuf:"bytes,2,opt,name=profile" json:"profile,omitempty"` Path string `protobuf:"bytes,3,opt,name=path" json:"path,omitempty"` Value string `protobuf:"bytes,4,opt,name=value" json:"value,omitempty"` Version int64 `protobuf:"varint,5,opt,name=version" json:"version,omitempty"` }
func (*ResponseMessage) Descriptor ¶
func (*ResponseMessage) Descriptor() ([]byte, []int)
func (*ResponseMessage) GetKey ¶
func (m *ResponseMessage) GetKey() string
func (*ResponseMessage) GetPath ¶
func (m *ResponseMessage) GetPath() string
func (*ResponseMessage) GetProfile ¶
func (m *ResponseMessage) GetProfile() string
func (*ResponseMessage) GetValue ¶
func (m *ResponseMessage) GetValue() string
func (*ResponseMessage) GetVersion ¶
func (m *ResponseMessage) GetVersion() int64
func (*ResponseMessage) ProtoMessage ¶
func (*ResponseMessage) ProtoMessage()
func (*ResponseMessage) Reset ¶
func (m *ResponseMessage) Reset()
func (*ResponseMessage) String ¶
func (m *ResponseMessage) String() string
type StringArray ¶
type StringArray []string
func (StringArray) Contains ¶
func (array StringArray) Contains(val string) bool
func (StringArray) Remove ¶
func (array StringArray) Remove(target string) StringArray
type ValueChangeResultRequest ¶
type ValueChangeResultRequest struct { NodeId string `protobuf:"bytes,1,opt,name=node_id,json=nodeId" json:"node_id,omitempty"` App string `protobuf:"bytes,2,opt,name=app" json:"app,omitempty"` Profile string `protobuf:"bytes,3,opt,name=profile" json:"profile,omitempty"` Key string `protobuf:"bytes,4,opt,name=key" json:"key,omitempty"` DeployId string `protobuf:"bytes,5,opt,name=deploy_id,json=deployId" json:"deploy_id,omitempty"` Result ValueChangeResultRequest_ValueChangeResult `protobuf:"varint,6,opt,name=result,enum=pb.ValueChangeResultRequest_ValueChangeResult" json:"result,omitempty"` Msg string `protobuf:"bytes,7,opt,name=msg" json:"msg,omitempty"` Version int64 `protobuf:"varint,8,opt,name=version" json:"version,omitempty"` }
func (*ValueChangeResultRequest) Descriptor ¶
func (*ValueChangeResultRequest) Descriptor() ([]byte, []int)
func (*ValueChangeResultRequest) GetApp ¶
func (m *ValueChangeResultRequest) GetApp() string
func (*ValueChangeResultRequest) GetDeployId ¶
func (m *ValueChangeResultRequest) GetDeployId() string
func (*ValueChangeResultRequest) GetKey ¶
func (m *ValueChangeResultRequest) GetKey() string
func (*ValueChangeResultRequest) GetMsg ¶
func (m *ValueChangeResultRequest) GetMsg() string
func (*ValueChangeResultRequest) GetNodeId ¶
func (m *ValueChangeResultRequest) GetNodeId() string
func (*ValueChangeResultRequest) GetProfile ¶
func (m *ValueChangeResultRequest) GetProfile() string
func (*ValueChangeResultRequest) GetResult ¶
func (m *ValueChangeResultRequest) GetResult() ValueChangeResultRequest_ValueChangeResult
func (*ValueChangeResultRequest) GetVersion ¶
func (m *ValueChangeResultRequest) GetVersion() int64
func (*ValueChangeResultRequest) ProtoMessage ¶
func (*ValueChangeResultRequest) ProtoMessage()
func (*ValueChangeResultRequest) Reset ¶
func (m *ValueChangeResultRequest) Reset()
func (*ValueChangeResultRequest) String ¶
func (m *ValueChangeResultRequest) String() string
type ValueChangeResultRequest_ValueChangeResult ¶
type ValueChangeResultRequest_ValueChangeResult int32
const ( ValueChangeResultRequest_FAILED ValueChangeResultRequest_ValueChangeResult = 0 ValueChangeResultRequest_SUCCESS ValueChangeResultRequest_ValueChangeResult = 1 )
func (ValueChangeResultRequest_ValueChangeResult) EnumDescriptor ¶
func (ValueChangeResultRequest_ValueChangeResult) EnumDescriptor() ([]byte, []int)
func (ValueChangeResultRequest_ValueChangeResult) String ¶
func (x ValueChangeResultRequest_ValueChangeResult) String() string
type ValueChangeResultResponse ¶
type ValueChangeResultResponse struct { Status int32 `protobuf:"varint,1,opt,name=status" json:"status,omitempty"` Msg string `protobuf:"bytes,2,opt,name=msg" json:"msg,omitempty"` }
func (*ValueChangeResultResponse) Descriptor ¶
func (*ValueChangeResultResponse) Descriptor() ([]byte, []int)
func (*ValueChangeResultResponse) GetMsg ¶
func (m *ValueChangeResultResponse) GetMsg() string
func (*ValueChangeResultResponse) GetStatus ¶
func (m *ValueChangeResultResponse) GetStatus() int32
func (*ValueChangeResultResponse) ProtoMessage ¶
func (*ValueChangeResultResponse) ProtoMessage()
func (*ValueChangeResultResponse) Reset ¶
func (m *ValueChangeResultResponse) Reset()
func (*ValueChangeResultResponse) String ¶
func (m *ValueChangeResultResponse) String() string
Click to show internal directories.
Click to hide internal directories.