From f406360599d97c5b1034f2c8c999c1fa2ce50e3e Mon Sep 17 00:00:00 2001 From: lepdou Date: Sat, 7 May 2022 14:56:55 +0800 Subject: [PATCH 1/2] support dynamic config --- api/config_file.go | 36 + api/config_file_impl.go | 55 + examples/configuration/main.go | 65 + examples/configuration/polaris.yaml | 8 + pkg/config/api.go | 23 + pkg/config/config_connector.go | 229 +++ pkg/config/config_file.go | 118 ++ pkg/config/default.go | 19 + pkg/config/impl.go | 12 +- pkg/flow/configuration/factory.go | 78 + pkg/flow/configuration/manager.go | 77 + pkg/flow/configuration/model.go | 122 ++ pkg/flow/configuration/remote/config.go | 267 ++++ pkg/flow/configuration/remote/polling.go | 185 +++ pkg/flow/configuration/remote/retry_policy.go | 52 + pkg/flow/configuration/remote/type.go | 24 + pkg/flow/configuration/service.go | 68 + pkg/flow/configuration/util/cache_key.go | 47 + pkg/flow/data/util.go | 14 + pkg/flow/impl.go | 24 + pkg/flow/sync_flow.go | 5 + pkg/model/config.go | 93 ++ pkg/model/engine.go | 2 + pkg/model/pb/v1/config_file.pb.go | 1258 +++++++++++++++++ pkg/model/pb/v1/config_file.proto | 91 ++ pkg/model/pb/v1/config_file_response.pb.go | 637 +++++++++ pkg/model/pb/v1/config_file_response.proto | 48 + pkg/model/pb/v1/grpc_config_api.pb.go | 210 +++ pkg/model/pb/v1/grpc_config_api.proto | 18 + pkg/network/conn.go | 1 + pkg/network/impl.go | 40 +- pkg/plugin/common/plugin.go | 4 + .../configconnector/config_connector.go | 38 + pkg/plugin/configconnector/config_file.go | 59 + .../configconnector/config_file_response.go | 41 + pkg/plugin/configconnector/proxy.go | 52 + pkg/plugin/register/plugins.go | 2 + plugin/configconnector/polaris/config.go | 53 + .../polaris/config_connector.go | 265 ++++ plugin/configconnector/polaris/creator.go | 94 ++ plugin/serverconnector/common/util.go | 14 + polaris.yaml | 29 +- 42 files changed, 4571 insertions(+), 6 deletions(-) create mode 100644 api/config_file.go create mode 100644 api/config_file_impl.go create mode 100644 examples/configuration/main.go create mode 100644 examples/configuration/polaris.yaml create mode 100644 pkg/config/config_connector.go create mode 100644 pkg/config/config_file.go create mode 100644 pkg/flow/configuration/factory.go create mode 100644 pkg/flow/configuration/manager.go create mode 100644 pkg/flow/configuration/model.go create mode 100644 pkg/flow/configuration/remote/config.go create mode 100644 pkg/flow/configuration/remote/polling.go create mode 100644 pkg/flow/configuration/remote/retry_policy.go create mode 100644 pkg/flow/configuration/remote/type.go create mode 100644 pkg/flow/configuration/service.go create mode 100644 pkg/flow/configuration/util/cache_key.go create mode 100644 pkg/model/config.go create mode 100644 pkg/model/pb/v1/config_file.pb.go create mode 100644 pkg/model/pb/v1/config_file.proto create mode 100644 pkg/model/pb/v1/config_file_response.pb.go create mode 100644 pkg/model/pb/v1/config_file_response.proto create mode 100644 pkg/model/pb/v1/grpc_config_api.pb.go create mode 100644 pkg/model/pb/v1/grpc_config_api.proto create mode 100644 pkg/plugin/configconnector/config_connector.go create mode 100644 pkg/plugin/configconnector/config_file.go create mode 100644 pkg/plugin/configconnector/config_file_response.go create mode 100644 pkg/plugin/configconnector/proxy.go create mode 100644 plugin/configconnector/polaris/config.go create mode 100644 plugin/configconnector/polaris/config_connector.go create mode 100644 plugin/configconnector/polaris/creator.go diff --git a/api/config_file.go b/api/config_file.go new file mode 100644 index 00000000..f63a52e1 --- /dev/null +++ b/api/config_file.go @@ -0,0 +1,36 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package api + +import "github.com/polarismesh/polaris-go/pkg/model" + +// ConfigFileAPI 配置文件的 API +type ConfigFileAPI interface { + SDKOwner + // GetConfigFile 获取配置文件 + GetConfigFile(namespace, fileGroup, fileName string) (model.ConfigFile, error) +} + +var ( + // NewConfigFileAPIBySDKContext 通过 SDKContext 创建 ConfigFileAPI + NewConfigFileAPIBySDKContext = newConfigFileAPIBySDKContext + // NewConfigFileAPI 通过 polaris.yaml 创建 ConfigFileAPI + NewConfigFileAPI = newConfigFileAPI + // NewConfigFileAPIByConfig 通过 Configuration 创建 ConfigFileAPI + NewConfigFileAPIByConfig = newConfigFileAPIByConfig +) diff --git a/api/config_file_impl.go b/api/config_file_impl.go new file mode 100644 index 00000000..0fe539e7 --- /dev/null +++ b/api/config_file_impl.go @@ -0,0 +1,55 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package api + +import ( + "github.com/polarismesh/polaris-go/pkg/config" + "github.com/polarismesh/polaris-go/pkg/model" +) + +type configFileAPI struct { + context SDKContext +} + +func newConfigFileAPI() (ConfigFileAPI, error) { + return newConfigFileAPIByConfig(config.NewDefaultConfigurationWithDomain()) +} + +func newConfigFileAPIByConfig(cfg config.Configuration) (ConfigFileAPI, error) { + context, err := InitContextByConfig(cfg) + if err != nil { + return nil, err + } + return &configFileAPI{context}, nil +} + +func newConfigFileAPIBySDKContext(context SDKContext) ConfigFileAPI { + return &configFileAPI{ + context: context, + } +} + +// GetConfigFile 获取配置文件 +func (c *configFileAPI) GetConfigFile(namespace, fileGroup, fileName string) (model.ConfigFile, error) { + return c.context.GetEngine().SyncGetConfigFile(namespace, fileGroup, fileName) +} + +// SDKContext 获取SDK上下文 +func (c *configFileAPI) SDKContext() SDKContext { + return c.context +} diff --git a/examples/configuration/main.go b/examples/configuration/main.go new file mode 100644 index 00000000..83c77fae --- /dev/null +++ b/examples/configuration/main.go @@ -0,0 +1,65 @@ +/** + * Tencent is pleased to support the open source community by making polaris-go available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package main + +import ( + "fmt" + "github.com/polarismesh/polaris-go/api" + "github.com/polarismesh/polaris-go/pkg/model" +) + +func main() { + configFileAPI, err := api.NewConfigFileAPI() + + if err != nil { + fmt.Println("fail to start example.", err) + return + } + + //获取远程的配置文件 + namespace := "default" + fileGroup := "polaris-config-example" + fileName := "example.yaml" + + configFile, err := configFileAPI.GetConfigFile(namespace, fileGroup, fileName) + if err != nil { + fmt.Println("fail to get config.", err) + return + } + + // 打印配置文件内容 + fmt.Println(configFile.GetContent()) + + // 方式一:添加监听器 + configFile.AddChangeListener(changeListener) + + //方式二:添加监听器 + changeChan := make(chan model.ConfigFileChangeEvent) + configFile.AddChangeListenerWithChannel(changeChan) + + for { + select { + case event := <-changeChan: + fmt.Println(fmt.Sprintf("received change event by channel. %+v", event)) + } + } +} + +func changeListener(event model.ConfigFileChangeEvent) { + fmt.Println(fmt.Sprintf("received change event. %+v", event)) +} diff --git a/examples/configuration/polaris.yaml b/examples/configuration/polaris.yaml new file mode 100644 index 00000000..fdee6156 --- /dev/null +++ b/examples/configuration/polaris.yaml @@ -0,0 +1,8 @@ +global: + serverConnector: + addresses: + - 127.0.0.1:8091 +config: + configConnector: + addresses: + - 127.0.0.1:8093 diff --git a/pkg/config/api.go b/pkg/config/api.go index 4c3ed4cc..2cc9ee6a 100644 --- a/pkg/config/api.go +++ b/pkg/config/api.go @@ -72,6 +72,19 @@ type ProviderConfig interface { GetRateLimit() RateLimitConfig } +// ConfigFileConfig 配置中心的配置 +type ConfigFileConfig interface { + BaseConfig + // IsEnable 是否启用配置中心 + IsEnable() bool + // GetConfigConnectorConfig 配置文件连接器 + GetConfigConnectorConfig() ConfigConnectorConfig + // GetPropertiesValueCacheSize 值缓存的最大数量 + GetPropertiesValueCacheSize() int32 + // GetPropertiesValueExpireTime 缓存的过期时间,默认为 60s + GetPropertiesValueExpireTime() int64 +} + // RateLimitConfig 限流相关配置 type RateLimitConfig interface { BaseConfig @@ -407,6 +420,8 @@ type Configuration interface { GetConsumer() ConsumerConfig // GetProvider provider前缀开头的所有配置项 GetProvider() ProviderConfig + // GetConfigFile config前缀开头的所有配置项 + GetConfigFile() ConfigFileConfig } // When when to active health check @@ -465,3 +480,11 @@ type ServiceSpecificConfig interface { GetServiceRouter() ServiceRouterConfig } + +// ConfigConnectorConfig 配置中心连接相关的配置 +type ConfigConnectorConfig interface { + ServerConnectorConfig + + // GetConnectorType 后端服务器类型,默认是 polaris + GetConnectorType() string +} diff --git a/pkg/config/config_connector.go b/pkg/config/config_connector.go new file mode 100644 index 00000000..9ce08167 --- /dev/null +++ b/pkg/config/config_connector.go @@ -0,0 +1,229 @@ +/* + * Tencent is pleased to support the open source community by making polaris-go available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + */ + +package config + +import ( + "errors" + "fmt" + "time" + + "github.com/polarismesh/polaris-go/pkg/model" + "google.golang.org/protobuf/proto" + + "github.com/hashicorp/go-multierror" + + "github.com/polarismesh/polaris-go/pkg/plugin/common" +) + +// ConfigConnectorConfigImpl 对接配置中心连接器相关配置 +type ConfigConnectorConfigImpl struct { + Addresses []string `yaml:"addresses" json:"addresses"` + + Protocol string `yaml:"protocol" json:"protocol"` + + ConnectTimeout *time.Duration `yaml:"connectTimeout" json:"connectTimeout"` + + // 远程请求超时时间 + MessageTimeout *time.Duration `yaml:"messageTimeout" json:"messageTimeout"` + + ConnectionIdleTimeout *time.Duration `yaml:"connectionIdleTimeout" json:"connectionIdleTimeout"` + + RequestQueueSize *int32 `yaml:"requestQueueSize" json:"requestQueueSize"` + + ServerSwitchInterval *time.Duration `yaml:"serverSwitchInterval" json:"serverSwitchInterval"` + + ReconnectInterval *time.Duration `yaml:"reconnectInterval" json:"reconnectInterval"` + + Plugin PluginConfigs `yaml:"plugin" json:"plugin"` + + ConnectorType string `yaml:"connectorType" json:"connectorType"` +} + +// GetAddresses config.configConnector.addresses +func (c *ConfigConnectorConfigImpl) GetAddresses() []string { + return c.Addresses +} + +// SetAddresses 设置远端server地址,格式为: +func (c *ConfigConnectorConfigImpl) SetAddresses(addresses []string) { + c.Addresses = addresses +} + +// GetProtocol config.configConnector.protocol +func (c *ConfigConnectorConfigImpl) GetProtocol() string { + return c.Protocol +} + +// SetProtocol 设置与server对接的协议 +func (c *ConfigConnectorConfigImpl) SetProtocol(protocol string) { + c.Protocol = protocol +} + +// GetConnectTimeout config.configConnector.connectTimeout +func (c *ConfigConnectorConfigImpl) GetConnectTimeout() time.Duration { + return *c.ConnectTimeout +} + +// SetConnectTimeout 设置与server的连接超时时间 +func (c *ConfigConnectorConfigImpl) SetConnectTimeout(timeout time.Duration) { + c.ConnectTimeout = &timeout +} + +// GetMessageTimeout config.configConnector.messageTimeout +func (c *ConfigConnectorConfigImpl) GetMessageTimeout() time.Duration { + return *c.MessageTimeout +} + +// SetMessageTimeout 设置远程请求超时时间 +func (c *ConfigConnectorConfigImpl) SetMessageTimeout(timeout time.Duration) { + c.MessageTimeout = &timeout +} + +// GetConnectionIdleTimeout config.configConnector.connectionIdleTimeout +func (c *ConfigConnectorConfigImpl) GetConnectionIdleTimeout() time.Duration { + return *c.ConnectionIdleTimeout +} + +// SetConnectionIdleTimeout 设置连接空闲后超时时间 +func (c *ConfigConnectorConfigImpl) SetConnectionIdleTimeout(timeout time.Duration) { + c.ConnectionIdleTimeout = &timeout +} + +// GetRequestQueueSize config.configConnector.requestQueueSize +func (c *ConfigConnectorConfigImpl) GetRequestQueueSize() int32 { + return *c.RequestQueueSize +} + +// SetRequestQueueSize 设置新请求的队列BUFFER容量 +func (c *ConfigConnectorConfigImpl) SetRequestQueueSize(queueSize int32) { + c.RequestQueueSize = &queueSize +} + +// GetServerSwitchInterval config.configConnector.serverSwitchInterval +func (c *ConfigConnectorConfigImpl) GetServerSwitchInterval() time.Duration { + return *c.ServerSwitchInterval +} + +// SetServerSwitchInterval 设置server的切换时延 +func (c *ConfigConnectorConfigImpl) SetServerSwitchInterval(interval time.Duration) { + c.ServerSwitchInterval = &interval +} + +// GetReconnectInterval 一次连接失败后,到下一次连接之间的最小间隔时间 +func (c *ConfigConnectorConfigImpl) GetReconnectInterval() time.Duration { + return *c.ReconnectInterval +} + +// SetReconnectInterval 一次连接失败后,到下一次连接之间的最小间隔时间 +func (c *ConfigConnectorConfigImpl) SetReconnectInterval(interval time.Duration) { + c.ReconnectInterval = &interval +} + +// GetPluginConfig config.configConnector.plugin +func (c *ConfigConnectorConfigImpl) GetPluginConfig(pluginName string) BaseConfig { + cfgValue, ok := c.Plugin[pluginName] + if !ok { + return nil + } + return cfgValue.(BaseConfig) +} + +// SetPluginConfig 输出插件具体配置 +func (c *ConfigConnectorConfigImpl) SetPluginConfig(pluginName string, value BaseConfig) error { + return c.Plugin.SetPluginConfig(common.TypeServerConnector, pluginName, value) +} + +// GetConnectorType 获取连接器类型 +func (c *ConfigConnectorConfigImpl) GetConnectorType() string { + return c.ConnectorType +} + +// SetConnectorType 设置连接器类型 +func (c *ConfigConnectorConfigImpl) SetConnectorType(connectorType string) { + c.ConnectorType = connectorType +} + +// Verify 检验ConfigConnector配置 +func (c *ConfigConnectorConfigImpl) Verify() error { + if nil == c { + return errors.New("ConfigConnectorConfig is nil") + } + var errs error + if len(c.Addresses) == 0 { + errs = multierror.Append(errs, fmt.Errorf("config.configConnector.addresses is empty")) + } + if nil != c.RequestQueueSize && *c.RequestQueueSize < 0 { + errs = multierror.Append(errs, + fmt.Errorf("config.configConnector.requestQueueSize %v is invalid", c.RequestQueueSize)) + } + if *c.ConnectionIdleTimeout < DefaultMinTimingInterval { + errs = multierror.Append(errs, + fmt.Errorf("config.configConnector.connectionIdleTimeout %v"+ + " is less than minimal timing interval %v", + *c.ConnectionIdleTimeout, DefaultMinTimingInterval)) + } + if *c.ServerSwitchInterval <= *c.ConnectionIdleTimeout { + errs = multierror.Append(errs, + fmt.Errorf("config.configConnector.serverSwitchInterval %v"+ + " is less than or equal to config.configConnector.connectionIdleTimeout %v", + *c.ServerSwitchInterval, *c.ConnectionIdleTimeout)) + } + if len(c.ConnectorType) == 0 { + errs = multierror.Append(errs, fmt.Errorf("config.configConnector.connectorType is empty")) + } + return errs +} + +// SetDefault 设置ConfigConnector配置的默认值 +func (c *ConfigConnectorConfigImpl) SetDefault() { + if c.ConnectTimeout == nil { + c.ConnectTimeout = model.ToDurationPtr(DefaultServerConnectTimeout) + } + if c.MessageTimeout == nil { + c.MessageTimeout = model.ToDurationPtr(DefaultServerMessageTimeout) + } + if c.ConnectionIdleTimeout == nil { + c.ConnectionIdleTimeout = model.ToDurationPtr(DefaultServerConnectionIdleTimeout) + } + if c.ServerSwitchInterval == nil { + c.ServerSwitchInterval = model.ToDurationPtr(DefaultServerSwitchInterval) + } + if c.RequestQueueSize == nil { + c.RequestQueueSize = proto.Int32(int32(DefaultRequestQueueSize)) + } + if c.ReconnectInterval == nil { + c.ReconnectInterval = model.ToDurationPtr(DefaultReConnectInterval) + } + if len(c.Protocol) == 0 { + c.Protocol = DefaultConfigConnector + } + if len(c.Addresses) == 0 { + c.SetAddresses([]string{DefaultConfigConnectorAddresses}) + } + if len(c.ConnectorType) == 0 { + c.ConnectorType = DefaultConnectorType + } + c.Plugin.SetDefault(common.TypeConfigConnector) +} + +// Init 配置初始化 +func (c *ConfigConnectorConfigImpl) Init() { + c.Plugin = PluginConfigs{} + c.Plugin.Init(common.TypeConfigConnector) +} diff --git a/pkg/config/config_file.go b/pkg/config/config_file.go new file mode 100644 index 00000000..cce07ed3 --- /dev/null +++ b/pkg/config/config_file.go @@ -0,0 +1,118 @@ +/* + * Tencent is pleased to support the open source community by making polaris-go available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + */ + +package config + +import ( + "errors" + "fmt" + + "github.com/golang/protobuf/proto" + + "github.com/hashicorp/go-multierror" +) + +var ( + // DefaultConfigFileEnable 默认打开配置中心能力 + DefaultConfigFileEnable = true +) + +// 对接配置中心相关配置 +type ConfigFileConfigImpl struct { + ConfigConnectorConfig *ConfigConnectorConfigImpl `yaml:"configConnector" json:"configConnector"` + // 是否启动配置中心 + Enable *bool `yaml:"enable" json:"enable"` + PropertiesValueCacheSize *int32 `yaml:"propertiesValueCacheSize" json:"propertiesValueCacheSize"` + PropertiesValueExpireTime *int64 `yaml:"propertiesValueExpireTime" json:"propertiesValueExpireTime"` +} + +// GetConfigConnectorConfig config.configConnector前缀开头的所有配置项 +func (c *ConfigFileConfigImpl) GetConfigConnectorConfig() ConfigConnectorConfig { + return c.ConfigConnectorConfig +} + +// IsEnable config.enable +func (c *ConfigFileConfigImpl) IsEnable() bool { + return *c.Enable +} + +// SetEnable 设置是否开启配置中心功能 +func (c *ConfigFileConfigImpl) SetEnable(enable bool) { + c.Enable = &enable +} + +// GetPropertiesValueCacheSize config.propertiesValueCacheSize +func (c *ConfigFileConfigImpl) GetPropertiesValueCacheSize() int32 { + return *c.PropertiesValueCacheSize +} + +// SetPropertiesValueCacheSize 设置类型转化缓存的key数量 +func (c *ConfigFileConfigImpl) SetPropertiesValueCacheSize(propertiesValueCacheSize int32) { + c.PropertiesValueCacheSize = &propertiesValueCacheSize +} + +// GetPropertiesValueExpireTime config.propertiesValueExpireTime +func (c *ConfigFileConfigImpl) GetPropertiesValueExpireTime() int64 { + return *c.PropertiesValueExpireTime +} + +// SetPropertiesValueExpireTime 设置类型转化缓存的过期时间,默认为1分钟 +func (c *ConfigFileConfigImpl) SetPropertiesValueExpireTime(propertiesValueExpireTime int64) { + c.PropertiesValueExpireTime = &propertiesValueExpireTime +} + +// Verify 检验ConfigConnector配置 +func (c *ConfigFileConfigImpl) Verify() error { + if c == nil { + return errors.New("ConfigFileConfig is nil") + } + var errs error + if err := c.ConfigConnectorConfig.Verify(); err != nil { + errs = multierror.Append(errs, err) + } + if c.Enable == nil { + return fmt.Errorf("config.enable must not be nil") + } + if c.PropertiesValueCacheSize != nil && *c.PropertiesValueCacheSize < 0 { + errs = multierror.Append(errs, fmt.Errorf("config.propertiesValueCacheSize %v is invalid", c.PropertiesValueCacheSize)) + } + if c.PropertiesValueExpireTime != nil && *c.PropertiesValueExpireTime < 0 { + errs = multierror.Append(errs, fmt.Errorf("config.propertiesValueExpireTime %v is invalid", c.PropertiesValueExpireTime)) + } + return errs +} + +// SetDefault 设置ConfigConnector配置的默认值 +func (c *ConfigFileConfigImpl) SetDefault() { + c.ConfigConnectorConfig.SetDefault() + if c.Enable == nil { + c.Enable = &DefaultConfigFileEnable + } + if c.PropertiesValueCacheSize == nil { + c.PropertiesValueCacheSize = proto.Int32(int32(DefaultPropertiesValueCacheSize)) + } + if c.PropertiesValueCacheSize == nil { + c.PropertiesValueExpireTime = proto.Int64(int64(DefaultPropertiesValueCacheSize)) + } +} + +// Init 配置初始化 +func (c *ConfigFileConfigImpl) Init() { + c.ConfigConnectorConfig = &ConfigConnectorConfigImpl{} + c.ConfigConnectorConfig.Init() +} diff --git a/pkg/config/default.go b/pkg/config/default.go index aff89d9f..520f4381 100644 --- a/pkg/config/default.go +++ b/pkg/config/default.go @@ -129,6 +129,14 @@ const ( DefaultMapKVTupleSeparator = "|" // 默认实例地理位置提供者插件名称 DefaultLocationProvider = "" + // 默认类型转化缓存的key数量 + DefaultPropertiesValueCacheSize = 100 + // 默认类型转化缓存的过期时间,1分钟 + DefaultPropertiesValueExpireTime = 60000 + // 默认连接器类型 + DefaultConnectorType = "polaris" + // 默认连接器类型 + DefaultConfigConnectorAddresses = "127.0.0.1:8093" ) // 默认埋点server的端口,与上面的IP一一对应 @@ -201,6 +209,8 @@ const ( MaxRateLimitWindowSize = 20000 // 默认超时清理时延 DefaultRateLimitPurgeInterval = 1 * time.Minute + // 默认的注册中心连接器插件 + DefaultConfigConnector string = "polaris" ) // 默认的就近路由配置 @@ -236,6 +246,7 @@ type ClusterType string const ( BuiltinCluster ClusterType = "builtin" DiscoverCluster ClusterType = "discover" + ConfigCluster ClusterType = "config" HealthCheckCluster ClusterType = "healthCheck" MonitorCluster ClusterType = "monitor" ) @@ -246,6 +257,7 @@ const ( ServerDiscoverService = "polaris.discover" ServerHeartBeatService = "polaris.healthcheck" ServerMonitorService = "polaris.monitor" + ServerConfigService = "polaris.config" ) // server集群服务信息 @@ -310,6 +322,7 @@ var ( DefaultPolarisServicesRouterChain = []string{DefaultServiceRouterDstMeta} DefaultServerServiceToLoadBalancer = map[ClusterType]string{ DiscoverCluster: DefaultLoadBalancerWR, + ConfigCluster: DefaultLoadBalancerWR, HealthCheckCluster: DefaultLoadBalancerMaglev, MonitorCluster: DefaultLoadBalancerMaglev, } @@ -483,6 +496,8 @@ func (c *ConfigurationImpl) Init() { c.Consumer.Init() c.Provider = &ProviderConfigImpl{} c.Provider.Init() + c.Config = &ConfigFileConfigImpl{} + c.Config.Init() } // 检验configuration配置 @@ -501,6 +516,9 @@ func (c *ConfigurationImpl) Verify() error { if err = c.Provider.Verify(); err != nil { errs = multierror.Append(errs, err) } + if err = c.Config.Verify(); err != nil { + errs = multierror.Append(errs, err) + } return errs } @@ -509,6 +527,7 @@ func (c *ConfigurationImpl) SetDefault() { c.Global.SetDefault() c.Consumer.SetDefault() c.Provider.SetDefault() + c.Config.SetDefault() } // systemConfig init diff --git a/pkg/config/impl.go b/pkg/config/impl.go index 40232678..23aab309 100644 --- a/pkg/config/impl.go +++ b/pkg/config/impl.go @@ -30,9 +30,10 @@ import ( // ConfigurationImpl cl5全局配置 type ConfigurationImpl struct { - Global *GlobalConfigImpl `yaml:"global" json:"global"` - Consumer *ConsumerConfigImpl `yaml:"consumer" json:"consumer"` - Provider *ProviderConfigImpl `yaml:"provider" json:"provider"` + Global *GlobalConfigImpl `yaml:"global" json:"global"` + Consumer *ConsumerConfigImpl `yaml:"consumer" json:"consumer"` + Provider *ProviderConfigImpl `yaml:"provider" json:"provider"` + Config *ConfigFileConfigImpl `yaml:"config" json:"config"` } // GetGlobal cl5.global前缀开头的所有配置项 @@ -50,6 +51,11 @@ func (c *ConfigurationImpl) GetProvider() ProviderConfig { return c.Provider } +// GetConfig config前缀开头的所有配置项 +func (c *ConfigurationImpl) GetConfigFile() ConfigFileConfig { + return c.Config +} + // GlobalConfigImpl 全局配置 type GlobalConfigImpl struct { System *SystemConfigImpl `yaml:"system" json:"system"` diff --git a/pkg/flow/configuration/factory.go b/pkg/flow/configuration/factory.go new file mode 100644 index 00000000..c74c9748 --- /dev/null +++ b/pkg/flow/configuration/factory.go @@ -0,0 +1,78 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package configuration + +import ( + "github.com/polarismesh/polaris-go/pkg/flow/configuration/remote" + "github.com/polarismesh/polaris-go/pkg/flow/configuration/util" + "sync" + + "github.com/polarismesh/polaris-go/pkg/config" + "github.com/polarismesh/polaris-go/pkg/model" + "github.com/polarismesh/polaris-go/pkg/plugin/configconnector" +) + +type configFileFactory struct { + connector configconnector.ConfigConnector + configuration config.Configuration +} + +func newConfigFileFactory(connector configconnector.ConfigConnector, configuration config.Configuration) *configFileFactory { + return &configFileFactory{ + connector: connector, + configuration: configuration, + } +} + +func (c *configFileFactory) createConfigFile(configFileMetadata model.ConfigFileMetadata) (model.ConfigFile, error) { + configFileRemoteRepo, err := remote.NewConfigFileRepo(configFileMetadata, c.connector, c.configuration) + if err != nil { + return nil, err + } + + return newDefaultConfigFile(configFileMetadata, configFileRemoteRepo), err +} + +type configFileFactoryManager struct { + factories *sync.Map + connector configconnector.ConfigConnector + configuration config.Configuration +} + +func newConfigFileFactoryManager(connector configconnector.ConfigConnector, configuration config.Configuration) *configFileFactoryManager { + return &configFileFactoryManager{ + factories: new(sync.Map), + connector: connector, + configuration: configuration, + } +} + +func (c *configFileFactoryManager) getFactory(configFileMetadata model.ConfigFileMetadata) *configFileFactory { + cacheKey := util.GenConfigFileCacheKeyByMetadata(configFileMetadata) + + factoryObj, ok := c.factories.Load(cacheKey) + if ok { + return factoryObj.(*configFileFactory) + } + + factory := newConfigFileFactory(c.connector, c.configuration) + + c.factories.Store(cacheKey, factory) + + return factory +} diff --git a/pkg/flow/configuration/manager.go b/pkg/flow/configuration/manager.go new file mode 100644 index 00000000..36bd5cc5 --- /dev/null +++ b/pkg/flow/configuration/manager.go @@ -0,0 +1,77 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package configuration + +import ( + "github.com/polarismesh/polaris-go/pkg/flow/configuration/util" + "sync" + + "github.com/polarismesh/polaris-go/pkg/config" + "github.com/polarismesh/polaris-go/pkg/model" + "github.com/polarismesh/polaris-go/pkg/plugin/configconnector" +) + +type configFileManager struct { + configFileCache *sync.Map + lock *sync.Mutex + connector configconnector.ConfigConnector + configuration config.Configuration + configFileFactoryManager *configFileFactoryManager +} + +func newConfigFileManager(connector configconnector.ConfigConnector, + configuration config.Configuration) *configFileManager { + return &configFileManager{ + configFileCache: new(sync.Map), + lock: new(sync.Mutex), + connector: connector, + configuration: configuration, + configFileFactoryManager: newConfigFileFactoryManager(connector, configuration), + } +} + +func (c *configFileManager) getConfigFile(configFileMetadata model.ConfigFileMetadata) (model.ConfigFile, error) { + cacheKey := util.GenConfigFileCacheKeyByMetadata(configFileMetadata) + + configFileObj, ok := c.configFileCache.Load(cacheKey) + + if ok { + return configFileObj.(model.ConfigFile), nil + } + + c.lock.Lock() + defer c.lock.Unlock() + + //double check + configFileObj, ok = c.configFileCache.Load(cacheKey) + + if ok { + return configFileObj.(model.ConfigFile), nil + } + + factory := c.configFileFactoryManager.getFactory(configFileMetadata) + + configFile, err := factory.createConfigFile(configFileMetadata) + if err != nil { + return nil, err + } + + c.configFileCache.Store(cacheKey, configFile) + + return configFile, nil +} diff --git a/pkg/flow/configuration/model.go b/pkg/flow/configuration/model.go new file mode 100644 index 00000000..8818c88f --- /dev/null +++ b/pkg/flow/configuration/model.go @@ -0,0 +1,122 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package configuration + +import ( + "github.com/polarismesh/polaris-go/pkg/flow/configuration/remote" + "github.com/polarismesh/polaris-go/pkg/log" + "github.com/polarismesh/polaris-go/pkg/model" + "sync" +) + +type defaultConfigFile struct { + model.DefaultConfigFileMetadata + + remoteConfigFileRepo *remote.ConfigFileRepo + content string + + lock *sync.Mutex + changeListeners []func(event model.ConfigFileChangeEvent) + changeListenerChans []chan model.ConfigFileChangeEvent +} + +func newDefaultConfigFile(metadata model.ConfigFileMetadata, repo *remote.ConfigFileRepo) *defaultConfigFile { + configFile := &defaultConfigFile{ + remoteConfigFileRepo: repo, + content: repo.GetContent(), + lock: new(sync.Mutex), + } + configFile.Namespace = metadata.GetNamespace() + configFile.FileGroup = metadata.GetFileGroup() + configFile.FileName = metadata.GetFileName() + + repo.AddChangeListener(configFile.repoChangeListener) + + return configFile +} + +// GetContent 获取配置文件内容 +func (c *defaultConfigFile) GetContent() string { + if c.content == remote.NotExistedFileContent { + return "" + } + return c.content +} + +// HasContent 是否有配置内容 +func (c *defaultConfigFile) HasContent() bool { + return c.content != "" && c.content != remote.NotExistedFileContent +} + +func (c *defaultConfigFile) repoChangeListener(configFileMetadata model.ConfigFileMetadata, newContent string) error { + oldContent := c.content + + log.GetBaseLogger().Infof("[Config] update content. file = %+v, old content = %s, new content = %s", + configFileMetadata, oldContent, newContent) + + var changeType model.ChangeType + + if oldContent == remote.NotExistedFileContent && newContent != remote.NotExistedFileContent { + changeType = model.Added + } else if oldContent != remote.NotExistedFileContent && newContent == remote.NotExistedFileContent { + changeType = model.Deleted + // NotExistedFileContent 只用于内部删除标记,不应该透露给用户 + newContent = "" + } else if oldContent != newContent { + changeType = model.Modified + } else { + changeType = model.NotChanged + } + + event := model.ConfigFileChangeEvent{ + ConfigFileMetadata: configFileMetadata, + OldValue: c.content, + NewValue: newContent, + ChangeType: changeType, + } + c.content = newContent + + c.fireChangeEvent(event) + return nil +} + +// AddChangeListenerWithChannel 增加配置文件变更监听器 +func (c *defaultConfigFile) AddChangeListenerWithChannel(changeChan chan model.ConfigFileChangeEvent) { + c.lock.Lock() + defer c.lock.Unlock() + + c.changeListenerChans = append(c.changeListenerChans, changeChan) +} + +// AddChangeListener 增加配置文件变更监听器 +func (c *defaultConfigFile) AddChangeListener(cb model.OnConfigFileChange) { + c.lock.Lock() + defer c.lock.Unlock() + + c.changeListeners = append(c.changeListeners, cb) +} + +func (c *defaultConfigFile) fireChangeEvent(event model.ConfigFileChangeEvent) { + for _, listenerChan := range c.changeListenerChans { + listenerChan <- event + } + + for _, changeListener := range c.changeListeners { + changeListener(event) + } +} diff --git a/pkg/flow/configuration/remote/config.go b/pkg/flow/configuration/remote/config.go new file mode 100644 index 00000000..67a271ea --- /dev/null +++ b/pkg/flow/configuration/remote/config.go @@ -0,0 +1,267 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package remote + +import ( + "context" + "fmt" + "github.com/polarismesh/polaris-go/pkg/config" + "github.com/polarismesh/polaris-go/pkg/log" + "github.com/polarismesh/polaris-go/pkg/model" + v1 "github.com/polarismesh/polaris-go/pkg/model/pb/v1" + "github.com/polarismesh/polaris-go/pkg/plugin/configconnector" + "sync" + "time" +) + +const ( + delayMinTime = 1 // 1s + delayMaxTime = 120 // 120s +) + +var configFileRepos []*ConfigFileRepo +var startCheckVersionOnce = new(sync.Once) +var stopCheckVersionTask context.CancelFunc + +// ConfigFileRepo 服务端配置文件代理类,从服务端拉取配置并同步数据 +type ConfigFileRepo struct { + connector configconnector.ConfigConnector + configuration config.Configuration + + configFileMetadata model.ConfigFileMetadata + notifiedVersion uint64 // 长轮询通知的版本号 + remoteConfigFile *configconnector.ConfigFile // 从服务端获取的原始配置对象 + retryPolicy retryPolicy + listeners []ConfigFileRepoChangeListener +} + +// ConfigFileRepoChangeListener 远程配置文件发布监听器 +type ConfigFileRepoChangeListener func(configFileMetadata model.ConfigFileMetadata, newContent string) error + +// NewConfigFileRepo 创建远程配置文件 +func NewConfigFileRepo(metadata model.ConfigFileMetadata, + connector configconnector.ConfigConnector, + configuration config.Configuration) (*ConfigFileRepo, error) { + + repo := &ConfigFileRepo{ + connector: connector, + configuration: configuration, + configFileMetadata: metadata, + notifiedVersion: initVersion, + retryPolicy: retryPolicy{ + delayMinTime: delayMinTime, + delayMaxTime: delayMaxTime, + }, + } + + configFileRepos = append(configFileRepos, repo) + + //1. 同步从服务端拉取配置 + err := repo.pull() + if err != nil { + return nil, err + } + //2. 加到长轮询的池子里 + repo.addToLongPollingPoll() + //3. 启动定时比对版本号的任务 + startCheckVersionOnce.Do(func() { + ctx, cancel := context.WithCancel(context.Background()) + stopCheckVersionTask = cancel + go startCheckVersionTask(ctx) + }) + + return repo, nil +} + +func (r *ConfigFileRepo) GetContent() string { + if r.remoteConfigFile == nil { + return NotExistedFileContent + } + return r.remoteConfigFile.GetContent() +} + +func (r *ConfigFileRepo) getVersion() uint64 { + if r.remoteConfigFile == nil { + return initVersion + } + return r.remoteConfigFile.GetVersion() +} + +func (r *ConfigFileRepo) pull() error { + pullConfigFileReq := &configconnector.ConfigFile{ + Namespace: r.configFileMetadata.GetNamespace(), + FileGroup: r.configFileMetadata.GetFileGroup(), + FileName: r.configFileMetadata.GetFileName(), + Version: r.notifiedVersion, + } + + log.GetBaseLogger().Infof("[Config] start pull config file. config file = %+v, version = %d", + r.configFileMetadata, r.notifiedVersion) + + retryTimes := 0 + var err error + for retryTimes < 3 { + startTime := time.Now() + + response, err := r.connector.GetConfigFile(pullConfigFileReq) + + if err != nil { + log.GetBaseLogger().Errorf("[Config] failed to pull config file. retry times = %d", retryTimes, err) + r.retryPolicy.fail() + retryTimes++ + r.retryPolicy.delay() + continue + } + + // 拉取配置成功 + pulledConfigFile := response.GetConfigFile() + responseCode := response.GetCode() + + //打印请求信息 + pulledConfigFileVersion := int64(-1) + if pulledConfigFile != nil { + pulledConfigFileVersion = int64(pulledConfigFile.GetVersion()) + } + log.GetBaseLogger().Infof("[Config] pull config file finished. config file = %+v, code = %d, version = %d, duration = %d ms", + pulledConfigFile, responseCode, pulledConfigFileVersion, time.Now().UnixNano()/1e6-startTime.UnixNano()/1e6) + + //拉取成功 + if responseCode == v1.ExecuteSuccess { + //本地配置文件落后,更新内存缓存 + if r.remoteConfigFile == nil || pulledConfigFile.Version >= r.remoteConfigFile.Version { + r.remoteConfigFile = deepCloneConfigFile(pulledConfigFile) + r.fireChangeEvent(pulledConfigFile.GetContent()) + } + return nil + } + + //远端没有此配置文件 + if responseCode == v1.NotFoundResource { + log.GetBaseLogger().Warnf("[Config] config file not found, please check whether config file released. %+v", r.configFileMetadata) + + //删除配置文件 + if r.remoteConfigFile != nil { + r.remoteConfigFile = nil + r.fireChangeEvent(NotExistedFileContent) + } + + return nil + } + + //预期之外的状态码,重试 + log.GetBaseLogger().Errorf("[Config] pull response with unexpected code. retry times = %d, code = %d", retryTimes, responseCode) + err = fmt.Errorf("pull config file with unexpect code. %d", responseCode) + r.retryPolicy.fail() + retryTimes++ + r.retryPolicy.delay() + } + return err +} + +func deepCloneConfigFile(sourceConfigFile *configconnector.ConfigFile) *configconnector.ConfigFile { + return &configconnector.ConfigFile{ + Namespace: sourceConfigFile.GetNamespace(), + FileGroup: sourceConfigFile.GetFileGroup(), + FileName: sourceConfigFile.GetFileName(), + Content: sourceConfigFile.GetContent(), + Version: sourceConfigFile.GetVersion(), + Md5: sourceConfigFile.GetMd5(), + } +} + +func (r *ConfigFileRepo) addToLongPollingPoll() { + //从服务端找不到配置文件或者拉取异常 + if r.remoteConfigFile == nil { + r.remoteConfigFile = &configconnector.ConfigFile{ + Namespace: r.configFileMetadata.GetNamespace(), + FileGroup: r.configFileMetadata.GetFileGroup(), + FileName: r.configFileMetadata.GetFileName(), + Version: initVersion, + } + } + + addConfigFileToLongPollingPool(r) +} + +func StopCheckVersionTask() { + if stopCheckVersionTask != nil { + stopCheckVersionTask() + } +} + +func startCheckVersionTask(ctx context.Context) { + t := time.NewTimer(time.Minute) + defer t.Stop() + for { + select { + case <-ctx.Done(): + break + case <-t.C: + for _, repo := range configFileRepos { + //没有通知版本号 + if repo.notifiedVersion == initVersion { + continue + } + //从服务端获取的配置文件版本号落后于通知的版本号,重新拉取配置 + if repo.remoteConfigFile == nil || repo.notifiedVersion > repo.remoteConfigFile.GetVersion() { + if repo.remoteConfigFile == nil { + log.GetBaseLogger().Warnf("[Config] client does not pull the configuration, it will be pulled again."+ + "file = %+v, notified version = %d", + repo.configFileMetadata, repo.notifiedVersion) + } else { + log.GetBaseLogger().Warnf("[Config] notified version greater than pulled version, will pull config file again. "+ + "file = %+v, notified version = %d, pulled version = %d", + repo.configFileMetadata, repo.notifiedVersion, repo.remoteConfigFile.GetVersion()) + } + + err := repo.pull() + if err != nil { + log.GetBaseLogger().Errorf("[Config] pull config file error by check version task.", err) + } + } + } + } + } +} + +func (r *ConfigFileRepo) onLongPollingNotified(newVersion uint64) { + if r.remoteConfigFile != nil && r.remoteConfigFile.GetVersion() >= newVersion { + return + } + + r.notifiedVersion = newVersion + + err := r.pull() + if err != nil { + log.GetBaseLogger().Errorf("[Config] pull config file error by check version task.", err) + } +} + +func (r *ConfigFileRepo) AddChangeListener(listener ConfigFileRepoChangeListener) { + r.listeners = append(r.listeners, listener) +} + +func (r *ConfigFileRepo) fireChangeEvent(newContent string) { + for _, listener := range r.listeners { + err := listener(r.configFileMetadata, newContent) + if err != nil { + log.GetBaseLogger().Errorf("[Config] invoke config file repo change listener failed. config file = %+v", + r.configFileMetadata, err) + } + } +} diff --git a/pkg/flow/configuration/remote/polling.go b/pkg/flow/configuration/remote/polling.go new file mode 100644 index 00000000..c0babe9a --- /dev/null +++ b/pkg/flow/configuration/remote/polling.go @@ -0,0 +1,185 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package remote + +import ( + "github.com/polarismesh/polaris-go/pkg/flow/configuration/util" + "github.com/polarismesh/polaris-go/pkg/log" + "github.com/polarismesh/polaris-go/pkg/model" + v1 "github.com/polarismesh/polaris-go/pkg/model/pb/v1" + "github.com/polarismesh/polaris-go/pkg/plugin/configconnector" + "sync" + "time" +) + +var ( + configConnector configconnector.ConfigConnector + + configFilePool = new(sync.Map) + notifiedVersion = new(sync.Map) + startLongPollingTaskOnce = new(sync.Once) + + pollingRetryPolicy = retryPolicy{ + delayMinTime: delayMinTime, + delayMaxTime: delayMaxTime, + } + + stopPolling bool +) + +// InitLongPollingService 初始化长轮询服务 +func InitLongPollingService(connector configconnector.ConfigConnector) { + configConnector = connector + stopPolling = false +} + +func addConfigFileToLongPollingPool(remoteConfigFileRepo *ConfigFileRepo) { + configFileMetadata := remoteConfigFileRepo.configFileMetadata + version := remoteConfigFileRepo.getVersion() + + log.GetBaseLogger().Infof("[Config] add long polling config file. file = %+v, version = %d", configFileMetadata, version) + + cacheKey := util.GenConfigFileCacheKeyByMetadata(configFileMetadata) + configFilePool.Store(cacheKey, remoteConfigFileRepo) + notifiedVersion.Store(cacheKey, version) + + // 开启长轮询任务 + startLongPollingTaskOnce.Do(func() { + go startLongPollingTask() + }) +} + +func StopLongPollingTask() { + stopPolling = true +} + +func startLongPollingTask() { + time.Sleep(5 * time.Second) + + doLongPolling() +} + +func doLongPolling() { + for { + if stopPolling { + return + } + + //1. 生成订阅配置列表 + watchConfigFiles := assembleWatchConfigFiles() + + log.GetBaseLogger().Infof("[Config] do long polling. config file size = %d, delay time = %d", + len(watchConfigFiles), pollingRetryPolicy.currentDelayTime) + + //2. 调用 connector watch接口 + response, err := configConnector.WatchConfigFiles(watchConfigFiles) + if err != nil { + log.GetBaseLogger().Errorf("[Config] long polling failed.", err) + pollingRetryPolicy.fail() + pollingRetryPolicy.delay() + continue + } + + responseCode := response.GetCode() + + //3.1 接口调用成功,判断版本号是否有更新,如果有更新则通知 remoteRepo 拉取最新,并触发回调事件 + if responseCode == v1.ExecuteSuccess && response.GetConfigFile() != nil { + pollingRetryPolicy.success() + + changedConfigFile := response.GetConfigFile() + configFileMetadata := &model.DefaultConfigFileMetadata{ + Namespace: changedConfigFile.GetNamespace(), + FileGroup: changedConfigFile.GetFileGroup(), + FileName: changedConfigFile.GetFileName(), + } + + cacheKey := util.GenConfigFileCacheKeyByMetadata(configFileMetadata) + + newNotifiedVersion := changedConfigFile.GetVersion() + oldNotifiedVersion := getConfigFileNotifiedVersion(cacheKey) + + maxVersion := oldNotifiedVersion + if newNotifiedVersion > oldNotifiedVersion { + maxVersion = newNotifiedVersion + } + + //更新版本号 + notifiedVersion.Store(cacheKey, maxVersion) + + log.GetBaseLogger().Infof("[Config] received change event by long polling. file = %+v, new version = %d, old version = %d", + changedConfigFile, newNotifiedVersion, oldNotifiedVersion) + + //通知 remoteConfigFileRepo 拉取最新配置 + remoteConfigFileRepo := getRemoteConfigFileRepo(cacheKey) + remoteConfigFileRepo.onLongPollingNotified(maxVersion) + + continue + } + + //3.2 如果没有变更,打印日志 + if responseCode == v1.DataNoChange { + pollingRetryPolicy.success() + log.GetBaseLogger().Infof("[Config] long polling result: data no change") + continue + } + + //3.3 预期之外的状态,退避重试 + log.GetBaseLogger().Errorf("[Config] long polling result with unexpect code. code = {}", responseCode) + pollingRetryPolicy.fail() + pollingRetryPolicy.delay() + } +} + +func assembleWatchConfigFiles() []*configconnector.ConfigFile { + var watchConfigFiles []*configconnector.ConfigFile + + configFilePool.Range(func(key, value interface{}) bool { + cacheKey := key.(string) + configFileMetadata := util.ExtractConfigFileMetadataFromKey(cacheKey) + + watchConfigFiles = append(watchConfigFiles, &configconnector.ConfigFile{ + Namespace: configFileMetadata.GetNamespace(), + FileGroup: configFileMetadata.GetFileGroup(), + FileName: configFileMetadata.GetFileName(), + Version: getConfigFileNotifiedVersion(cacheKey), + }) + + return true + }) + + return watchConfigFiles +} + +func getConfigFileNotifiedVersion(cacheKey string) uint64 { + var version uint64 + versionObj, ok := notifiedVersion.Load(cacheKey) + if !ok { + version = initVersion + } else { + version = versionObj.(uint64) + } + return version +} + +func getRemoteConfigFileRepo(cacheKey string) *ConfigFileRepo { + configFile, ok := configFilePool.Load(cacheKey) + if !ok { + return nil + } + return configFile.(*ConfigFileRepo) +} diff --git a/pkg/flow/configuration/remote/retry_policy.go b/pkg/flow/configuration/remote/retry_policy.go new file mode 100644 index 00000000..4ac4df49 --- /dev/null +++ b/pkg/flow/configuration/remote/retry_policy.go @@ -0,0 +1,52 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package remote + +import ( + "time" +) + +type retryPolicy struct { + delayMinTime time.Duration + delayMaxTime time.Duration + currentDelayTime time.Duration +} + +func (r *retryPolicy) success() { + r.currentDelayTime = 0 +} + +func (r *retryPolicy) fail() { + delayTime := r.currentDelayTime + + if delayTime == 0 { + delayTime = r.delayMinTime + } else { + if r.currentDelayTime<<1 < r.delayMaxTime { + delayTime = r.currentDelayTime << 1 + } else { + delayTime = r.delayMaxTime + } + } + + r.currentDelayTime = delayTime +} + +func (r *retryPolicy) delay() { + time.Sleep(r.currentDelayTime * time.Second) +} diff --git a/pkg/flow/configuration/remote/type.go b/pkg/flow/configuration/remote/type.go new file mode 100644 index 00000000..eaa70acf --- /dev/null +++ b/pkg/flow/configuration/remote/type.go @@ -0,0 +1,24 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package remote + +const ( + initVersion = 0 + + NotExistedFileContent = string("@@not_existed@@") +) diff --git a/pkg/flow/configuration/service.go b/pkg/flow/configuration/service.go new file mode 100644 index 00000000..d77cf0ce --- /dev/null +++ b/pkg/flow/configuration/service.go @@ -0,0 +1,68 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package configuration + +import ( + "sync" + + "github.com/polarismesh/polaris-go/pkg/config" + "github.com/polarismesh/polaris-go/pkg/flow/configuration/remote" + "github.com/polarismesh/polaris-go/pkg/model" + "github.com/polarismesh/polaris-go/pkg/plugin/configconnector" +) + +// ConfigFileService 配置中心核心服务门面类 +type ConfigFileService struct { + connector configconnector.ConfigConnector + configuration config.Configuration + configFileManager *configFileManager +} + +var configFileService *ConfigFileService +var once = new(sync.Once) + +// NewConfigFileService 创建配置中心服务 +func NewConfigFileService(connector configconnector.ConfigConnector, + configuration config.Configuration) *ConfigFileService { + + once.Do(func() { + configFileService = &ConfigFileService{ + connector: connector, + configuration: configuration, + configFileManager: newConfigFileManager(connector, configuration), + } + + remote.InitLongPollingService(connector) + }) + return configFileService +} + +// GetConfigFile 获取配置文件 +func (c *ConfigFileService) GetConfigFile(namespace, fileGroup, fileName string) (model.ConfigFile, error) { + return c.configFileManager.getConfigFile(&model.DefaultConfigFileMetadata{ + Namespace: namespace, + FileGroup: fileGroup, + FileName: fileName, + }) +} + +// Destroy 销毁服务 +func (c *ConfigFileService) Destroy() { + remote.StopLongPollingTask() + remote.StopCheckVersionTask() +} diff --git a/pkg/flow/configuration/util/cache_key.go b/pkg/flow/configuration/util/cache_key.go new file mode 100644 index 00000000..b75307cd --- /dev/null +++ b/pkg/flow/configuration/util/cache_key.go @@ -0,0 +1,47 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package util + +import ( + "github.com/polarismesh/polaris-go/pkg/model" + "strings" +) + +const ( + separator = "+" +) + +// GenConfigFileCacheKey 生成配置文件缓存的 Key +func GenConfigFileCacheKey(namespace, fileGroup, fileName string) string { + return namespace + separator + fileGroup + separator + fileName +} + +// GenConfigFileCacheKeyByMetadata 生成配置文件缓存的 Key +func GenConfigFileCacheKeyByMetadata(configFileMetadata model.ConfigFileMetadata) string { + return GenConfigFileCacheKey(configFileMetadata.GetNamespace(), configFileMetadata.GetFileGroup(), configFileMetadata.GetFileName()) +} + +// ExtractConfigFileMetadataFromKey 从配置文件 Key 解析出配置文件元数据 +func ExtractConfigFileMetadataFromKey(key string) model.ConfigFileMetadata { + info := strings.Split(key, separator) + return &model.DefaultConfigFileMetadata{ + Namespace: info[0], + FileGroup: info[1], + FileName: info[2], + } +} diff --git a/pkg/flow/data/util.go b/pkg/flow/data/util.go index f2aa42db..d9b64f65 100644 --- a/pkg/flow/data/util.go +++ b/pkg/flow/data/util.go @@ -21,6 +21,8 @@ import ( "fmt" "time" + "github.com/polarismesh/polaris-go/pkg/plugin/configconnector" + "github.com/polarismesh/polaris-go/pkg/clock" "github.com/polarismesh/polaris-go/pkg/config" "github.com/polarismesh/polaris-go/pkg/log" @@ -49,6 +51,18 @@ func GetServerConnector( return targetPlugin.(serverconnector.ServerConnector), nil } +// GetConfigConnector 加载配置中心连接器插件 +func GetConfigConnector( + cfg config.Configuration, supplier plugin.Supplier) (configconnector.ConfigConnector, error) { + // 加载配置中心连接器 + protocol := cfg.GetConfigFile().GetConfigConnectorConfig().GetProtocol() + targetPlugin, err := supplier.GetPlugin(common.TypeConfigConnector, protocol) + if err != nil { + return nil, err + } + return targetPlugin.(configconnector.ConfigConnector), nil +} + // GetRegistry 加载本地缓存插件 func GetRegistry(cfg config.Configuration, supplier plugin.Supplier) (localregistry.LocalRegistry, error) { localCacheType := cfg.GetConsumer().GetLocalCache().GetType() diff --git a/pkg/flow/impl.go b/pkg/flow/impl.go index 21cb9073..d62218be 100644 --- a/pkg/flow/impl.go +++ b/pkg/flow/impl.go @@ -19,6 +19,8 @@ package flow import ( "github.com/modern-go/reflect2" + "github.com/polarismesh/polaris-go/pkg/flow/configuration" + "github.com/polarismesh/polaris-go/pkg/plugin/configconnector" "github.com/polarismesh/polaris-go/pkg/config" "github.com/polarismesh/polaris-go/pkg/flow/cbcheck" @@ -43,6 +45,8 @@ import ( type Engine struct { // 服务端连接器 connector serverconnector.ServerConnector + // 服务端连接器 + configConnector configconnector.ConfigConnector // 服务本地缓存 registry localregistry.LocalRegistry // 全局配置 @@ -73,6 +77,8 @@ type Engine struct { circuitBreakerChain []circuitbreaker.InstanceCircuitBreaker // 修改消息订阅插件链 subscribe subscribe.Subscribe + // 配置中心门面类 + configFileService *configuration.ConfigFileService } // InitFlowEngine 初始化flowEngine实例 @@ -100,6 +106,15 @@ func InitFlowEngine(flowEngine *Engine, initContext plugin.InitContext) error { return err } } + + // 加载配置中心连接器 + if len(cfg.GetConfigFile().GetConfigConnectorConfig().GetAddresses()) > 0 { + flowEngine.configConnector, err = data.GetConfigConnector(cfg, plugins) + if err != nil { + return err + } + } + // 加载服务路由链插件 err = flowEngine.LoadFlowRouteChain() if err != nil { @@ -145,6 +160,12 @@ func InitFlowEngine(flowEngine *Engine, initContext plugin.InitContext) error { } initContext.Plugins.RegisterEventSubscriber(common.OnServiceUpdated, callbackHandler) globalCtx.SetValue(model.ContextKeyEngine, flowEngine) + + //初始化配置中心服务 + if cfg.GetConfigFile().IsEnable() { + flowEngine.configFileService = configuration.NewConfigFileService(flowEngine.configConnector, flowEngine.configuration) + } + return nil } @@ -297,6 +318,9 @@ func (e *Engine) Destroy() error { if e.flowQuotaAssistant != nil { e.flowQuotaAssistant.Destroy() } + if e.configFileService != nil { + e.configFileService.Destroy() + } return nil } diff --git a/pkg/flow/sync_flow.go b/pkg/flow/sync_flow.go index d2e1ba05..12f7a472 100644 --- a/pkg/flow/sync_flow.go +++ b/pkg/flow/sync_flow.go @@ -632,3 +632,8 @@ func (e *Engine) realInitCalleeService(req *model.InitCalleeServiceRequest, reportReq.CallResult.SetSuccess(costTime) return nil } + +// SyncGetConfigFile 同步获取配置文件 +func (e *Engine) SyncGetConfigFile(namespace, fileGroup, fileName string) (model.ConfigFile, error) { + return e.configFileService.GetConfigFile(namespace, fileGroup, fileName) +} diff --git a/pkg/model/config.go b/pkg/model/config.go new file mode 100644 index 00000000..5c80cade --- /dev/null +++ b/pkg/model/config.go @@ -0,0 +1,93 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package model + +// ChangeType 配置文件变更类型 +type ChangeType int + +const ( + // Modified 修改类型 + Modified ChangeType = iota + // Deleted 删除类型 + Deleted + // Added 新增类型 + Added + // NotChanged 没有变更 + NotChanged +) + +// OnConfigFileChange 配置文件变更回调监听器 +type OnConfigFileChange func(event ConfigFileChangeEvent) + +// ConfigFileChangeEvent 配置文件变更事件 +type ConfigFileChangeEvent struct { + ConfigFileMetadata ConfigFileMetadata + + // OldValue 变更之前的值 + OldValue string + // NewValue 变更之后的值 + NewValue string + // ChangeType 变更类型 + ChangeType ChangeType +} + +// ConfigFileMetadata 配置文件元信息 +type ConfigFileMetadata interface { + // GetNamespace 获取 Namespace 信息 + GetNamespace() string + // GetFileGroup 获取配置文件组 + GetFileGroup() string + // GetFileName 获取配置文件值 + GetFileName() string +} + +// ConfigFile 文本类型配置文件对象 +type ConfigFile interface { + ConfigFileMetadata + + // GetContent 获取配置文件内容 + GetContent() string + // HasContent 是否有配置内容 + HasContent() bool + // AddChangeListenerWithChannel 增加配置文件变更监听器 + AddChangeListenerWithChannel(chan ConfigFileChangeEvent) + // AddChangeListener 增加配置文件变更监听器 + AddChangeListener(cb OnConfigFileChange) +} + +// DefaultConfigFileMetadata 默认 ConfigFileMetadata 实现类 +type DefaultConfigFileMetadata struct { + Namespace string + FileGroup string + FileName string +} + +// GetNamespace 获取 Namespace +func (m *DefaultConfigFileMetadata) GetNamespace() string { + return m.Namespace +} + +// GetFileGroup 获取配置文件组 +func (m *DefaultConfigFileMetadata) GetFileGroup() string { + return m.FileGroup +} + +// GetFileName 获取配置文件值 +func (m *DefaultConfigFileMetadata) GetFileName() string { + return m.FileName +} diff --git a/pkg/model/engine.go b/pkg/model/engine.go index e8b2494d..28864a0a 100644 --- a/pkg/model/engine.go +++ b/pkg/model/engine.go @@ -117,4 +117,6 @@ type Engine interface { GetContext() ValueContext // 所需的被调初始化 InitCalleeService(req *InitCalleeServiceRequest) error + // SyncGetConfigFile 同步获取配置文件 + SyncGetConfigFile(namespace, fileGroup, fileName string) (ConfigFile, error) } diff --git a/pkg/model/pb/v1/config_file.pb.go b/pkg/model/pb/v1/config_file.pb.go new file mode 100644 index 00000000..3ff2df4e --- /dev/null +++ b/pkg/model/pb/v1/config_file.pb.go @@ -0,0 +1,1258 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v3.17.3 +// source: config_file.proto + +package v1 + +import ( + reflect "reflect" + sync "sync" + + wrappers "github.com/golang/protobuf/ptypes/wrappers" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ConfigFileGroup struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *wrappers.UInt64Value `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name *wrappers.StringValue `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Namespace *wrappers.StringValue `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` + Comment *wrappers.StringValue `protobuf:"bytes,4,opt,name=comment,proto3" json:"comment,omitempty"` + CreateTime *wrappers.StringValue `protobuf:"bytes,5,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` + CreateBy *wrappers.StringValue `protobuf:"bytes,6,opt,name=create_by,json=createBy,proto3" json:"create_by,omitempty"` + ModifyTime *wrappers.StringValue `protobuf:"bytes,7,opt,name=modify_time,json=modifyTime,proto3" json:"modify_time,omitempty"` + ModifyBy *wrappers.StringValue `protobuf:"bytes,8,opt,name=modify_by,json=modifyBy,proto3" json:"modify_by,omitempty"` + FileCount *wrappers.UInt64Value `protobuf:"bytes,9,opt,name=fileCount,proto3" json:"fileCount,omitempty"` +} + +func (x *ConfigFileGroup) Reset() { + *x = ConfigFileGroup{} + if protoimpl.UnsafeEnabled { + mi := &file_config_file_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfigFileGroup) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigFileGroup) ProtoMessage() {} + +func (x *ConfigFileGroup) ProtoReflect() protoreflect.Message { + mi := &file_config_file_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigFileGroup.ProtoReflect.Descriptor instead. +func (*ConfigFileGroup) Descriptor() ([]byte, []int) { + return file_config_file_proto_rawDescGZIP(), []int{0} +} + +func (x *ConfigFileGroup) GetId() *wrappers.UInt64Value { + if x != nil { + return x.Id + } + return nil +} + +func (x *ConfigFileGroup) GetName() *wrappers.StringValue { + if x != nil { + return x.Name + } + return nil +} + +func (x *ConfigFileGroup) GetNamespace() *wrappers.StringValue { + if x != nil { + return x.Namespace + } + return nil +} + +func (x *ConfigFileGroup) GetComment() *wrappers.StringValue { + if x != nil { + return x.Comment + } + return nil +} + +func (x *ConfigFileGroup) GetCreateTime() *wrappers.StringValue { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *ConfigFileGroup) GetCreateBy() *wrappers.StringValue { + if x != nil { + return x.CreateBy + } + return nil +} + +func (x *ConfigFileGroup) GetModifyTime() *wrappers.StringValue { + if x != nil { + return x.ModifyTime + } + return nil +} + +func (x *ConfigFileGroup) GetModifyBy() *wrappers.StringValue { + if x != nil { + return x.ModifyBy + } + return nil +} + +func (x *ConfigFileGroup) GetFileCount() *wrappers.UInt64Value { + if x != nil { + return x.FileCount + } + return nil +} + +type ConfigFile struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *wrappers.UInt64Value `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name *wrappers.StringValue `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Namespace *wrappers.StringValue `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` + Group *wrappers.StringValue `protobuf:"bytes,4,opt,name=group,proto3" json:"group,omitempty"` + Content *wrappers.StringValue `protobuf:"bytes,5,opt,name=content,proto3" json:"content,omitempty"` + Format *wrappers.StringValue `protobuf:"bytes,6,opt,name=format,proto3" json:"format,omitempty"` + Comment *wrappers.StringValue `protobuf:"bytes,7,opt,name=comment,proto3" json:"comment,omitempty"` + Status *wrappers.StringValue `protobuf:"bytes,8,opt,name=status,proto3" json:"status,omitempty"` + Tags []*ConfigFileTag `protobuf:"bytes,9,rep,name=tags,proto3" json:"tags,omitempty"` + CreateTime *wrappers.StringValue `protobuf:"bytes,10,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` + CreateBy *wrappers.StringValue `protobuf:"bytes,11,opt,name=create_by,json=createBy,proto3" json:"create_by,omitempty"` + ModifyTime *wrappers.StringValue `protobuf:"bytes,12,opt,name=modify_time,json=modifyTime,proto3" json:"modify_time,omitempty"` + ModifyBy *wrappers.StringValue `protobuf:"bytes,13,opt,name=modify_by,json=modifyBy,proto3" json:"modify_by,omitempty"` + ReleaseTime *wrappers.StringValue `protobuf:"bytes,14,opt,name=release_time,json=releaseTime,proto3" json:"release_time,omitempty"` + ReleaseBy *wrappers.StringValue `protobuf:"bytes,15,opt,name=release_by,json=releaseBy,proto3" json:"release_by,omitempty"` +} + +func (x *ConfigFile) Reset() { + *x = ConfigFile{} + if protoimpl.UnsafeEnabled { + mi := &file_config_file_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfigFile) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigFile) ProtoMessage() {} + +func (x *ConfigFile) ProtoReflect() protoreflect.Message { + mi := &file_config_file_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigFile.ProtoReflect.Descriptor instead. +func (*ConfigFile) Descriptor() ([]byte, []int) { + return file_config_file_proto_rawDescGZIP(), []int{1} +} + +func (x *ConfigFile) GetId() *wrappers.UInt64Value { + if x != nil { + return x.Id + } + return nil +} + +func (x *ConfigFile) GetName() *wrappers.StringValue { + if x != nil { + return x.Name + } + return nil +} + +func (x *ConfigFile) GetNamespace() *wrappers.StringValue { + if x != nil { + return x.Namespace + } + return nil +} + +func (x *ConfigFile) GetGroup() *wrappers.StringValue { + if x != nil { + return x.Group + } + return nil +} + +func (x *ConfigFile) GetContent() *wrappers.StringValue { + if x != nil { + return x.Content + } + return nil +} + +func (x *ConfigFile) GetFormat() *wrappers.StringValue { + if x != nil { + return x.Format + } + return nil +} + +func (x *ConfigFile) GetComment() *wrappers.StringValue { + if x != nil { + return x.Comment + } + return nil +} + +func (x *ConfigFile) GetStatus() *wrappers.StringValue { + if x != nil { + return x.Status + } + return nil +} + +func (x *ConfigFile) GetTags() []*ConfigFileTag { + if x != nil { + return x.Tags + } + return nil +} + +func (x *ConfigFile) GetCreateTime() *wrappers.StringValue { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *ConfigFile) GetCreateBy() *wrappers.StringValue { + if x != nil { + return x.CreateBy + } + return nil +} + +func (x *ConfigFile) GetModifyTime() *wrappers.StringValue { + if x != nil { + return x.ModifyTime + } + return nil +} + +func (x *ConfigFile) GetModifyBy() *wrappers.StringValue { + if x != nil { + return x.ModifyBy + } + return nil +} + +func (x *ConfigFile) GetReleaseTime() *wrappers.StringValue { + if x != nil { + return x.ReleaseTime + } + return nil +} + +func (x *ConfigFile) GetReleaseBy() *wrappers.StringValue { + if x != nil { + return x.ReleaseBy + } + return nil +} + +type ConfigFileTag struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Key *wrappers.StringValue `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` + Value *wrappers.StringValue `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` +} + +func (x *ConfigFileTag) Reset() { + *x = ConfigFileTag{} + if protoimpl.UnsafeEnabled { + mi := &file_config_file_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfigFileTag) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigFileTag) ProtoMessage() {} + +func (x *ConfigFileTag) ProtoReflect() protoreflect.Message { + mi := &file_config_file_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigFileTag.ProtoReflect.Descriptor instead. +func (*ConfigFileTag) Descriptor() ([]byte, []int) { + return file_config_file_proto_rawDescGZIP(), []int{2} +} + +func (x *ConfigFileTag) GetKey() *wrappers.StringValue { + if x != nil { + return x.Key + } + return nil +} + +func (x *ConfigFileTag) GetValue() *wrappers.StringValue { + if x != nil { + return x.Value + } + return nil +} + +type ConfigFileRelease struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *wrappers.UInt64Value `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name *wrappers.StringValue `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Namespace *wrappers.StringValue `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` + Group *wrappers.StringValue `protobuf:"bytes,4,opt,name=group,proto3" json:"group,omitempty"` + FileName *wrappers.StringValue `protobuf:"bytes,5,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` + Content *wrappers.StringValue `protobuf:"bytes,6,opt,name=content,proto3" json:"content,omitempty"` + Comment *wrappers.StringValue `protobuf:"bytes,7,opt,name=comment,proto3" json:"comment,omitempty"` + Md5 *wrappers.StringValue `protobuf:"bytes,8,opt,name=md5,proto3" json:"md5,omitempty"` + Version *wrappers.UInt64Value `protobuf:"bytes,9,opt,name=version,proto3" json:"version,omitempty"` + CreateTime *wrappers.StringValue `protobuf:"bytes,10,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` + CreateBy *wrappers.StringValue `protobuf:"bytes,11,opt,name=create_by,json=createBy,proto3" json:"create_by,omitempty"` + ModifyTime *wrappers.StringValue `protobuf:"bytes,12,opt,name=modify_time,json=modifyTime,proto3" json:"modify_time,omitempty"` + ModifyBy *wrappers.StringValue `protobuf:"bytes,13,opt,name=modify_by,json=modifyBy,proto3" json:"modify_by,omitempty"` +} + +func (x *ConfigFileRelease) Reset() { + *x = ConfigFileRelease{} + if protoimpl.UnsafeEnabled { + mi := &file_config_file_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfigFileRelease) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigFileRelease) ProtoMessage() {} + +func (x *ConfigFileRelease) ProtoReflect() protoreflect.Message { + mi := &file_config_file_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigFileRelease.ProtoReflect.Descriptor instead. +func (*ConfigFileRelease) Descriptor() ([]byte, []int) { + return file_config_file_proto_rawDescGZIP(), []int{3} +} + +func (x *ConfigFileRelease) GetId() *wrappers.UInt64Value { + if x != nil { + return x.Id + } + return nil +} + +func (x *ConfigFileRelease) GetName() *wrappers.StringValue { + if x != nil { + return x.Name + } + return nil +} + +func (x *ConfigFileRelease) GetNamespace() *wrappers.StringValue { + if x != nil { + return x.Namespace + } + return nil +} + +func (x *ConfigFileRelease) GetGroup() *wrappers.StringValue { + if x != nil { + return x.Group + } + return nil +} + +func (x *ConfigFileRelease) GetFileName() *wrappers.StringValue { + if x != nil { + return x.FileName + } + return nil +} + +func (x *ConfigFileRelease) GetContent() *wrappers.StringValue { + if x != nil { + return x.Content + } + return nil +} + +func (x *ConfigFileRelease) GetComment() *wrappers.StringValue { + if x != nil { + return x.Comment + } + return nil +} + +func (x *ConfigFileRelease) GetMd5() *wrappers.StringValue { + if x != nil { + return x.Md5 + } + return nil +} + +func (x *ConfigFileRelease) GetVersion() *wrappers.UInt64Value { + if x != nil { + return x.Version + } + return nil +} + +func (x *ConfigFileRelease) GetCreateTime() *wrappers.StringValue { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *ConfigFileRelease) GetCreateBy() *wrappers.StringValue { + if x != nil { + return x.CreateBy + } + return nil +} + +func (x *ConfigFileRelease) GetModifyTime() *wrappers.StringValue { + if x != nil { + return x.ModifyTime + } + return nil +} + +func (x *ConfigFileRelease) GetModifyBy() *wrappers.StringValue { + if x != nil { + return x.ModifyBy + } + return nil +} + +type ConfigFileReleaseHistory struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id *wrappers.UInt64Value `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + Name *wrappers.StringValue `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Namespace *wrappers.StringValue `protobuf:"bytes,3,opt,name=namespace,proto3" json:"namespace,omitempty"` + Group *wrappers.StringValue `protobuf:"bytes,4,opt,name=group,proto3" json:"group,omitempty"` + FileName *wrappers.StringValue `protobuf:"bytes,5,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` + Content *wrappers.StringValue `protobuf:"bytes,6,opt,name=content,proto3" json:"content,omitempty"` + Format *wrappers.StringValue `protobuf:"bytes,7,opt,name=format,proto3" json:"format,omitempty"` + Comment *wrappers.StringValue `protobuf:"bytes,8,opt,name=comment,proto3" json:"comment,omitempty"` + Md5 *wrappers.StringValue `protobuf:"bytes,9,opt,name=md5,proto3" json:"md5,omitempty"` + Type *wrappers.StringValue `protobuf:"bytes,10,opt,name=type,proto3" json:"type,omitempty"` + Status *wrappers.StringValue `protobuf:"bytes,11,opt,name=status,proto3" json:"status,omitempty"` + Tags []*ConfigFileTag `protobuf:"bytes,12,rep,name=tags,proto3" json:"tags,omitempty"` + CreateTime *wrappers.StringValue `protobuf:"bytes,13,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` + CreateBy *wrappers.StringValue `protobuf:"bytes,14,opt,name=create_by,json=createBy,proto3" json:"create_by,omitempty"` + ModifyTime *wrappers.StringValue `protobuf:"bytes,15,opt,name=modify_time,json=modifyTime,proto3" json:"modify_time,omitempty"` + ModifyBy *wrappers.StringValue `protobuf:"bytes,16,opt,name=modify_by,json=modifyBy,proto3" json:"modify_by,omitempty"` +} + +func (x *ConfigFileReleaseHistory) Reset() { + *x = ConfigFileReleaseHistory{} + if protoimpl.UnsafeEnabled { + mi := &file_config_file_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfigFileReleaseHistory) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigFileReleaseHistory) ProtoMessage() {} + +func (x *ConfigFileReleaseHistory) ProtoReflect() protoreflect.Message { + mi := &file_config_file_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigFileReleaseHistory.ProtoReflect.Descriptor instead. +func (*ConfigFileReleaseHistory) Descriptor() ([]byte, []int) { + return file_config_file_proto_rawDescGZIP(), []int{4} +} + +func (x *ConfigFileReleaseHistory) GetId() *wrappers.UInt64Value { + if x != nil { + return x.Id + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetName() *wrappers.StringValue { + if x != nil { + return x.Name + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetNamespace() *wrappers.StringValue { + if x != nil { + return x.Namespace + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetGroup() *wrappers.StringValue { + if x != nil { + return x.Group + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetFileName() *wrappers.StringValue { + if x != nil { + return x.FileName + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetContent() *wrappers.StringValue { + if x != nil { + return x.Content + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetFormat() *wrappers.StringValue { + if x != nil { + return x.Format + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetComment() *wrappers.StringValue { + if x != nil { + return x.Comment + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetMd5() *wrappers.StringValue { + if x != nil { + return x.Md5 + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetType() *wrappers.StringValue { + if x != nil { + return x.Type + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetStatus() *wrappers.StringValue { + if x != nil { + return x.Status + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetTags() []*ConfigFileTag { + if x != nil { + return x.Tags + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetCreateTime() *wrappers.StringValue { + if x != nil { + return x.CreateTime + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetCreateBy() *wrappers.StringValue { + if x != nil { + return x.CreateBy + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetModifyTime() *wrappers.StringValue { + if x != nil { + return x.ModifyTime + } + return nil +} + +func (x *ConfigFileReleaseHistory) GetModifyBy() *wrappers.StringValue { + if x != nil { + return x.ModifyBy + } + return nil +} + +type ClientConfigFileInfo struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Namespace *wrappers.StringValue `protobuf:"bytes,1,opt,name=namespace,proto3" json:"namespace,omitempty"` + Group *wrappers.StringValue `protobuf:"bytes,2,opt,name=group,proto3" json:"group,omitempty"` + FileName *wrappers.StringValue `protobuf:"bytes,3,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` + Content *wrappers.StringValue `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"` + Version *wrappers.UInt64Value `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"` + Md5 *wrappers.StringValue `protobuf:"bytes,6,opt,name=md5,proto3" json:"md5,omitempty"` +} + +func (x *ClientConfigFileInfo) Reset() { + *x = ClientConfigFileInfo{} + if protoimpl.UnsafeEnabled { + mi := &file_config_file_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClientConfigFileInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClientConfigFileInfo) ProtoMessage() {} + +func (x *ClientConfigFileInfo) ProtoReflect() protoreflect.Message { + mi := &file_config_file_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClientConfigFileInfo.ProtoReflect.Descriptor instead. +func (*ClientConfigFileInfo) Descriptor() ([]byte, []int) { + return file_config_file_proto_rawDescGZIP(), []int{5} +} + +func (x *ClientConfigFileInfo) GetNamespace() *wrappers.StringValue { + if x != nil { + return x.Namespace + } + return nil +} + +func (x *ClientConfigFileInfo) GetGroup() *wrappers.StringValue { + if x != nil { + return x.Group + } + return nil +} + +func (x *ClientConfigFileInfo) GetFileName() *wrappers.StringValue { + if x != nil { + return x.FileName + } + return nil +} + +func (x *ClientConfigFileInfo) GetContent() *wrappers.StringValue { + if x != nil { + return x.Content + } + return nil +} + +func (x *ClientConfigFileInfo) GetVersion() *wrappers.UInt64Value { + if x != nil { + return x.Version + } + return nil +} + +func (x *ClientConfigFileInfo) GetMd5() *wrappers.StringValue { + if x != nil { + return x.Md5 + } + return nil +} + +type ClientWatchConfigFileRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ClientIp *wrappers.StringValue `protobuf:"bytes,1,opt,name=client_ip,json=clientIp,proto3" json:"client_ip,omitempty"` + ServiceName *wrappers.StringValue `protobuf:"bytes,2,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty"` + WatchFiles []*ClientConfigFileInfo `protobuf:"bytes,3,rep,name=watch_files,json=watchFiles,proto3" json:"watch_files,omitempty"` +} + +func (x *ClientWatchConfigFileRequest) Reset() { + *x = ClientWatchConfigFileRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_config_file_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ClientWatchConfigFileRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ClientWatchConfigFileRequest) ProtoMessage() {} + +func (x *ClientWatchConfigFileRequest) ProtoReflect() protoreflect.Message { + mi := &file_config_file_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ClientWatchConfigFileRequest.ProtoReflect.Descriptor instead. +func (*ClientWatchConfigFileRequest) Descriptor() ([]byte, []int) { + return file_config_file_proto_rawDescGZIP(), []int{6} +} + +func (x *ClientWatchConfigFileRequest) GetClientIp() *wrappers.StringValue { + if x != nil { + return x.ClientIp + } + return nil +} + +func (x *ClientWatchConfigFileRequest) GetServiceName() *wrappers.StringValue { + if x != nil { + return x.ServiceName + } + return nil +} + +func (x *ClientWatchConfigFileRequest) GetWatchFiles() []*ClientConfigFileInfo { + if x != nil { + return x.WatchFiles + } + return nil +} + +var File_config_file_proto protoreflect.FileDescriptor + +var file_config_file_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x76, 0x31, 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, + 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x95, 0x04, 0x0a, 0x0f, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x2c, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x02, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x09, 0x6e, + 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x09, 0x6e, 0x61, + 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, + 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, + 0x3d, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x39, + 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x62, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x08, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x79, 0x12, 0x3d, 0x0a, 0x0b, 0x6d, 0x6f, 0x64, + 0x69, 0x66, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x6d, 0x6f, + 0x64, 0x69, 0x66, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x39, 0x0a, 0x09, 0x6d, 0x6f, 0x64, 0x69, + 0x66, 0x79, 0x5f, 0x62, 0x79, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x08, 0x6d, 0x6f, 0x64, 0x69, 0x66, + 0x79, 0x42, 0x79, 0x12, 0x3a, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, + 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x52, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, + 0xd1, 0x06, 0x0a, 0x0a, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x2c, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, + 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x02, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3a, + 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, + 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x36, + 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x07, 0x63, + 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x34, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x36, 0x0a, 0x07, + 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, + 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x34, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x08, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x25, 0x0a, 0x04, 0x74, 0x61, + 0x67, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, 0x67, + 0x73, 0x12, 0x3d, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, + 0x12, 0x39, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x62, 0x79, 0x18, 0x0b, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x52, 0x08, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x79, 0x12, 0x3d, 0x0a, 0x0b, 0x6d, + 0x6f, 0x64, 0x69, 0x66, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, + 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x39, 0x0a, 0x09, 0x6d, 0x6f, + 0x64, 0x69, 0x66, 0x79, 0x5f, 0x62, 0x79, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x08, 0x6d, 0x6f, 0x64, + 0x69, 0x66, 0x79, 0x42, 0x79, 0x12, 0x3f, 0x0a, 0x0c, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, + 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0b, 0x72, 0x65, 0x6c, 0x65, 0x61, + 0x73, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x3b, 0x0a, 0x0a, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x5f, 0x62, 0x79, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x09, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, + 0x65, 0x42, 0x79, 0x22, 0x73, 0x0a, 0x0d, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, + 0x65, 0x54, 0x61, 0x67, 0x12, 0x2e, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x03, 0x6b, 0x65, 0x79, 0x12, 0x32, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, 0xea, 0x05, 0x0a, 0x11, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x2c, + 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, + 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x02, 0x69, 0x64, 0x12, 0x30, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x3a, + 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x67, 0x72, + 0x6f, 0x75, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, + 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x39, + 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x63, 0x6f, 0x6e, + 0x74, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, + 0x74, 0x12, 0x36, 0x0a, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x2e, 0x0a, 0x03, 0x6d, 0x64, 0x35, + 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x52, 0x03, 0x6d, 0x64, 0x35, 0x12, 0x36, 0x0a, 0x07, 0x76, 0x65, 0x72, + 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, + 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, + 0x6e, 0x12, 0x3d, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x0a, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, + 0x12, 0x39, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x62, 0x79, 0x18, 0x0b, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x52, 0x08, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x79, 0x12, 0x3d, 0x0a, 0x0b, 0x6d, + 0x6f, 0x64, 0x69, 0x66, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, + 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x39, 0x0a, 0x09, 0x6d, 0x6f, + 0x64, 0x69, 0x66, 0x79, 0x5f, 0x62, 0x79, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x08, 0x6d, 0x6f, 0x64, + 0x69, 0x66, 0x79, 0x42, 0x79, 0x22, 0xfe, 0x06, 0x0a, 0x18, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x48, 0x69, 0x73, 0x74, 0x6f, + 0x72, 0x79, 0x12, 0x2c, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x02, 0x69, 0x64, + 0x12, 0x30, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x6e, 0x61, + 0x6d, 0x65, 0x12, 0x3a, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x32, + 0x0a, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, + 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, + 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x67, 0x72, 0x6f, + 0x75, 0x70, 0x12, 0x39, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x36, 0x0a, + 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x07, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x34, 0x0a, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x18, + 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x52, 0x06, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x12, 0x36, 0x0a, 0x07, 0x63, + 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, + 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6d, 0x6d, + 0x65, 0x6e, 0x74, 0x12, 0x2e, 0x0a, 0x03, 0x6d, 0x64, 0x35, 0x18, 0x09, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x03, + 0x6d, 0x64, 0x35, 0x12, 0x30, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x34, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, + 0x0b, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, + 0x6c, 0x75, 0x65, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x25, 0x0a, 0x04, 0x74, + 0x61, 0x67, 0x73, 0x18, 0x0c, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x76, 0x31, 0x2e, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, + 0x67, 0x73, 0x12, 0x3d, 0x0a, 0x0b, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x74, 0x69, 0x6d, + 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, + 0x65, 0x12, 0x39, 0x0a, 0x09, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x5f, 0x62, 0x79, 0x18, 0x0e, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x52, 0x08, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x42, 0x79, 0x12, 0x3d, 0x0a, 0x0b, + 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x0f, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x0a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x39, 0x0a, 0x09, 0x6d, + 0x6f, 0x64, 0x69, 0x66, 0x79, 0x5f, 0x62, 0x79, 0x18, 0x10, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x08, 0x6d, 0x6f, + 0x64, 0x69, 0x66, 0x79, 0x42, 0x79, 0x22, 0xe1, 0x02, 0x0a, 0x14, 0x43, 0x6c, 0x69, 0x65, 0x6e, + 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x12, + 0x3a, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x52, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x32, 0x0a, 0x05, 0x67, + 0x72, 0x6f, 0x75, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, + 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x12, + 0x39, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x07, 0x63, 0x6f, + 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, + 0x6e, 0x74, 0x12, 0x36, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x36, 0x34, 0x56, 0x61, 0x6c, 0x75, + 0x65, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2e, 0x0a, 0x03, 0x6d, 0x64, + 0x35, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, + 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x03, 0x6d, 0x64, 0x35, 0x22, 0xd5, 0x01, 0x0a, 0x1c, 0x43, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x57, 0x61, 0x74, 0x63, 0x68, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x39, 0x0a, 0x09, 0x63, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, + 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x08, 0x63, 0x6c, + 0x69, 0x65, 0x6e, 0x74, 0x49, 0x70, 0x12, 0x3f, 0x0a, 0x0c, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, + 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, + 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, + 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x0b, 0x73, 0x65, 0x72, 0x76, + 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x39, 0x0a, 0x0b, 0x77, 0x61, 0x74, 0x63, 0x68, + 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, + 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x77, 0x61, 0x74, 0x63, 0x68, 0x46, 0x69, 0x6c, + 0x65, 0x73, 0x42, 0x05, 0x5a, 0x03, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, +} + +var ( + file_config_file_proto_rawDescOnce sync.Once + file_config_file_proto_rawDescData = file_config_file_proto_rawDesc +) + +func file_config_file_proto_rawDescGZIP() []byte { + file_config_file_proto_rawDescOnce.Do(func() { + file_config_file_proto_rawDescData = protoimpl.X.CompressGZIP(file_config_file_proto_rawDescData) + }) + return file_config_file_proto_rawDescData +} + +var file_config_file_proto_msgTypes = make([]protoimpl.MessageInfo, 7) +var file_config_file_proto_goTypes = []interface{}{ + (*ConfigFileGroup)(nil), // 0: v1.ConfigFileGroup + (*ConfigFile)(nil), // 1: v1.ConfigFile + (*ConfigFileTag)(nil), // 2: v1.ConfigFileTag + (*ConfigFileRelease)(nil), // 3: v1.ConfigFileRelease + (*ConfigFileReleaseHistory)(nil), // 4: v1.ConfigFileReleaseHistory + (*ClientConfigFileInfo)(nil), // 5: v1.ClientConfigFileInfo + (*ClientWatchConfigFileRequest)(nil), // 6: v1.ClientWatchConfigFileRequest + (*wrappers.UInt64Value)(nil), // 7: google.protobuf.UInt64Value + (*wrappers.StringValue)(nil), // 8: google.protobuf.StringValue +} +var file_config_file_proto_depIdxs = []int32{ + 7, // 0: v1.ConfigFileGroup.id:type_name -> google.protobuf.UInt64Value + 8, // 1: v1.ConfigFileGroup.name:type_name -> google.protobuf.StringValue + 8, // 2: v1.ConfigFileGroup.namespace:type_name -> google.protobuf.StringValue + 8, // 3: v1.ConfigFileGroup.comment:type_name -> google.protobuf.StringValue + 8, // 4: v1.ConfigFileGroup.create_time:type_name -> google.protobuf.StringValue + 8, // 5: v1.ConfigFileGroup.create_by:type_name -> google.protobuf.StringValue + 8, // 6: v1.ConfigFileGroup.modify_time:type_name -> google.protobuf.StringValue + 8, // 7: v1.ConfigFileGroup.modify_by:type_name -> google.protobuf.StringValue + 7, // 8: v1.ConfigFileGroup.fileCount:type_name -> google.protobuf.UInt64Value + 7, // 9: v1.ConfigFile.id:type_name -> google.protobuf.UInt64Value + 8, // 10: v1.ConfigFile.name:type_name -> google.protobuf.StringValue + 8, // 11: v1.ConfigFile.namespace:type_name -> google.protobuf.StringValue + 8, // 12: v1.ConfigFile.group:type_name -> google.protobuf.StringValue + 8, // 13: v1.ConfigFile.content:type_name -> google.protobuf.StringValue + 8, // 14: v1.ConfigFile.format:type_name -> google.protobuf.StringValue + 8, // 15: v1.ConfigFile.comment:type_name -> google.protobuf.StringValue + 8, // 16: v1.ConfigFile.status:type_name -> google.protobuf.StringValue + 2, // 17: v1.ConfigFile.tags:type_name -> v1.ConfigFileTag + 8, // 18: v1.ConfigFile.create_time:type_name -> google.protobuf.StringValue + 8, // 19: v1.ConfigFile.create_by:type_name -> google.protobuf.StringValue + 8, // 20: v1.ConfigFile.modify_time:type_name -> google.protobuf.StringValue + 8, // 21: v1.ConfigFile.modify_by:type_name -> google.protobuf.StringValue + 8, // 22: v1.ConfigFile.release_time:type_name -> google.protobuf.StringValue + 8, // 23: v1.ConfigFile.release_by:type_name -> google.protobuf.StringValue + 8, // 24: v1.ConfigFileTag.key:type_name -> google.protobuf.StringValue + 8, // 25: v1.ConfigFileTag.value:type_name -> google.protobuf.StringValue + 7, // 26: v1.ConfigFileRelease.id:type_name -> google.protobuf.UInt64Value + 8, // 27: v1.ConfigFileRelease.name:type_name -> google.protobuf.StringValue + 8, // 28: v1.ConfigFileRelease.namespace:type_name -> google.protobuf.StringValue + 8, // 29: v1.ConfigFileRelease.group:type_name -> google.protobuf.StringValue + 8, // 30: v1.ConfigFileRelease.file_name:type_name -> google.protobuf.StringValue + 8, // 31: v1.ConfigFileRelease.content:type_name -> google.protobuf.StringValue + 8, // 32: v1.ConfigFileRelease.comment:type_name -> google.protobuf.StringValue + 8, // 33: v1.ConfigFileRelease.md5:type_name -> google.protobuf.StringValue + 7, // 34: v1.ConfigFileRelease.version:type_name -> google.protobuf.UInt64Value + 8, // 35: v1.ConfigFileRelease.create_time:type_name -> google.protobuf.StringValue + 8, // 36: v1.ConfigFileRelease.create_by:type_name -> google.protobuf.StringValue + 8, // 37: v1.ConfigFileRelease.modify_time:type_name -> google.protobuf.StringValue + 8, // 38: v1.ConfigFileRelease.modify_by:type_name -> google.protobuf.StringValue + 7, // 39: v1.ConfigFileReleaseHistory.id:type_name -> google.protobuf.UInt64Value + 8, // 40: v1.ConfigFileReleaseHistory.name:type_name -> google.protobuf.StringValue + 8, // 41: v1.ConfigFileReleaseHistory.namespace:type_name -> google.protobuf.StringValue + 8, // 42: v1.ConfigFileReleaseHistory.group:type_name -> google.protobuf.StringValue + 8, // 43: v1.ConfigFileReleaseHistory.file_name:type_name -> google.protobuf.StringValue + 8, // 44: v1.ConfigFileReleaseHistory.content:type_name -> google.protobuf.StringValue + 8, // 45: v1.ConfigFileReleaseHistory.format:type_name -> google.protobuf.StringValue + 8, // 46: v1.ConfigFileReleaseHistory.comment:type_name -> google.protobuf.StringValue + 8, // 47: v1.ConfigFileReleaseHistory.md5:type_name -> google.protobuf.StringValue + 8, // 48: v1.ConfigFileReleaseHistory.type:type_name -> google.protobuf.StringValue + 8, // 49: v1.ConfigFileReleaseHistory.status:type_name -> google.protobuf.StringValue + 2, // 50: v1.ConfigFileReleaseHistory.tags:type_name -> v1.ConfigFileTag + 8, // 51: v1.ConfigFileReleaseHistory.create_time:type_name -> google.protobuf.StringValue + 8, // 52: v1.ConfigFileReleaseHistory.create_by:type_name -> google.protobuf.StringValue + 8, // 53: v1.ConfigFileReleaseHistory.modify_time:type_name -> google.protobuf.StringValue + 8, // 54: v1.ConfigFileReleaseHistory.modify_by:type_name -> google.protobuf.StringValue + 8, // 55: v1.ClientConfigFileInfo.namespace:type_name -> google.protobuf.StringValue + 8, // 56: v1.ClientConfigFileInfo.group:type_name -> google.protobuf.StringValue + 8, // 57: v1.ClientConfigFileInfo.file_name:type_name -> google.protobuf.StringValue + 8, // 58: v1.ClientConfigFileInfo.content:type_name -> google.protobuf.StringValue + 7, // 59: v1.ClientConfigFileInfo.version:type_name -> google.protobuf.UInt64Value + 8, // 60: v1.ClientConfigFileInfo.md5:type_name -> google.protobuf.StringValue + 8, // 61: v1.ClientWatchConfigFileRequest.client_ip:type_name -> google.protobuf.StringValue + 8, // 62: v1.ClientWatchConfigFileRequest.service_name:type_name -> google.protobuf.StringValue + 5, // 63: v1.ClientWatchConfigFileRequest.watch_files:type_name -> v1.ClientConfigFileInfo + 64, // [64:64] is the sub-list for method output_type + 64, // [64:64] is the sub-list for method input_type + 64, // [64:64] is the sub-list for extension type_name + 64, // [64:64] is the sub-list for extension extendee + 0, // [0:64] is the sub-list for field type_name +} + +func init() { file_config_file_proto_init() } +func file_config_file_proto_init() { + if File_config_file_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_config_file_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfigFileGroup); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_config_file_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfigFile); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_config_file_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfigFileTag); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_config_file_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfigFileRelease); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_config_file_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfigFileReleaseHistory); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_config_file_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClientConfigFileInfo); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_config_file_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ClientWatchConfigFileRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_config_file_proto_rawDesc, + NumEnums: 0, + NumMessages: 7, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_config_file_proto_goTypes, + DependencyIndexes: file_config_file_proto_depIdxs, + MessageInfos: file_config_file_proto_msgTypes, + }.Build() + File_config_file_proto = out.File + file_config_file_proto_rawDesc = nil + file_config_file_proto_goTypes = nil + file_config_file_proto_depIdxs = nil +} diff --git a/pkg/model/pb/v1/config_file.proto b/pkg/model/pb/v1/config_file.proto new file mode 100644 index 00000000..21ed8c65 --- /dev/null +++ b/pkg/model/pb/v1/config_file.proto @@ -0,0 +1,91 @@ +syntax = "proto3"; + +package v1; + +import "google/protobuf/wrappers.proto"; +option go_package = "v1"; + +message ConfigFileGroup { + google.protobuf.UInt64Value id = 1; + google.protobuf.StringValue name = 2; + google.protobuf.StringValue namespace = 3; + google.protobuf.StringValue comment = 4; + google.protobuf.StringValue create_time = 5; + google.protobuf.StringValue create_by = 6; + google.protobuf.StringValue modify_time = 7; + google.protobuf.StringValue modify_by = 8; + google.protobuf.UInt64Value fileCount = 9; +} + +message ConfigFile { + google.protobuf.UInt64Value id = 1; + google.protobuf.StringValue name = 2; + google.protobuf.StringValue namespace = 3; + google.protobuf.StringValue group = 4; + google.protobuf.StringValue content = 5; + google.protobuf.StringValue format = 6; + google.protobuf.StringValue comment = 7; + google.protobuf.StringValue status = 8; + repeated ConfigFileTag tags = 9; + google.protobuf.StringValue create_time = 10; + google.protobuf.StringValue create_by = 11; + google.protobuf.StringValue modify_time = 12; + google.protobuf.StringValue modify_by = 13; + google.protobuf.StringValue release_time = 14; + google.protobuf.StringValue release_by = 15; +} + +message ConfigFileTag { + google.protobuf.StringValue key = 1; + google.protobuf.StringValue value = 2; +} + +message ConfigFileRelease { + google.protobuf.UInt64Value id = 1; + google.protobuf.StringValue name = 2; + google.protobuf.StringValue namespace = 3; + google.protobuf.StringValue group = 4; + google.protobuf.StringValue file_name = 5; + google.protobuf.StringValue content = 6; + google.protobuf.StringValue comment = 7; + google.protobuf.StringValue md5 = 8; + google.protobuf.UInt64Value version = 9; + google.protobuf.StringValue create_time = 10; + google.protobuf.StringValue create_by = 11; + google.protobuf.StringValue modify_time = 12; + google.protobuf.StringValue modify_by = 13; +} + +message ConfigFileReleaseHistory { + google.protobuf.UInt64Value id = 1; + google.protobuf.StringValue name = 2; + google.protobuf.StringValue namespace = 3; + google.protobuf.StringValue group = 4; + google.protobuf.StringValue file_name = 5; + google.protobuf.StringValue content = 6; + google.protobuf.StringValue format = 7; + google.protobuf.StringValue comment = 8; + google.protobuf.StringValue md5 = 9; + google.protobuf.StringValue type = 10; + google.protobuf.StringValue status = 11; + repeated ConfigFileTag tags = 12; + google.protobuf.StringValue create_time = 13; + google.protobuf.StringValue create_by = 14; + google.protobuf.StringValue modify_time = 15; + google.protobuf.StringValue modify_by = 16; +} + +message ClientConfigFileInfo { + google.protobuf.StringValue namespace = 1; + google.protobuf.StringValue group = 2; + google.protobuf.StringValue file_name = 3; + google.protobuf.StringValue content = 4; + google.protobuf.UInt64Value version = 5; + google.protobuf.StringValue md5 = 6; +} + +message ClientWatchConfigFileRequest { + google.protobuf.StringValue client_ip = 1; + google.protobuf.StringValue service_name = 2; + repeated ClientConfigFileInfo watch_files = 3; +} diff --git a/pkg/model/pb/v1/config_file_response.pb.go b/pkg/model/pb/v1/config_file_response.pb.go new file mode 100644 index 00000000..e05a5f6e --- /dev/null +++ b/pkg/model/pb/v1/config_file_response.pb.go @@ -0,0 +1,637 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v3.17.3 +// source: config_file_response.proto + +package v1 + +import ( + reflect "reflect" + sync "sync" + + wrappers "github.com/golang/protobuf/ptypes/wrappers" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ConfigSimpleResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code *wrappers.UInt32Value `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + Info *wrappers.StringValue `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` +} + +func (x *ConfigSimpleResponse) Reset() { + *x = ConfigSimpleResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_config_file_response_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfigSimpleResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigSimpleResponse) ProtoMessage() {} + +func (x *ConfigSimpleResponse) ProtoReflect() protoreflect.Message { + mi := &file_config_file_response_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigSimpleResponse.ProtoReflect.Descriptor instead. +func (*ConfigSimpleResponse) Descriptor() ([]byte, []int) { + return file_config_file_response_proto_rawDescGZIP(), []int{0} +} + +func (x *ConfigSimpleResponse) GetCode() *wrappers.UInt32Value { + if x != nil { + return x.Code + } + return nil +} + +func (x *ConfigSimpleResponse) GetInfo() *wrappers.StringValue { + if x != nil { + return x.Info + } + return nil +} + +type ConfigResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code *wrappers.UInt32Value `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + Info *wrappers.StringValue `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` + ConfigFileGroup *ConfigFileGroup `protobuf:"bytes,3,opt,name=configFileGroup,proto3" json:"configFileGroup,omitempty"` + ConfigFile *ConfigFile `protobuf:"bytes,4,opt,name=configFile,proto3" json:"configFile,omitempty"` + ConfigFileRelease *ConfigFileRelease `protobuf:"bytes,5,opt,name=configFileRelease,proto3" json:"configFileRelease,omitempty"` + ConfigFileReleaseHistory *ConfigFileReleaseHistory `protobuf:"bytes,6,opt,name=configFileReleaseHistory,proto3" json:"configFileReleaseHistory,omitempty"` +} + +func (x *ConfigResponse) Reset() { + *x = ConfigResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_config_file_response_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfigResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigResponse) ProtoMessage() {} + +func (x *ConfigResponse) ProtoReflect() protoreflect.Message { + mi := &file_config_file_response_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigResponse.ProtoReflect.Descriptor instead. +func (*ConfigResponse) Descriptor() ([]byte, []int) { + return file_config_file_response_proto_rawDescGZIP(), []int{1} +} + +func (x *ConfigResponse) GetCode() *wrappers.UInt32Value { + if x != nil { + return x.Code + } + return nil +} + +func (x *ConfigResponse) GetInfo() *wrappers.StringValue { + if x != nil { + return x.Info + } + return nil +} + +func (x *ConfigResponse) GetConfigFileGroup() *ConfigFileGroup { + if x != nil { + return x.ConfigFileGroup + } + return nil +} + +func (x *ConfigResponse) GetConfigFile() *ConfigFile { + if x != nil { + return x.ConfigFile + } + return nil +} + +func (x *ConfigResponse) GetConfigFileRelease() *ConfigFileRelease { + if x != nil { + return x.ConfigFileRelease + } + return nil +} + +func (x *ConfigResponse) GetConfigFileReleaseHistory() *ConfigFileReleaseHistory { + if x != nil { + return x.ConfigFileReleaseHistory + } + return nil +} + +type ConfigBatchWriteResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code *wrappers.UInt32Value `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + Info *wrappers.StringValue `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` + Total *wrappers.UInt32Value `protobuf:"bytes,3,opt,name=total,proto3" json:"total,omitempty"` + Responses []*ConfigResponse `protobuf:"bytes,4,rep,name=responses,proto3" json:"responses,omitempty"` +} + +func (x *ConfigBatchWriteResponse) Reset() { + *x = ConfigBatchWriteResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_config_file_response_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfigBatchWriteResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigBatchWriteResponse) ProtoMessage() {} + +func (x *ConfigBatchWriteResponse) ProtoReflect() protoreflect.Message { + mi := &file_config_file_response_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigBatchWriteResponse.ProtoReflect.Descriptor instead. +func (*ConfigBatchWriteResponse) Descriptor() ([]byte, []int) { + return file_config_file_response_proto_rawDescGZIP(), []int{2} +} + +func (x *ConfigBatchWriteResponse) GetCode() *wrappers.UInt32Value { + if x != nil { + return x.Code + } + return nil +} + +func (x *ConfigBatchWriteResponse) GetInfo() *wrappers.StringValue { + if x != nil { + return x.Info + } + return nil +} + +func (x *ConfigBatchWriteResponse) GetTotal() *wrappers.UInt32Value { + if x != nil { + return x.Total + } + return nil +} + +func (x *ConfigBatchWriteResponse) GetResponses() []*ConfigResponse { + if x != nil { + return x.Responses + } + return nil +} + +type ConfigBatchQueryResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code *wrappers.UInt32Value `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + Info *wrappers.StringValue `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` + Total *wrappers.UInt32Value `protobuf:"bytes,3,opt,name=total,proto3" json:"total,omitempty"` + ConfigFileGroups []*ConfigFileGroup `protobuf:"bytes,4,rep,name=configFileGroups,proto3" json:"configFileGroups,omitempty"` + ConfigFiles []*ConfigFile `protobuf:"bytes,5,rep,name=configFiles,proto3" json:"configFiles,omitempty"` + ConfigFileReleases []*ConfigFileRelease `protobuf:"bytes,6,rep,name=configFileReleases,proto3" json:"configFileReleases,omitempty"` + ConfigFileReleaseHistories []*ConfigFileReleaseHistory `protobuf:"bytes,7,rep,name=configFileReleaseHistories,proto3" json:"configFileReleaseHistories,omitempty"` +} + +func (x *ConfigBatchQueryResponse) Reset() { + *x = ConfigBatchQueryResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_config_file_response_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfigBatchQueryResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigBatchQueryResponse) ProtoMessage() {} + +func (x *ConfigBatchQueryResponse) ProtoReflect() protoreflect.Message { + mi := &file_config_file_response_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigBatchQueryResponse.ProtoReflect.Descriptor instead. +func (*ConfigBatchQueryResponse) Descriptor() ([]byte, []int) { + return file_config_file_response_proto_rawDescGZIP(), []int{3} +} + +func (x *ConfigBatchQueryResponse) GetCode() *wrappers.UInt32Value { + if x != nil { + return x.Code + } + return nil +} + +func (x *ConfigBatchQueryResponse) GetInfo() *wrappers.StringValue { + if x != nil { + return x.Info + } + return nil +} + +func (x *ConfigBatchQueryResponse) GetTotal() *wrappers.UInt32Value { + if x != nil { + return x.Total + } + return nil +} + +func (x *ConfigBatchQueryResponse) GetConfigFileGroups() []*ConfigFileGroup { + if x != nil { + return x.ConfigFileGroups + } + return nil +} + +func (x *ConfigBatchQueryResponse) GetConfigFiles() []*ConfigFile { + if x != nil { + return x.ConfigFiles + } + return nil +} + +func (x *ConfigBatchQueryResponse) GetConfigFileReleases() []*ConfigFileRelease { + if x != nil { + return x.ConfigFileReleases + } + return nil +} + +func (x *ConfigBatchQueryResponse) GetConfigFileReleaseHistories() []*ConfigFileReleaseHistory { + if x != nil { + return x.ConfigFileReleaseHistories + } + return nil +} + +type ConfigClientResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Code *wrappers.UInt32Value `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` + Info *wrappers.StringValue `protobuf:"bytes,2,opt,name=info,proto3" json:"info,omitempty"` + ConfigFile *ClientConfigFileInfo `protobuf:"bytes,3,opt,name=configFile,proto3" json:"configFile,omitempty"` +} + +func (x *ConfigClientResponse) Reset() { + *x = ConfigClientResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_config_file_response_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ConfigClientResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ConfigClientResponse) ProtoMessage() {} + +func (x *ConfigClientResponse) ProtoReflect() protoreflect.Message { + mi := &file_config_file_response_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ConfigClientResponse.ProtoReflect.Descriptor instead. +func (*ConfigClientResponse) Descriptor() ([]byte, []int) { + return file_config_file_response_proto_rawDescGZIP(), []int{4} +} + +func (x *ConfigClientResponse) GetCode() *wrappers.UInt32Value { + if x != nil { + return x.Code + } + return nil +} + +func (x *ConfigClientResponse) GetInfo() *wrappers.StringValue { + if x != nil { + return x.Info + } + return nil +} + +func (x *ConfigClientResponse) GetConfigFile() *ClientConfigFileInfo { + if x != nil { + return x.ConfigFile + } + return nil +} + +var File_config_file_response_proto protoreflect.FileDescriptor + +var file_config_file_response_proto_rawDesc = []byte{ + 0x0a, 0x1a, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x72, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x76, 0x31, + 0x1a, 0x1e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2f, 0x77, 0x72, 0x61, 0x70, 0x70, 0x65, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x11, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0x7a, 0x0a, 0x14, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x53, 0x69, 0x6d, + 0x70, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x63, + 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, + 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x30, 0x0a, + 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, + 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x22, + 0x82, 0x03, 0x0a, 0x0e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, + 0x63, 0x6f, 0x64, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, + 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x3d, 0x0a, 0x0f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, + 0x46, 0x69, 0x6c, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x13, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x47, + 0x72, 0x6f, 0x75, 0x70, 0x52, 0x0f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, + 0x47, 0x72, 0x6f, 0x75, 0x70, 0x12, 0x2e, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, + 0x69, 0x6c, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x76, 0x31, 0x2e, 0x43, + 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x66, 0x69, + 0x67, 0x46, 0x69, 0x6c, 0x65, 0x12, 0x43, 0x0a, 0x11, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, + 0x69, 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, + 0x32, 0x15, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, + 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x11, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, + 0x69, 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x58, 0x0a, 0x18, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x48, + 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x65, + 0x61, 0x73, 0x65, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x18, 0x63, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x48, 0x69, 0x73, + 0x74, 0x6f, 0x72, 0x79, 0x22, 0xe4, 0x01, 0x0a, 0x18, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, + 0x61, 0x74, 0x63, 0x68, 0x57, 0x72, 0x69, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x30, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x63, + 0x6f, 0x64, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x32, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, + 0x75, 0x65, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x30, 0x0a, 0x09, 0x72, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x76, + 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x52, 0x09, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x73, 0x22, 0xca, 0x03, 0x0a, 0x18, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x42, 0x61, 0x74, 0x63, 0x68, 0x51, 0x75, 0x65, 0x72, 0x79, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, + 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x69, 0x6e, + 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, + 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x32, 0x0a, 0x05, + 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, + 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x55, 0x49, + 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, + 0x12, 0x3f, 0x0a, 0x10, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x47, 0x72, + 0x6f, 0x75, 0x70, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x76, 0x31, 0x2e, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x52, + 0x10, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, + 0x73, 0x12, 0x30, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x73, + 0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, + 0x6c, 0x65, 0x73, 0x12, 0x45, 0x0a, 0x12, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, + 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, + 0x15, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x12, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, + 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x73, 0x12, 0x5c, 0x0a, 0x1a, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x48, + 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, + 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, + 0x6c, 0x65, 0x61, 0x73, 0x65, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x52, 0x1a, 0x63, 0x6f, + 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x48, + 0x69, 0x73, 0x74, 0x6f, 0x72, 0x69, 0x65, 0x73, 0x22, 0xb4, 0x01, 0x0a, 0x14, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x12, 0x30, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, + 0x66, 0x2e, 0x55, 0x49, 0x6e, 0x74, 0x33, 0x32, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x04, 0x63, + 0x6f, 0x64, 0x65, 0x12, 0x30, 0x0a, 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x1c, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x52, + 0x04, 0x69, 0x6e, 0x66, 0x6f, 0x12, 0x38, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, + 0x69, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x76, 0x31, 0x2e, 0x43, + 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x49, + 0x6e, 0x66, 0x6f, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x42, + 0x05, 0x5a, 0x03, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_config_file_response_proto_rawDescOnce sync.Once + file_config_file_response_proto_rawDescData = file_config_file_response_proto_rawDesc +) + +func file_config_file_response_proto_rawDescGZIP() []byte { + file_config_file_response_proto_rawDescOnce.Do(func() { + file_config_file_response_proto_rawDescData = protoimpl.X.CompressGZIP(file_config_file_response_proto_rawDescData) + }) + return file_config_file_response_proto_rawDescData +} + +var file_config_file_response_proto_msgTypes = make([]protoimpl.MessageInfo, 5) +var file_config_file_response_proto_goTypes = []interface{}{ + (*ConfigSimpleResponse)(nil), // 0: v1.ConfigSimpleResponse + (*ConfigResponse)(nil), // 1: v1.ConfigResponse + (*ConfigBatchWriteResponse)(nil), // 2: v1.ConfigBatchWriteResponse + (*ConfigBatchQueryResponse)(nil), // 3: v1.ConfigBatchQueryResponse + (*ConfigClientResponse)(nil), // 4: v1.ConfigClientResponse + (*wrappers.UInt32Value)(nil), // 5: google.protobuf.UInt32Value + (*wrappers.StringValue)(nil), // 6: google.protobuf.StringValue + (*ConfigFileGroup)(nil), // 7: v1.ConfigFileGroup + (*ConfigFile)(nil), // 8: v1.ConfigFile + (*ConfigFileRelease)(nil), // 9: v1.ConfigFileRelease + (*ConfigFileReleaseHistory)(nil), // 10: v1.ConfigFileReleaseHistory + (*ClientConfigFileInfo)(nil), // 11: v1.ClientConfigFileInfo +} +var file_config_file_response_proto_depIdxs = []int32{ + 5, // 0: v1.ConfigSimpleResponse.code:type_name -> google.protobuf.UInt32Value + 6, // 1: v1.ConfigSimpleResponse.info:type_name -> google.protobuf.StringValue + 5, // 2: v1.ConfigResponse.code:type_name -> google.protobuf.UInt32Value + 6, // 3: v1.ConfigResponse.info:type_name -> google.protobuf.StringValue + 7, // 4: v1.ConfigResponse.configFileGroup:type_name -> v1.ConfigFileGroup + 8, // 5: v1.ConfigResponse.configFile:type_name -> v1.ConfigFile + 9, // 6: v1.ConfigResponse.configFileRelease:type_name -> v1.ConfigFileRelease + 10, // 7: v1.ConfigResponse.configFileReleaseHistory:type_name -> v1.ConfigFileReleaseHistory + 5, // 8: v1.ConfigBatchWriteResponse.code:type_name -> google.protobuf.UInt32Value + 6, // 9: v1.ConfigBatchWriteResponse.info:type_name -> google.protobuf.StringValue + 5, // 10: v1.ConfigBatchWriteResponse.total:type_name -> google.protobuf.UInt32Value + 1, // 11: v1.ConfigBatchWriteResponse.responses:type_name -> v1.ConfigResponse + 5, // 12: v1.ConfigBatchQueryResponse.code:type_name -> google.protobuf.UInt32Value + 6, // 13: v1.ConfigBatchQueryResponse.info:type_name -> google.protobuf.StringValue + 5, // 14: v1.ConfigBatchQueryResponse.total:type_name -> google.protobuf.UInt32Value + 7, // 15: v1.ConfigBatchQueryResponse.configFileGroups:type_name -> v1.ConfigFileGroup + 8, // 16: v1.ConfigBatchQueryResponse.configFiles:type_name -> v1.ConfigFile + 9, // 17: v1.ConfigBatchQueryResponse.configFileReleases:type_name -> v1.ConfigFileRelease + 10, // 18: v1.ConfigBatchQueryResponse.configFileReleaseHistories:type_name -> v1.ConfigFileReleaseHistory + 5, // 19: v1.ConfigClientResponse.code:type_name -> google.protobuf.UInt32Value + 6, // 20: v1.ConfigClientResponse.info:type_name -> google.protobuf.StringValue + 11, // 21: v1.ConfigClientResponse.configFile:type_name -> v1.ClientConfigFileInfo + 22, // [22:22] is the sub-list for method output_type + 22, // [22:22] is the sub-list for method input_type + 22, // [22:22] is the sub-list for extension type_name + 22, // [22:22] is the sub-list for extension extendee + 0, // [0:22] is the sub-list for field type_name +} + +func init() { file_config_file_response_proto_init() } +func file_config_file_response_proto_init() { + if File_config_file_response_proto != nil { + return + } + file_config_file_proto_init() + if !protoimpl.UnsafeEnabled { + file_config_file_response_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfigSimpleResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_config_file_response_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfigResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_config_file_response_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfigBatchWriteResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_config_file_response_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfigBatchQueryResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_config_file_response_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ConfigClientResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_config_file_response_proto_rawDesc, + NumEnums: 0, + NumMessages: 5, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_config_file_response_proto_goTypes, + DependencyIndexes: file_config_file_response_proto_depIdxs, + MessageInfos: file_config_file_response_proto_msgTypes, + }.Build() + File_config_file_response_proto = out.File + file_config_file_response_proto_rawDesc = nil + file_config_file_response_proto_goTypes = nil + file_config_file_response_proto_depIdxs = nil +} diff --git a/pkg/model/pb/v1/config_file_response.proto b/pkg/model/pb/v1/config_file_response.proto new file mode 100644 index 00000000..a91f7ca0 --- /dev/null +++ b/pkg/model/pb/v1/config_file_response.proto @@ -0,0 +1,48 @@ +syntax = "proto3"; + +package v1; + +import "google/protobuf/wrappers.proto"; +import "config_file.proto"; + +option go_package="v1"; + +message ConfigSimpleResponse { + google.protobuf.UInt32Value code = 1; + google.protobuf.StringValue info = 2; +} + +message ConfigResponse { + google.protobuf.UInt32Value code = 1; + google.protobuf.StringValue info = 2; + + ConfigFileGroup configFileGroup = 3; + ConfigFile configFile = 4; + ConfigFileRelease configFileRelease = 5; + ConfigFileReleaseHistory configFileReleaseHistory = 6; +} + +message ConfigBatchWriteResponse { + google.protobuf.UInt32Value code = 1; + google.protobuf.StringValue info = 2; + google.protobuf.UInt32Value total = 3; + + repeated ConfigResponse responses = 4; +} + +message ConfigBatchQueryResponse { + google.protobuf.UInt32Value code = 1; + google.protobuf.StringValue info = 2; + google.protobuf.UInt32Value total = 3; + repeated ConfigFileGroup configFileGroups = 4; + repeated ConfigFile configFiles = 5; + repeated ConfigFileRelease configFileReleases = 6; + repeated ConfigFileReleaseHistory configFileReleaseHistories = 7; +} + +message ConfigClientResponse { + google.protobuf.UInt32Value code = 1; + google.protobuf.StringValue info = 2; + + ClientConfigFileInfo configFile = 3; +} diff --git a/pkg/model/pb/v1/grpc_config_api.pb.go b/pkg/model/pb/v1/grpc_config_api.pb.go new file mode 100644 index 00000000..76589c1e --- /dev/null +++ b/pkg/model/pb/v1/grpc_config_api.pb.go @@ -0,0 +1,210 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v3.17.3 +// source: grpc_config_api.proto + +package v1 + +import ( + context "context" + reflect "reflect" + + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +var File_grpc_config_api_proto protoreflect.FileDescriptor + +var file_grpc_config_api_proto_rawDesc = []byte{ + 0x0a, 0x15, 0x67, 0x72, 0x70, 0x63, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x61, 0x70, + 0x69, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x76, 0x31, 0x1a, 0x11, 0x63, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1a, + 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x72, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0xac, 0x01, 0x0a, 0x11, 0x50, + 0x6f, 0x6c, 0x61, 0x72, 0x69, 0x73, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x47, 0x52, 0x50, 0x43, + 0x12, 0x45, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, + 0x65, 0x12, 0x18, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, + 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x1a, 0x18, 0x2e, 0x76, 0x31, + 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x10, 0x57, 0x61, 0x74, 0x63, 0x68, + 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x20, 0x2e, 0x76, 0x31, + 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x57, 0x61, 0x74, 0x63, 0x68, 0x43, 0x6f, 0x6e, 0x66, + 0x69, 0x67, 0x46, 0x69, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, + 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x43, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x52, + 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x05, 0x5a, 0x03, 0x2f, 0x76, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var file_grpc_config_api_proto_goTypes = []interface{}{ + (*ClientConfigFileInfo)(nil), // 0: v1.ClientConfigFileInfo + (*ClientWatchConfigFileRequest)(nil), // 1: v1.ClientWatchConfigFileRequest + (*ConfigClientResponse)(nil), // 2: v1.ConfigClientResponse +} +var file_grpc_config_api_proto_depIdxs = []int32{ + 0, // 0: v1.PolarisConfigGRPC.GetConfigFile:input_type -> v1.ClientConfigFileInfo + 1, // 1: v1.PolarisConfigGRPC.WatchConfigFiles:input_type -> v1.ClientWatchConfigFileRequest + 2, // 2: v1.PolarisConfigGRPC.GetConfigFile:output_type -> v1.ConfigClientResponse + 2, // 3: v1.PolarisConfigGRPC.WatchConfigFiles:output_type -> v1.ConfigClientResponse + 2, // [2:4] is the sub-list for method output_type + 0, // [0:2] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_grpc_config_api_proto_init() } +func file_grpc_config_api_proto_init() { + if File_grpc_config_api_proto != nil { + return + } + file_config_file_proto_init() + file_config_file_response_proto_init() + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_grpc_config_api_proto_rawDesc, + NumEnums: 0, + NumMessages: 0, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_grpc_config_api_proto_goTypes, + DependencyIndexes: file_grpc_config_api_proto_depIdxs, + }.Build() + File_grpc_config_api_proto = out.File + file_grpc_config_api_proto_rawDesc = nil + file_grpc_config_api_proto_goTypes = nil + file_grpc_config_api_proto_depIdxs = nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConnInterface + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion6 + +// PolarisConfigGRPCClient is the client API for PolarisConfigGRPC service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type PolarisConfigGRPCClient interface { + // 拉取配置 + GetConfigFile(ctx context.Context, in *ClientConfigFileInfo, opts ...grpc.CallOption) (*ConfigClientResponse, error) + // 订阅配置变更 + WatchConfigFiles(ctx context.Context, in *ClientWatchConfigFileRequest, opts ...grpc.CallOption) (*ConfigClientResponse, error) +} + +type polarisConfigGRPCClient struct { + cc grpc.ClientConnInterface +} + +func NewPolarisConfigGRPCClient(cc grpc.ClientConnInterface) PolarisConfigGRPCClient { + return &polarisConfigGRPCClient{cc} +} + +func (c *polarisConfigGRPCClient) GetConfigFile(ctx context.Context, in *ClientConfigFileInfo, opts ...grpc.CallOption) (*ConfigClientResponse, error) { + out := new(ConfigClientResponse) + err := c.cc.Invoke(ctx, "/v1.PolarisConfigGRPC/GetConfigFile", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *polarisConfigGRPCClient) WatchConfigFiles(ctx context.Context, in *ClientWatchConfigFileRequest, opts ...grpc.CallOption) (*ConfigClientResponse, error) { + out := new(ConfigClientResponse) + err := c.cc.Invoke(ctx, "/v1.PolarisConfigGRPC/WatchConfigFiles", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// PolarisConfigGRPCServer is the server API for PolarisConfigGRPC service. +type PolarisConfigGRPCServer interface { + // 拉取配置 + GetConfigFile(context.Context, *ClientConfigFileInfo) (*ConfigClientResponse, error) + // 订阅配置变更 + WatchConfigFiles(context.Context, *ClientWatchConfigFileRequest) (*ConfigClientResponse, error) +} + +// UnimplementedPolarisConfigGRPCServer can be embedded to have forward compatible implementations. +type UnimplementedPolarisConfigGRPCServer struct { +} + +func (*UnimplementedPolarisConfigGRPCServer) GetConfigFile(context.Context, *ClientConfigFileInfo) (*ConfigClientResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetConfigFile not implemented") +} +func (*UnimplementedPolarisConfigGRPCServer) WatchConfigFiles(context.Context, *ClientWatchConfigFileRequest) (*ConfigClientResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WatchConfigFiles not implemented") +} + +func RegisterPolarisConfigGRPCServer(s *grpc.Server, srv PolarisConfigGRPCServer) { + s.RegisterService(&_PolarisConfigGRPC_serviceDesc, srv) +} + +func _PolarisConfigGRPC_GetConfigFile_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ClientConfigFileInfo) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PolarisConfigGRPCServer).GetConfigFile(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1.PolarisConfigGRPC/GetConfigFile", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PolarisConfigGRPCServer).GetConfigFile(ctx, req.(*ClientConfigFileInfo)) + } + return interceptor(ctx, in, info, handler) +} + +func _PolarisConfigGRPC_WatchConfigFiles_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ClientWatchConfigFileRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(PolarisConfigGRPCServer).WatchConfigFiles(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/v1.PolarisConfigGRPC/WatchConfigFiles", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(PolarisConfigGRPCServer).WatchConfigFiles(ctx, req.(*ClientWatchConfigFileRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _PolarisConfigGRPC_serviceDesc = grpc.ServiceDesc{ + ServiceName: "v1.PolarisConfigGRPC", + HandlerType: (*PolarisConfigGRPCServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetConfigFile", + Handler: _PolarisConfigGRPC_GetConfigFile_Handler, + }, + { + MethodName: "WatchConfigFiles", + Handler: _PolarisConfigGRPC_WatchConfigFiles_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "grpc_config_api.proto", +} diff --git a/pkg/model/pb/v1/grpc_config_api.proto b/pkg/model/pb/v1/grpc_config_api.proto new file mode 100644 index 00000000..8913b7fe --- /dev/null +++ b/pkg/model/pb/v1/grpc_config_api.proto @@ -0,0 +1,18 @@ +syntax = "proto3"; + +package v1; + +import "config_file.proto"; +import "config_file_response.proto"; + +option go_package = "v1"; + + +service PolarisConfigGRPC { + + // 拉取配置 + rpc GetConfigFile(ClientConfigFileInfo) returns (ConfigClientResponse) {} + + // 订阅配置变更 + rpc WatchConfigFiles(ClientWatchConfigFileRequest) returns (ConfigClientResponse) {} +} diff --git a/pkg/network/conn.go b/pkg/network/conn.go index 58b2dd6f..42f777f4 100644 --- a/pkg/network/conn.go +++ b/pkg/network/conn.go @@ -38,6 +38,7 @@ var ( // DefaultServerServiceToConnectionControl 不同系统服务使用不同的连接持有模式 DefaultServerServiceToConnectionControl = map[config.ClusterType]int{ config.DiscoverCluster: ConnectionLong, + config.ConfigCluster: ConnectionShort, config.HealthCheckCluster: ConnectionShort, config.MonitorCluster: ConnectionShort, } diff --git a/pkg/network/impl.go b/pkg/network/impl.go index e98f9057..eb728143 100644 --- a/pkg/network/impl.go +++ b/pkg/network/impl.go @@ -84,7 +84,7 @@ func (s *ServerAddressList) getAndConnectServer( func (s *ServerAddressList) getServerAddress(hashKey []byte) (string, model.Instance, error) { var targetAddress string var instance model.Instance - if s.service.ClusterType == config.BuiltinCluster { + if s.service.ClusterType == config.BuiltinCluster || s.service.ClusterType == config.ConfigCluster { serverCount := len(s.addresses) targetAddress = s.addresses[s.curIndex%serverCount] if s.curIndex == math.MaxInt32 { @@ -243,6 +243,8 @@ type connectionManager struct { cancel context.CancelFunc // 发现服务 discoverService model.ServiceKey + // 配置中心服务 + configService model.ServiceKey // 发现服务的事件集合,相同事件不去更新 discoverEventSet map[model.EventType]bool // 并发更新锁 @@ -301,12 +303,46 @@ func NewConnectionManager( manager.discoverService = builtInAddrList.service.ServiceKey manager.ready = serviceReadyStatus } - manager.ctx, manager.cancel = context.WithCancel(context.Background()) go manager.doSwitchRoutine() return manager, nil } +// NewConfigConnectionManager 创建配置中心连接管理器 +func NewConfigConnectionManager(cfg config.Configuration, valueCtx model.ValueContext) (ConnectionManager, error) { + configSwitchInterval := cfg.GetConfigFile().GetConfigConnectorConfig().GetServerSwitchInterval() + configConnectTimeout := cfg.GetConfigFile().GetConfigConnectorConfig().GetConnectTimeout() + configProtocol := cfg.GetConfigFile().GetConfigConnectorConfig().GetProtocol() + configManager := &connectionManager{ + connectTimeout: configConnectTimeout, + switchInterval: configSwitchInterval, + serverServices: make(map[config.ClusterType]*ServerAddressList), + valueCtx: valueCtx, + protocol: configProtocol, + } + + configAddresses := cfg.GetConfigFile().GetConfigConnectorConfig().GetAddresses() + configAddrList := &ServerAddressList{ + service: config.ClusterService{ + ServiceKey: model.ServiceKey{Namespace: config.ServerNamespace, Service: defaultService}, + ClusterType: config.ConfigCluster, + }, + useDefault: false, + manager: configManager, + addresses: configAddresses, + curIndex: rand.Intn(len(configAddresses)), + } + configManager.serverServices[config.ConfigCluster] = configAddrList + + if len(configManager.configService.Service) == 0 { + configManager.configService = configAddrList.service.ServiceKey + configManager.ready = serviceReadyStatus + } + + configManager.ctx, configManager.cancel = context.WithCancel(context.Background()) + return configManager, nil +} + // SetConnCreator 设置当前协议的连接创建器 func (c *connectionManager) SetConnCreator(creator ConnCreator) { c.creator = creator diff --git a/pkg/plugin/common/plugin.go b/pkg/plugin/common/plugin.go index 7833165e..c5fb923c 100644 --- a/pkg/plugin/common/plugin.go +++ b/pkg/plugin/common/plugin.go @@ -59,6 +59,8 @@ const ( TypeLocationProvider Type = 0x1012 // TypeReportHandler ReportClient 请求、响应处理器 TypeReportHandler Type = 0x1013 + // TypeConfigConnector extend point of config file connector + TypeConfigConnector Type = 0x1014 ) var typeToPresent = map[Type]string{ @@ -76,6 +78,7 @@ var typeToPresent = map[Type]string{ TypeSubScribe: "subScribe", TypeLocationProvider: "locationProvider", TypeReportHandler: "reportHandler", + TypeConfigConnector: "configConnector", } // ToString方法 @@ -243,4 +246,5 @@ var LoadedPluginTypes = []Type{ TypeSubScribe, TypeLocationProvider, TypeReportHandler, + TypeConfigConnector, } diff --git a/pkg/plugin/configconnector/config_connector.go b/pkg/plugin/configconnector/config_connector.go new file mode 100644 index 00000000..bad91cd9 --- /dev/null +++ b/pkg/plugin/configconnector/config_connector.go @@ -0,0 +1,38 @@ +/* + * Tencent is pleased to support the open source community by making polaris-go available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + */ + +package configconnector + +import ( + "github.com/polarismesh/polaris-go/pkg/plugin" + "github.com/polarismesh/polaris-go/pkg/plugin/common" +) + +// ConfigConnector interface of config connector plugin +type ConfigConnector interface { + plugin.Plugin + // GetConfigFile Get config file + GetConfigFile(configFile *ConfigFile) (*ConfigFileResponse, error) + // WatchConfigFiles Watch config files + WatchConfigFiles(configFileList []*ConfigFile) (*ConfigFileResponse, error) +} + +// init +func init() { + plugin.RegisterPluginInterface(common.TypeConfigConnector, new(ConfigConnector)) +} diff --git a/pkg/plugin/configconnector/config_file.go b/pkg/plugin/configconnector/config_file.go new file mode 100644 index 00000000..dfff2f0d --- /dev/null +++ b/pkg/plugin/configconnector/config_file.go @@ -0,0 +1,59 @@ +/* + * Tencent is pleased to support the open source community by making polaris-go available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + */ + +package configconnector + +// ConfigFile 配置文件 +type ConfigFile struct { + Namespace string + FileGroup string + FileName string + Content string + Version uint64 + Md5 string +} + +// GetNamespace 获取配置文件命名空间 +func (c *ConfigFile) GetNamespace() string { + return c.Namespace +} + +// GetFileGroup 获取配置文件组 +func (c *ConfigFile) GetFileGroup() string { + return c.FileGroup +} + +// GetFileName 获取配置文件名 +func (c *ConfigFile) GetFileName() string { + return c.FileName +} + +// GetContent 获取配置文件内容 +func (c *ConfigFile) GetContent() string { + return c.Content +} + +// GetVersion 获取配置文件版本号 +func (c *ConfigFile) GetVersion() uint64 { + return c.Version +} + +// GetMd5 获取配置文件MD5值 +func (c *ConfigFile) GetMd5() string { + return c.Md5 +} diff --git a/pkg/plugin/configconnector/config_file_response.go b/pkg/plugin/configconnector/config_file_response.go new file mode 100644 index 00000000..cd9d67e3 --- /dev/null +++ b/pkg/plugin/configconnector/config_file_response.go @@ -0,0 +1,41 @@ +/* + * Tencent is pleased to support the open source community by making polaris-go available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + */ + +package configconnector + +// ConfigFileResponse 配置文件响应体 +type ConfigFileResponse struct { + Code uint32 + Message string + ConfigFile *ConfigFile +} + +// GetCode 获取配置文件响应体code +func (c *ConfigFileResponse) GetCode() uint32 { + return c.Code +} + +// GetMessage 获取配置文件响应体信息 +func (c *ConfigFileResponse) GetMessage() string { + return c.Message +} + +// GetConfigFile 获取配置文件响应体内容 +func (c *ConfigFileResponse) GetConfigFile() *ConfigFile { + return c.ConfigFile +} diff --git a/pkg/plugin/configconnector/proxy.go b/pkg/plugin/configconnector/proxy.go new file mode 100644 index 00000000..573d018a --- /dev/null +++ b/pkg/plugin/configconnector/proxy.go @@ -0,0 +1,52 @@ +/* + * Tencent is pleased to support the open source community by making polaris-go available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + */ + +package configconnector + +import ( + "github.com/polarismesh/polaris-go/pkg/model" + "github.com/polarismesh/polaris-go/pkg/plugin" + "github.com/polarismesh/polaris-go/pkg/plugin/common" +) + +type Proxy struct { + ConfigConnector + engine model.Engine +} + +func (p *Proxy) SetRealPlugin(plugin plugin.Plugin, engine model.Engine) { + p.ConfigConnector = plugin.(ConfigConnector) + p.engine = engine +} + +// GetConfigFile Get config file +func (p *Proxy) GetConfigFile(configFile *ConfigFile) (*ConfigFileResponse, error) { + response, err := p.ConfigConnector.GetConfigFile(configFile) + return response, err +} + +// WatchConfigFiles Watch config files +func (p *Proxy) WatchConfigFiles(configFileList []*ConfigFile) (*ConfigFileResponse, error) { + response, err := p.ConfigConnector.WatchConfigFiles(configFileList) + return response, err +} + +// init 注册proxy +func init() { + plugin.RegisterPluginProxy(common.TypeConfigConnector, &Proxy{}) +} diff --git a/pkg/plugin/register/plugins.go b/pkg/plugin/register/plugins.go index 942e01a9..950351c2 100644 --- a/pkg/plugin/register/plugins.go +++ b/pkg/plugin/register/plugins.go @@ -21,6 +21,7 @@ import ( // 注册插件类型 _ "github.com/polarismesh/polaris-go/pkg/plugin/alarmreporter" _ "github.com/polarismesh/polaris-go/pkg/plugin/circuitbreaker" + _ "github.com/polarismesh/polaris-go/pkg/plugin/configconnector" _ "github.com/polarismesh/polaris-go/pkg/plugin/healthcheck" _ "github.com/polarismesh/polaris-go/pkg/plugin/loadbalancer" _ "github.com/polarismesh/polaris-go/pkg/plugin/localregistry" @@ -36,6 +37,7 @@ import ( _ "github.com/polarismesh/polaris-go/plugin/circuitbreaker/errorcheck" _ "github.com/polarismesh/polaris-go/plugin/circuitbreaker/errorcount" _ "github.com/polarismesh/polaris-go/plugin/circuitbreaker/errorrate" + _ "github.com/polarismesh/polaris-go/plugin/configconnector/polaris" _ "github.com/polarismesh/polaris-go/plugin/healthcheck/http" _ "github.com/polarismesh/polaris-go/plugin/healthcheck/tcp" _ "github.com/polarismesh/polaris-go/plugin/loadbalancer/hash" diff --git a/plugin/configconnector/polaris/config.go b/plugin/configconnector/polaris/config.go new file mode 100644 index 00000000..c1d5f1aa --- /dev/null +++ b/plugin/configconnector/polaris/config.go @@ -0,0 +1,53 @@ +/* + * Tencent is pleased to support the open source community by making polaris-go available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + */ + +package polaris + +import ( + "fmt" + + "github.com/hashicorp/go-multierror" +) + +const ( + // 默认GRPC链路包接收大小 + DefaultMaxCallRecvMsgSize = 50 * 1024 * 1024 + // GRPC链路包接收大小的设置上限 + MaxMaxCallRecvMsgSize = 500 * 1024 * 1024 +) + +// GRPC插件级别配置 +type networkConfig struct { + MaxCallRecvMsgSize int `yaml:"maxCallRecvMsgSize"` +} + +// 校验GRPC配置值 +func (r *networkConfig) Verify() error { + var errs error + if r.MaxCallRecvMsgSize <= 0 || r.MaxCallRecvMsgSize > MaxMaxCallRecvMsgSize { + errs = multierror.Append(errs, fmt.Errorf("grpc.maxCallRecvMsgSize must be int (0, 524288000]")) + } + return errs +} + +// 设置GRPC配置默认值 +func (r *networkConfig) SetDefault() { + if r.MaxCallRecvMsgSize <= 0 { + r.MaxCallRecvMsgSize = DefaultMaxCallRecvMsgSize + } +} diff --git a/plugin/configconnector/polaris/config_connector.go b/plugin/configconnector/polaris/config_connector.go new file mode 100644 index 00000000..5eebe555 --- /dev/null +++ b/plugin/configconnector/polaris/config_connector.go @@ -0,0 +1,265 @@ +/* + * Tencent is pleased to support the open source community by making polaris-go available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + * + */ + +package polaris + +import ( + "context" + "fmt" + "sync/atomic" + "time" + + "google.golang.org/protobuf/types/known/wrapperspb" + + "github.com/polarismesh/polaris-go/pkg/plugin/configconnector" + + "github.com/golang/protobuf/jsonpb" + "github.com/polarismesh/polaris-go/pkg/model/pb" + + connector "github.com/polarismesh/polaris-go/plugin/serverconnector/common" + + "github.com/polarismesh/polaris-go/pkg/clock" + + configpb "github.com/polarismesh/polaris-go/pkg/model/pb/v1" + + "github.com/polarismesh/polaris-go/pkg/config" + + "github.com/polarismesh/polaris-go/pkg/log" + + "github.com/polarismesh/polaris-go/pkg/model" + "github.com/polarismesh/polaris-go/pkg/network" + "github.com/polarismesh/polaris-go/pkg/plugin" + "github.com/polarismesh/polaris-go/pkg/plugin/common" +) + +const ( + // 接收线程获取连接的间隔 + receiveConnInterval = 1 * time.Second +) + +// Connector 使用GRPC协议对接 +type Connector struct { + *plugin.PluginBase + *common.RunContext + // 插件级配置 + cfg *networkConfig + connManager network.ConnectionManager + connectionIdleTimeout time.Duration + valueCtx model.ValueContext + // 有没有打印过connManager ready的信息,用于避免重复打印 + hasPrintedReady uint32 +} + +// Type 插件类型 +func (c *Connector) Type() common.Type { + return common.TypeConfigConnector +} + +// Name 插件名,一个类型下插件名唯一 +func (c *Connector) Name() string { + return "polaris" +} + +// Init 初始化插件 +func (c *Connector) Init(ctx *plugin.InitContext) error { + c.RunContext = common.NewRunContext() + c.PluginBase = plugin.NewPluginBase(ctx) + cfgValue := ctx.Config.GetConfigFile().GetConfigConnectorConfig().GetPluginConfig(c.Name()) + if cfgValue != nil { + c.cfg = cfgValue.(*networkConfig) + } + connManager, err := network.NewConfigConnectionManager(ctx.Config, ctx.ValueCtx) + if err != nil { + return model.NewSDKError(model.ErrCodeAPIInvalidConfig, err, "fail to create config connectionManager") + } else { + c.connManager = connManager + } + c.connectionIdleTimeout = ctx.Config.GetGlobal().GetServerConnector().GetConnectionIdleTimeout() + c.valueCtx = ctx.ValueCtx + protocol := ctx.Config.GetConfigFile().GetConfigConnectorConfig().GetProtocol() + if protocol == c.Name() { + log.GetBaseLogger().Infof("set %s plugin as connectionCreator", c.Name()) + c.connManager.SetConnCreator(c) + } + return nil +} + +// Destroy 销毁插件,可用于释放资源 +func (g *Connector) Destroy() error { + g.RunContext.Destroy() + g.connManager.Destroy() + return nil +} + +// GetConfigFile Get config file +func (c *Connector) GetConfigFile(configFile *configconnector.ConfigFile) (*configconnector.ConfigFileResponse, error) { + var err error + if err = c.waitDiscoverReady(); err != nil { + return nil, err + } + opKey := connector.OpKeyGetConfigFile + startTime := clock.GetClock().Now() + // 获取server连接 + conn, err := c.connManager.GetConnection(opKey, config.ConfigCluster) + if err != nil { + return nil, connector.NetworkError(c.connManager, conn, int32(model.ErrCodeConnectError), err, startTime, + fmt.Sprintf("fail to get connection, opKey %s", opKey)) + } + // 释放server连接 + defer conn.Release(opKey) + configClient := configpb.NewPolarisConfigGRPCClient(network.ToGRPCConn(conn.Conn)) + reqID := connector.NextRegisterInstanceReqID() + ctx, cancel := connector.CreateHeaderContextWithReqId(0, reqID) + if cancel != nil { + defer cancel() + } + // 打印请求报文 + info := transferToClientConfigFileInfo(configFile) + if log.GetBaseLogger().IsLevelEnabled(log.DebugLog) { + reqJson, _ := (&jsonpb.Marshaler{}).MarshalToString(info) + log.GetBaseLogger().Debugf("request to send is %s, opKey %s, connID %s", reqJson, opKey, conn.ConnID) + } + pbResp, err := configClient.GetConfigFile(ctx, info) + return c.handleResponse(info.String(), reqID, opKey, pbResp, err, conn, startTime) +} + +// WatchConfigFiles Watch config files +func (c *Connector) WatchConfigFiles(configFileList []*configconnector.ConfigFile) (*configconnector.ConfigFileResponse, error) { + var err error + if err = c.waitDiscoverReady(); err != nil { + return nil, err + } + opKey := connector.OpKeyWatchConfigFiles + startTime := clock.GetClock().Now() + // 获取server连接 + conn, err := c.connManager.GetConnection(opKey, config.ConfigCluster) + if err != nil { + return nil, connector.NetworkError(c.connManager, conn, int32(model.ErrCodeConnectError), err, startTime, + fmt.Sprintf("fail to get connection, opKey %s", opKey)) + } + // 释放server连接 + defer conn.Release(opKey) + configClient := configpb.NewPolarisConfigGRPCClient(network.ToGRPCConn(conn.Conn)) + reqID := connector.NextWatchConfigFilesReqID() + ctx, cancel := connector.CreateHeaderContextWithReqId(0, reqID) + if cancel != nil { + defer cancel() + } + // 构造request + var configFileInfoList []*configpb.ClientConfigFileInfo + for _, c := range configFileList { + configFileInfoList = append(configFileInfoList, transferToClientConfigFileInfo(c)) + } + request := &configpb.ClientWatchConfigFileRequest{WatchFiles: configFileInfoList} + // 打印请求报文 + if log.GetBaseLogger().IsLevelEnabled(log.DebugLog) { + reqJson, _ := (&jsonpb.Marshaler{}).MarshalToString(request) + log.GetBaseLogger().Debugf("request to send is %s, opKey %s, connID %s", reqJson, opKey, conn.ConnID) + } + pbResp, err := configClient.WatchConfigFiles(ctx, request) + return c.handleResponse(request.String(), reqID, opKey, pbResp, err, conn, startTime) +} + +// IsEnable .插件开关 +func (c *Connector) IsEnable(cfg config.Configuration) bool { + if cfg.GetGlobal().GetSystem().GetMode() == model.ModeWithAgent { + return false + } + return true +} + +// 等待discover就绪 +func (c *Connector) waitDiscoverReady() error { + ctx, cancel := context.WithTimeout(context.Background(), receiveConnInterval/2) + defer cancel() + for { + select { + case <-c.RunContext.Done(): + // connector已经销毁 + return model.NewSDKError(model.ErrCodeInvalidStateError, nil, "SDK context has destroyed") + case <-ctx.Done(): + // 超时 + return nil + default: + if c.connManager.IsReady() && atomic.CompareAndSwapUint32(&c.hasPrintedReady, 0, 1) { + // 准备就绪 + log.GetBaseLogger().Infof("%s, waitDiscover: config service is ready", c.GetSDKContextID()) + return nil + } + time.Sleep(clock.TimeStep()) + } + } +} + +func (c *Connector) handleResponse(request string, reqID string, opKey string, response *configpb.ConfigClientResponse, + err error, conn *network.Connection, startTime time.Time) (*configconnector.ConfigFileResponse, error) { + endTime := clock.GetClock().Now() + if err != nil { + return nil, connector.NetworkError(c.connManager, conn, int32(model.ErrorCodeRpcError), err, startTime, + fmt.Sprintf("fail to %s, request %s, "+ + "reason is fail to send request, reqID %s, server %s", opKey, request, reqID, conn.ConnID)) + } + // 打印应答报文 + if log.GetBaseLogger().IsLevelEnabled(log.DebugLog) { + respJson, _ := (&jsonpb.Marshaler{}).MarshalToString(response) + log.GetBaseLogger().Debugf("response recv is %s, opKey %s, connID %s", respJson, opKey, conn.ConnID) + } + serverCodeType := pb.ConvertServerErrorToRpcError(response.GetCode().GetValue()) + code := response.GetCode().GetValue() + //预期code,正常响应 + if code == configpb.ExecuteSuccess || code == configpb.NotFoundResource || code == configpb.DataNoChange { + c.connManager.ReportSuccess(conn.ConnID, int32(serverCodeType), endTime.Sub(startTime)) + return &configconnector.ConfigFileResponse{ + Code: response.GetCode().GetValue(), + Message: response.GetInfo().GetValue(), + ConfigFile: transferFromClientConfigFileInfo(response.GetConfigFile()), + }, nil + } else { + // 当server发生了内部错误时,上报调用服务失败 + errMsg := fmt.Sprintf( + "fail to %s, request %s, server code %d, reason %s, server %s", opKey, + request, response.GetCode().GetValue(), response.GetInfo().GetValue(), conn.ConnID) + c.connManager.ReportFail(conn.ConnID, int32(model.ErrCodeServerError), endTime.Sub(startTime)) + return nil, model.NewSDKError(model.ErrCodeServerException, nil, errMsg) + } +} + +func transferToClientConfigFileInfo(configFile *configconnector.ConfigFile) *configpb.ClientConfigFileInfo { + return &configpb.ClientConfigFileInfo{ + Namespace: wrapperspb.String(configFile.Namespace), + Group: wrapperspb.String(configFile.GetFileGroup()), + FileName: wrapperspb.String(configFile.GetFileName()), + Version: wrapperspb.UInt64(configFile.GetVersion()), + } +} + +func transferFromClientConfigFileInfo(configFileInfo *configpb.ClientConfigFileInfo) *configconnector.ConfigFile { + return &configconnector.ConfigFile{ + Namespace: configFileInfo.GetNamespace().GetValue(), + FileGroup: configFileInfo.GetGroup().GetValue(), + FileName: configFileInfo.GetFileName().GetValue(), + Content: configFileInfo.GetContent().GetValue(), + Version: configFileInfo.GetVersion().GetValue(), + Md5: configFileInfo.GetMd5().GetValue(), + } +} + +// init 注册插件信息 +func init() { + plugin.RegisterConfigurablePlugin(&Connector{}, &networkConfig{}) +} diff --git a/plugin/configconnector/polaris/creator.go b/plugin/configconnector/polaris/creator.go new file mode 100644 index 00000000..93707320 --- /dev/null +++ b/plugin/configconnector/polaris/creator.go @@ -0,0 +1,94 @@ +/** + * Tencent is pleased to support the open source community by making polaris-go available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package polaris + +import ( + "context" + "strings" + "time" + + "google.golang.org/grpc" + "google.golang.org/grpc/stats" + + "github.com/polarismesh/polaris-go/pkg/log" + "github.com/polarismesh/polaris-go/pkg/model" + "github.com/polarismesh/polaris-go/pkg/network" +) + +// 创建连接 +func (g *Connector) CreateConnection( + address string, timeout time.Duration, clientInfo *network.ClientInfo) (network.ClosableConn, error) { + var opts []grpc.DialOption + opts = append(opts, grpc.WithInsecure()) + opts = append(opts, grpc.WithBlock()) + localIPValue := clientInfo.GetIPString() + if len(localIPValue) == 0 { + opts = append(opts, grpc.WithStatsHandler(&statHandler{clientInfo: clientInfo})) + } + log.GetBaseLogger().Debugf("create connection with maxCallRecvSize %d", g.cfg.MaxCallRecvMsgSize) + opts = append(opts, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(g.cfg.MaxCallRecvMsgSize))) + ctx, cancel := context.WithTimeout(context.Background(), timeout) + defer cancel() + conn, err := grpc.DialContext(ctx, address, opts...) + if err != nil { + return nil, err + } + return conn, nil +} + +// Handler defines the interface for the related stats handling (e.g., RPCs, connections). +type statHandler struct { + // 全局上下文 + clientInfo *network.ClientInfo +} + +// TagRPC can attach some information to the given context. +// The context used for the rest lifetime of the RPC will be derived from +// the returned context. +func (s *statHandler) TagRPC(ctx context.Context, info *stats.RPCTagInfo) context.Context { + return ctx +} + +// HandleRPC processes the RPC stats. +func (s *statHandler) HandleRPC(context.Context, stats.RPCStats) { + +} + +// TagConn can attach some information to the given context. +// The returned context will be used for stats handling. +// For conn stats handling, the context used in HandleConn for this +// connection will be derived from the context returned. +// For RPC stats handling, +// - On server side, the context used in HandleRPC for all RPCs on this +// connection will be derived from the context returned. +// - On client side, the context is not derived from the context returned. +func (s *statHandler) TagConn(ctx context.Context, info *stats.ConnTagInfo) context.Context { + localAddr := info.LocalAddr.String() + localIP := strings.Split(localAddr, ":")[0] + hashValue, _ := model.HashStr(localIP) + log.GetBaseLogger().Infof( + "localAddress from connection is %s, IP is %s, hashValue is %d", localAddr, localIP, hashValue) + s.clientInfo.IP.Store(localIP) + s.clientInfo.HashKey.Store([]byte(localAddr)) + return ctx +} + +// HandleConn processes the Conn stats. +func (s *statHandler) HandleConn(context.Context, stats.ConnStats) { + +} diff --git a/plugin/serverconnector/common/util.go b/plugin/serverconnector/common/util.go index abeac81a..9e9bad04 100644 --- a/plugin/serverconnector/common/util.go +++ b/plugin/serverconnector/common/util.go @@ -47,6 +47,8 @@ const ( reqIDPrefixReportClient reqIDPrefixRateLimitInit reqIDPrefixRateLimitAcquire + reqIDPrefixGetConfigFile + reqIDPrefixWatchConfigFiles ) const ( @@ -59,6 +61,8 @@ const ( OpKeyRateLimitAcquire = "RateLimitAcquire" OpKeyRateLimitMetricInit = "RateLimitMetricInit" OpKeyRateLimitMetricReport = "RateLimitMetricReport" + OpKeyGetConfigFile = "GetConfigFile" + OpKeyWatchConfigFiles = "WatchConfigFiles" ) // 生成GetInstances调用的请求Id @@ -96,6 +100,16 @@ func NextRateLimitAcquireReqID() string { return fmt.Sprintf("%d%d", reqIDPrefixRateLimitAcquire, uuid.New().ID()) } +// 生成GetConfigFile调用的请求Id +func NextGetConfigFileReqID() string { + return fmt.Sprintf("%d%d", reqIDPrefixGetConfigFile, uuid.New().ID()) +} + +// 生成WatchConfigFiles调用的请求Id +func NextWatchConfigFilesReqID() string { + return fmt.Sprintf("%d%d", reqIDPrefixWatchConfigFiles, uuid.New().ID()) +} + // 获取连接错误码 func GetConnErrorCode(err error) int32 { code, ok := status.FromError(err) diff --git a/polaris.yaml b/polaris.yaml index 59b97e68..9031a73b 100644 --- a/polaris.yaml +++ b/polaris.yaml @@ -298,4 +298,31 @@ consumer: type: subscribeLocalChannel plugin: subscribeLocalChannel: - channelBufferSize: 50 \ No newline at end of file + channelBufferSize: 50 +# 配置中心默认配置 +config: + # 类型转化缓存的key数量 + propertiesValueCacheSize: 100 + # 类型转化缓存的过期时间,默认为1分钟 + propertiesValueExpireTime: 60000 + # 连接器配置,默认为北极星服务端 + configConnector: + id: polaris-config + connectorType: polaris + #描述: 访问server的连接协议,SDK会根据协议名称会加载对应的插件 + protocol: polaris + #描述: 发起连接后的连接超时时间 + connectTimeout: 500ms + #描述: 与服务端发起远程请求超时时间 + messageTimeout: 5s + #描述: 连接空闲时间(以最后一次消息交互时间来算),长连接模式下,当连接空闲超过一定时间后,SDK会主动释放连接 + connectionIdleTimeout: 60s + #描述: server节点的切换周期,为了使得server的压力能够均衡,SDK会定期切换目标服务端节点 + serverSwitchInterval: 10m + #描述:重连间隔时间 + reconnectInterval: 500ms + polaris: + #描述:GRPC客户端单次最大链路接收报文 + #类型:int + #范围:(0:524288000] + maxCallRecvMsgSize: 52428800 From c6f6c471284a7a5f4451d871afe8e373030255e3 Mon Sep 17 00:00:00 2001 From: lepdou Date: Sat, 7 May 2022 16:10:03 +0800 Subject: [PATCH 2/2] add ConfigAPI --- api.go | 11 ++++ api/config_file.go | 4 +- api/config_file_impl.go | 8 +++ api_config.go | 78 ++++++++++++++++++++++++++++ examples/configuration/main.go | 6 +-- examples/quickstart/consumer/main.go | 2 +- 6 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 api_config.go diff --git a/api.go b/api.go index c6d91289..f4ee05e2 100644 --- a/api.go +++ b/api.go @@ -105,3 +105,14 @@ type LimitAPI interface { func NewQuotaRequest() QuotaRequest { return &model.QuotaRequestImpl{} } + +//config + +type ConfigFile model.ConfigFile + +// ConfigAPI 配置文件的 API +type ConfigAPI interface { + api.SDKOwner + // GetConfigFile 获取配置文件 + GetConfigFile(namespace, fileGroup, fileName string) (ConfigFile, error) +} diff --git a/api/config_file.go b/api/config_file.go index f63a52e1..b3306192 100644 --- a/api/config_file.go +++ b/api/config_file.go @@ -30,7 +30,9 @@ var ( // NewConfigFileAPIBySDKContext 通过 SDKContext 创建 ConfigFileAPI NewConfigFileAPIBySDKContext = newConfigFileAPIBySDKContext // NewConfigFileAPI 通过 polaris.yaml 创建 ConfigFileAPI - NewConfigFileAPI = newConfigFileAPI + NewConfigFileAPI = newConfigFileAPI // NewConfigFileAPIByConfig 通过 Configuration 创建 ConfigFileAPI NewConfigFileAPIByConfig = newConfigFileAPIByConfig + // NewConfigFileAPIByFile 通过配置文件创建 ConfigFileAPI + NewConfigFileAPIByFile = newConfigFileAPIByFile ) diff --git a/api/config_file_impl.go b/api/config_file_impl.go index 0fe539e7..8c3f20bf 100644 --- a/api/config_file_impl.go +++ b/api/config_file_impl.go @@ -38,6 +38,14 @@ func newConfigFileAPIByConfig(cfg config.Configuration) (ConfigFileAPI, error) { return &configFileAPI{context}, nil } +func newConfigFileAPIByFile(path string) (ConfigFileAPI, error) { + context, err := InitContextByFile(path) + if err != nil { + return nil, err + } + return &configFileAPI{context}, nil +} + func newConfigFileAPIBySDKContext(context SDKContext) ConfigFileAPI { return &configFileAPI{ context: context, diff --git a/api_config.go b/api_config.go new file mode 100644 index 00000000..a52d9a2d --- /dev/null +++ b/api_config.go @@ -0,0 +1,78 @@ +/** + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package polaris + +import ( + "github.com/polarismesh/polaris-go/api" + "github.com/polarismesh/polaris-go/pkg/config" +) + +type configAPI struct { + rawAPI api.ConfigFileAPI +} + +// NewConfigAPI 获取配置中心 API +func NewConfigAPI() (ConfigAPI, error) { + rawAPI, err := api.NewConfigFileAPI() + if err != nil { + return nil, err + } + return &configAPI{ + rawAPI: rawAPI, + }, nil +} + +// NewConfigAPIByConfig 通过配置对象获取配置中心 API +func NewConfigAPIByConfig(cfg config.Configuration) (ConfigAPI, error) { + rawAPI, err := api.NewConfigFileAPIByConfig(cfg) + if err != nil { + return nil, err + } + return &configAPI{ + rawAPI: rawAPI, + }, nil +} + +// NewConfigAPIByFile 通过配置文件获取配置中心 API +func NewConfigAPIByFile(path string) (ConfigAPI, error) { + rawAPI, err := api.NewConfigFileAPIByFile(path) + if err != nil { + return nil, err + } + return &configAPI{ + rawAPI: rawAPI, + }, nil +} + +// NewConfigAPIByContext 通过上下文对象获取配置中心 API +func NewConfigAPIByContext(context api.SDKContext) ConfigAPI { + rawAPI := api.NewConfigFileAPIBySDKContext(context) + return &configAPI{ + rawAPI: rawAPI, + } +} + +// GetConfigFile 获取配置文件 +func (c *configAPI) GetConfigFile(namespace, fileGroup, fileName string) (ConfigFile, error) { + return c.rawAPI.GetConfigFile(namespace, fileGroup, fileName) +} + +// SDKContext 获取SDK上下文 +func (c *configAPI) SDKContext() api.SDKContext { + return c.rawAPI.SDKContext() +} diff --git a/examples/configuration/main.go b/examples/configuration/main.go index 83c77fae..6d24a1ee 100644 --- a/examples/configuration/main.go +++ b/examples/configuration/main.go @@ -19,12 +19,12 @@ package main import ( "fmt" - "github.com/polarismesh/polaris-go/api" + "github.com/polarismesh/polaris-go" "github.com/polarismesh/polaris-go/pkg/model" ) func main() { - configFileAPI, err := api.NewConfigFileAPI() + configAPI, err := polaris.NewConfigAPI() if err != nil { fmt.Println("fail to start example.", err) @@ -36,7 +36,7 @@ func main() { fileGroup := "polaris-config-example" fileName := "example.yaml" - configFile, err := configFileAPI.GetConfigFile(namespace, fileGroup, fileName) + configFile, err := configAPI.GetConfigFile(namespace, fileGroup, fileName) if err != nil { fmt.Println("fail to get config.", err) return diff --git a/examples/quickstart/consumer/main.go b/examples/quickstart/consumer/main.go index dfb5aa65..7770e733 100644 --- a/examples/quickstart/consumer/main.go +++ b/examples/quickstart/consumer/main.go @@ -78,7 +78,7 @@ func (svr *PolarisConsumer) runWebServer() { _, _ = rw.Write([]byte(fmt.Sprintf("[errot] send request to %s:%d fail : %s", instance.GetHost(), instance.GetPort(), err))) return } - delay := time.Now().Add(time.Duration(10 * time.Second)).Sub(start) + delay := time.Now().Sub(start) ret := &polaris.ServiceCallResult{ ServiceCallResult: model.ServiceCallResult{