Documentation ¶
Index ¶
- Constants
- func Initialize(ctx context.Context, config Config, s store.Store, ...) error
- func NewConfigConnManager(ctx context.Context, watchCenter *watchCenter) *connManager
- func NewWatchCenter(eventCenter *Center) *watchCenter
- type Callback
- type Center
- type Config
- type ConfigCenterServer
- type ConfigFileClientOperate
- type ConfigFileGroupOperate
- type ConfigFileOperate
- type ConfigFileReleaseHistoryOperate
- type ConfigFileReleaseOperate
- type ConfigFileTemplateOperate
- type Event
- type FileReleaseCallback
- type ResourceEvent
- type ResourceHook
- type Server
- func (s *Server) BatchDeleteConfigFile(ctx context.Context, configFiles []*api.ConfigFile, operator string) *api.ConfigResponse
- func (s *Server) Cache() cache.FileCache
- func (s *Server) ConnManager() *connManager
- func (s *Server) CreateConfigFile(ctx context.Context, configFile *api.ConfigFile) *api.ConfigResponse
- func (s *Server) CreateConfigFileGroup(ctx context.Context, configFileGroup *api.ConfigFileGroup) *api.ConfigResponse
- func (s *Server) CreateConfigFileTemplate(ctx context.Context, template *api.ConfigFileTemplate) *api.ConfigResponse
- func (s *Server) DeleteConfigFile(ctx context.Context, namespace, group, name, deleteBy string) *api.ConfigResponse
- func (s *Server) DeleteConfigFileGroup(ctx context.Context, namespace, name string) *api.ConfigResponse
- func (s *Server) DeleteConfigFileRelease(ctx context.Context, namespace, group, fileName, deleteBy string) *api.ConfigResponse
- func (s *Server) GetAllConfigFileTemplates(ctx context.Context) *api.ConfigBatchQueryResponse
- func (s *Server) GetConfigFileBaseInfo(ctx context.Context, namespace, group, name string) *api.ConfigResponse
- func (s *Server) GetConfigFileForClient(ctx context.Context, client *api.ClientConfigFileInfo) *api.ConfigClientResponse
- func (s *Server) GetConfigFileLatestReleaseHistory(ctx context.Context, namespace, group, fileName string) *api.ConfigResponse
- func (s *Server) GetConfigFileRelease(ctx context.Context, namespace, group, fileName string) *api.ConfigResponse
- func (s *Server) GetConfigFileReleaseHistory(ctx context.Context, namespace, group, fileName string, offset, limit uint32, ...) *api.ConfigBatchQueryResponse
- func (s *Server) GetConfigFileRichInfo(ctx context.Context, namespace, group, name string) *api.ConfigResponse
- func (s *Server) GetConfigFileTemplate(ctx context.Context, name string) *api.ConfigResponse
- func (s *Server) PublishConfigFile(ctx context.Context, configFileRelease *api.ConfigFileRelease) *api.ConfigResponse
- func (s *Server) QueryConfigFileGroups(ctx context.Context, namespace, groupName, fileName string, ...) *api.ConfigBatchQueryResponse
- func (s *Server) QueryConfigFilesByGroup(ctx context.Context, namespace, group string, offset, limit uint32) *api.ConfigBatchQueryResponse
- func (s *Server) SearchConfigFile(ctx context.Context, namespace, group, name, tags string, offset, limit uint32) *api.ConfigBatchQueryResponse
- func (s *Server) SetResourceHooks(hooks ...ResourceHook)
- func (s *Server) StartTxAndSetToContext(ctx context.Context) (store.Tx, context.Context, error)
- func (s *Server) UpdateConfigFile(ctx context.Context, configFile *api.ConfigFile) *api.ConfigResponse
- func (s *Server) UpdateConfigFileGroup(ctx context.Context, configFileGroup *api.ConfigFileGroup) *api.ConfigResponse
- func (s *Server) WatchCenter() *watchCenter
- func (s *Server) WatchConfigFiles(ctx context.Context, request *api.ClientWatchConfigFileRequest) (WatchCallback, error)
- type WatchCallback
Constants ¶
const ( DefaultScanTimeOffset = -10 * time.Second FirstScanTimeOffset = -time.Minute * 10 MessageExpireTime = -5 * time.Second )
const (
ContextTxKey = utils.StringContext("Config-Tx")
)
const (
// MaxPageSize 最大分页大小
MaxPageSize = 100
)
const (
QueueSize = 10240
)
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶
func Initialize(ctx context.Context, config Config, s store.Store, cacheMgn *cache.CacheManager, namespaceOperator namespace.NamespaceOperateServer, authSvr auth.AuthServer) error
Initialize 初始化配置中心模块
func NewConfigConnManager ¶
NewConfigConnManager 初始化连接管理器,定时响应超时的请求
func NewWatchCenter ¶
func NewWatchCenter(eventCenter *Center) *watchCenter
NewWatchCenter 创建一个客户端监听配置发布的处理中心
Types ¶
type Center ¶
type Center struct {
// contains filtered or unexported fields
}
Center 事件中心
func (*Center) WatchEvent ¶
WatchEvent 监听事件
type ConfigCenterServer ¶
type ConfigCenterServer interface { ConfigFileGroupOperate ConfigFileOperate ConfigFileReleaseOperate ConfigFileReleaseHistoryOperate ConfigFileClientOperate ConfigFileTemplateOperate }
ConfigCenterServer 配置中心server
type ConfigFileClientOperate ¶
type ConfigFileClientOperate interface { // GetConfigFileForClient 获取配置文件 GetConfigFileForClient(ctx context.Context, configFile *api.ClientConfigFileInfo) *api.ConfigClientResponse // WatchConfigFiles 客户端监听配置文件 WatchConfigFiles(ctx context.Context, request *api.ClientWatchConfigFileRequest) (WatchCallback, error) }
ConfigFileClientAPI 给客户端提供服务接口,不同的上层协议抽象的公共服务逻辑
type ConfigFileGroupOperate ¶
type ConfigFileGroupOperate interface { // CreateConfigFileGroup 创建配置文件组 CreateConfigFileGroup(ctx context.Context, configFileGroup *api.ConfigFileGroup) *api.ConfigResponse // QueryConfigFileGroups 查询配置文件组, namespace 为完全匹配,groupName 为模糊匹配, fileName 为模糊匹配文件名 QueryConfigFileGroups(ctx context.Context, namespace, groupName, fileName string, offset, limit uint32) *api.ConfigBatchQueryResponse // DeleteConfigFileGroup 删除配置文件组 DeleteConfigFileGroup(ctx context.Context, namespace, name string) *api.ConfigResponse // UpdateConfigFileGroup 更新配置文件组 UpdateConfigFileGroup(ctx context.Context, configFileGroup *api.ConfigFileGroup) *api.ConfigResponse }
ConfigFileGroupOperate 配置文件组接口
type ConfigFileOperate ¶
type ConfigFileOperate interface { // CreateConfigFile 创建配置文件 CreateConfigFile(ctx context.Context, configFile *api.ConfigFile) *api.ConfigResponse // GetConfigFileBaseInfo 获取单个配置文件基础信息,不包含发布信息 GetConfigFileBaseInfo(ctx context.Context, namespace, group, name string) *api.ConfigResponse // GetConfigFileRichInfo 获取单个配置文件基础信息,包含发布状态等信息 GetConfigFileRichInfo(ctx context.Context, namespace, group, name string) *api.ConfigResponse // QueryConfigFilesByGroup query file group's config file QueryConfigFilesByGroup(ctx context.Context, namespace, group string, offset, limit uint32) *api.ConfigBatchQueryResponse // SearchConfigFile 按 group 和 name 模糊搜索配置文件 SearchConfigFile(ctx context.Context, namespace, group, name, tags string, offset, limit uint32) *api.ConfigBatchQueryResponse // UpdateConfigFile 更新配置文件 UpdateConfigFile(ctx context.Context, configFile *api.ConfigFile) *api.ConfigResponse // DeleteConfigFile 删除配置文件 DeleteConfigFile(ctx context.Context, namespace, group, name, deleteBy string) *api.ConfigResponse // BatchDeleteConfigFile 批量删除配置文件 BatchDeleteConfigFile(ctx context.Context, configFiles []*api.ConfigFile, operator string) *api.ConfigResponse }
ConfigFileOperate 配置文件接口
type ConfigFileReleaseHistoryOperate ¶
type ConfigFileReleaseHistoryOperate interface { // GetConfigFileReleaseHistory 获取配置文件的发布历史 GetConfigFileReleaseHistory(ctx context.Context, namespace, group, fileName string, offset, limit uint32, endId uint64) *api.ConfigBatchQueryResponse // GetConfigFileLatestReleaseHistory 获取最后一次发布记录 GetConfigFileLatestReleaseHistory(ctx context.Context, namespace, group, fileName string) *api.ConfigResponse }
ConfigFileReleaseHistoryOperate 配置文件发布历史接口
type ConfigFileReleaseOperate ¶
type ConfigFileReleaseOperate interface { // PublishConfigFile 发布配置文件 PublishConfigFile(ctx context.Context, configFileRelease *api.ConfigFileRelease) *api.ConfigResponse // GetConfigFileRelease 获取配置文件发布 GetConfigFileRelease(ctx context.Context, namespace, group, fileName string) *api.ConfigResponse // DeleteConfigFileRelease 删除配置文件发布内容 DeleteConfigFileRelease(ctx context.Context, namespace, group, fileName, deleteBy string) *api.ConfigResponse }
ConfigFileReleaseOperate 配置文件发布接口
type ConfigFileTemplateOperate ¶
type ConfigFileTemplateOperate interface { // GetAllConfigFileTemplates get all config file templates GetAllConfigFileTemplates(ctx context.Context) *api.ConfigBatchQueryResponse // CreateConfigFileTemplate create config file template CreateConfigFileTemplate(ctx context.Context, template *api.ConfigFileTemplate) *api.ConfigResponse // GetConfigFileTemplate get config file template GetConfigFileTemplate(ctx context.Context, name string) *api.ConfigResponse }
ConfigFileTemplateOperate config file template operate
type FileReleaseCallback ¶
type FileReleaseCallback func(clientId string, rsp *api.ConfigClientResponse) bool
type ResourceEvent ¶
type ResourceEvent struct {
ConfigGroup *api.ConfigFileGroup
}
ResourceEvent 资源事件
type ResourceHook ¶
type ResourceHook interface { // Before // @param ctx // @param resourceType Before(ctx context.Context, resourceType model.Resource) // After // @param ctx // @param resourceType // @param res After(ctx context.Context, resourceType model.Resource, res *ResourceEvent) error }
ResourceHook The listener is placed before and after the resource operation, only normal flow
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server 配置中心核心服务
func GetOriginServer ¶
func (*Server) BatchDeleteConfigFile ¶
func (s *Server) BatchDeleteConfigFile(ctx context.Context, configFiles []*api.ConfigFile, operator string) *api.ConfigResponse
BatchDeleteConfigFile 批量删除配置文件
func (*Server) CreateConfigFile ¶
func (s *Server) CreateConfigFile(ctx context.Context, configFile *api.ConfigFile) *api.ConfigResponse
CreateConfigFile 创建配置文件
func (*Server) CreateConfigFileGroup ¶
func (s *Server) CreateConfigFileGroup(ctx context.Context, configFileGroup *api.ConfigFileGroup) *api.ConfigResponse
CreateConfigFileGroup 创建配置文件组
func (*Server) CreateConfigFileTemplate ¶
func (s *Server) CreateConfigFileTemplate(ctx context.Context, template *api.ConfigFileTemplate) *api.ConfigResponse
CreateConfigFileTemplate create config file template
func (*Server) DeleteConfigFile ¶
func (s *Server) DeleteConfigFile(ctx context.Context, namespace, group, name, deleteBy string) *api.ConfigResponse
DeleteConfigFile 删除配置文件,删除配置文件同时会通知客户端 Not_Found
func (*Server) DeleteConfigFileGroup ¶
func (s *Server) DeleteConfigFileGroup(ctx context.Context, namespace, name string) *api.ConfigResponse
DeleteConfigFileGroup 删除配置文件组
func (*Server) DeleteConfigFileRelease ¶
func (s *Server) DeleteConfigFileRelease(ctx context.Context, namespace, group, fileName, deleteBy string) *api.ConfigResponse
DeleteConfigFileRelease 删除配置文件发布,删除配置文件的时候,同步删除配置文件发布数据
func (*Server) GetAllConfigFileTemplates ¶
func (s *Server) GetAllConfigFileTemplates(ctx context.Context) *api.ConfigBatchQueryResponse
GetAllConfigFileTemplates get all config file templates
func (*Server) GetConfigFileBaseInfo ¶
func (s *Server) GetConfigFileBaseInfo(ctx context.Context, namespace, group, name string) *api.ConfigResponse
GetConfigFileBaseInfo 获取配置文件,只返回基础元信息
func (*Server) GetConfigFileForClient ¶
func (s *Server) GetConfigFileForClient(ctx context.Context, client *api.ClientConfigFileInfo) *api.ConfigClientResponse
GetConfigFileForClient 从缓存中获取配置文件,如果客户端的版本号大于服务端,则服务端重新加载缓存
func (*Server) GetConfigFileLatestReleaseHistory ¶
func (s *Server) GetConfigFileLatestReleaseHistory(ctx context.Context, namespace, group, fileName string) *api.ConfigResponse
GetConfigFileLatestReleaseHistory 获取配置文件最后一次发布记录
func (*Server) GetConfigFileRelease ¶
func (s *Server) GetConfigFileRelease(ctx context.Context, namespace, group, fileName string) *api.ConfigResponse
GetConfigFileRelease 获取配置文件发布内容
func (*Server) GetConfigFileReleaseHistory ¶
func (s *Server) GetConfigFileReleaseHistory(ctx context.Context, namespace, group, fileName string, offset, limit uint32, endId uint64) *api.ConfigBatchQueryResponse
GetConfigFileReleaseHistory 获取配置文件发布历史记录
func (*Server) GetConfigFileRichInfo ¶
func (s *Server) GetConfigFileRichInfo(ctx context.Context, namespace, group, name string) *api.ConfigResponse
GetConfigFileRichInfo 获取单个配置文件基础信息,包含发布状态等信息
func (*Server) GetConfigFileTemplate ¶
GetConfigFileTemplate get config file template by name
func (*Server) PublishConfigFile ¶
func (s *Server) PublishConfigFile(ctx context.Context, configFileRelease *api.ConfigFileRelease) *api.ConfigResponse
PublishConfigFile 发布配置文件
func (*Server) QueryConfigFileGroups ¶
func (s *Server) QueryConfigFileGroups(ctx context.Context, namespace, groupName, fileName string, offset, limit uint32) *api.ConfigBatchQueryResponse
QueryConfigFileGroups 查询配置文件组
func (*Server) QueryConfigFilesByGroup ¶
func (s *Server) QueryConfigFilesByGroup(ctx context.Context, namespace, group string, offset, limit uint32) *api.ConfigBatchQueryResponse
QueryConfigFilesByGroup querying configuration files
func (*Server) SearchConfigFile ¶
func (s *Server) SearchConfigFile(ctx context.Context, namespace, group, name, tags string, offset, limit uint32) *api.ConfigBatchQueryResponse
SearchConfigFile 查询配置文件
func (*Server) SetResourceHooks ¶
func (s *Server) SetResourceHooks(hooks ...ResourceHook)
SetResourceHooks 设置资源钩子
func (*Server) StartTxAndSetToContext ¶
StartTxAndSetToContext 开启一个事务,并放入到上下文里
func (*Server) UpdateConfigFile ¶
func (s *Server) UpdateConfigFile(ctx context.Context, configFile *api.ConfigFile) *api.ConfigResponse
UpdateConfigFile 更新配置文件
func (*Server) UpdateConfigFileGroup ¶
func (s *Server) UpdateConfigFileGroup(ctx context.Context, configFileGroup *api.ConfigFileGroup) *api.ConfigResponse
UpdateConfigFileGroup 更新配置文件组
func (*Server) WatchConfigFiles ¶
func (s *Server) WatchConfigFiles(ctx context.Context, request *api.ClientWatchConfigFileRequest) (WatchCallback, error)
Source Files ¶
- api.go
- client_config_file.go
- client_config_file_authibility.go
- common.go
- config_file.go
- config_file_authibility.go
- config_file_group.go
- config_file_group_authibility.go
- config_file_release.go
- config_file_release_authibility.go
- config_file_release_history.go
- config_file_release_history_authibility.go
- config_file_tag.go
- config_file_template.go
- config_file_template_authibility.go
- connection_manager.go
- event.go
- log.go
- resource_listener.go
- scanner.go
- server.go
- server_authability.go
- watcher.go