config

package
v1.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 4, 2023 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultScanTimeOffset = -10 * time.Second
	FirstScanTimeOffset   = -time.Minute * 10
	MessageExpireTime     = -5 * time.Second
)
View Source
const (
	ContextTxKey = utils.StringContext("Config-Tx")
)
View Source
const (
	// MaxPageSize 最大分页大小
	MaxPageSize = 100
)
View Source
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

func NewConfigConnManager(ctx context.Context, watchCenter *watchCenter) *connManager

NewConfigConnManager 初始化连接管理器,定时响应超时的请求

func NewWatchCenter

func NewWatchCenter(eventCenter *Center) *watchCenter

NewWatchCenter 创建一个客户端监听配置发布的处理中心

Types

type Callback

type Callback func(event Event) bool

Callback 事件回调

type Center

type Center struct {
	// contains filtered or unexported fields
}

Center 事件中心

func NewEventCenter

func NewEventCenter() *Center

NewEventCenter 新建事件中心

func (*Center) WatchEvent

func (c *Center) WatchEvent(eventType string, cb Callback)

WatchEvent 监听事件

type Config

type Config struct {
	Open  bool                   `yaml:"open"`
	Cache map[string]interface{} `yaml:"cache"`
}

Config 配置中心模块启动参数

type ConfigCenterServer

ConfigCenterServer 配置中心server

func GetServer

func GetServer() (ConfigCenterServer, error)

GetServer 获取已经初始化好的ConfigServer

type ConfigFileClientOperate

type ConfigFileClientOperate interface {
	// GetConfigFileForClient 获取配置文件
	GetConfigFileForClient(ctx context.Context, configFile *apiconfig.ClientConfigFileInfo) *apiconfig.ConfigClientResponse

	// WatchConfigFiles 客户端监听配置文件
	WatchConfigFiles(ctx context.Context, request *apiconfig.ClientWatchConfigFileRequest) (WatchCallback, error)
}

ConfigFileClientOperate 给客户端提供服务接口,不同的上层协议抽象的公共服务逻辑

type ConfigFileGroupOperate

type ConfigFileGroupOperate interface {
	// CreateConfigFileGroup 创建配置文件组
	CreateConfigFileGroup(ctx context.Context, configFileGroup *apiconfig.ConfigFileGroup) *apiconfig.ConfigResponse

	// QueryConfigFileGroups 查询配置文件组, namespace 为完全匹配,groupName 为模糊匹配, fileName 为模糊匹配文件名
	QueryConfigFileGroups(ctx context.Context,
		namespace, groupName, fileName string, offset, limit uint32) *apiconfig.ConfigBatchQueryResponse

	// DeleteConfigFileGroup 删除配置文件组
	DeleteConfigFileGroup(ctx context.Context, namespace, name string) *apiconfig.ConfigResponse

	// UpdateConfigFileGroup 更新配置文件组
	UpdateConfigFileGroup(ctx context.Context, configFileGroup *apiconfig.ConfigFileGroup) *apiconfig.ConfigResponse
}

ConfigFileGroupOperate 配置文件组接口

type ConfigFileOperate

type ConfigFileOperate interface {
	// CreateConfigFile 创建配置文件
	CreateConfigFile(ctx context.Context, configFile *apiconfig.ConfigFile) *apiconfig.ConfigResponse

	// GetConfigFileBaseInfo 获取单个配置文件基础信息,不包含发布信息
	GetConfigFileBaseInfo(ctx context.Context, namespace, group, name string) *apiconfig.ConfigResponse

	// GetConfigFileRichInfo 获取单个配置文件基础信息,包含发布状态等信息
	GetConfigFileRichInfo(ctx context.Context, namespace, group, name string) *apiconfig.ConfigResponse

	// QueryConfigFilesByGroup query file group's config file
	QueryConfigFilesByGroup(ctx context.Context,
		namespace, group string, offset, limit uint32) *apiconfig.ConfigBatchQueryResponse

	// SearchConfigFile 按 group 和 name 模糊搜索配置文件
	SearchConfigFile(ctx context.Context,
		namespace, group, name, tags string, offset, limit uint32) *apiconfig.ConfigBatchQueryResponse

	// UpdateConfigFile 更新配置文件
	UpdateConfigFile(ctx context.Context, configFile *apiconfig.ConfigFile) *apiconfig.ConfigResponse

	// DeleteConfigFile 删除配置文件
	DeleteConfigFile(ctx context.Context, namespace, group, name, deleteBy string) *apiconfig.ConfigResponse

	// BatchDeleteConfigFile 批量删除配置文件
	BatchDeleteConfigFile(ctx context.Context,
		configFiles []*apiconfig.ConfigFile, operator string) *apiconfig.ConfigResponse

	// ExportConfigFile 导出配置文件
	ExportConfigFile(ctx context.Context,
		configFileExport *apiconfig.ConfigFileExportRequest) *apiconfig.ConfigExportResponse

	// ImportConfigFile 导入配置文件
	ImportConfigFile(ctx context.Context,
		configFiles []*apiconfig.ConfigFile, conflictHandling string) *apiconfig.ConfigImportResponse
}

ConfigFileOperate 配置文件接口

type ConfigFileReleaseHistoryOperate

type ConfigFileReleaseHistoryOperate interface {
	// GetConfigFileReleaseHistory 获取配置文件的发布历史
	GetConfigFileReleaseHistory(ctx context.Context,
		namespace, group, fileName string, offset, limit uint32, endId uint64) *apiconfig.ConfigBatchQueryResponse

	// GetConfigFileLatestReleaseHistory 获取最后一次发布记录
	GetConfigFileLatestReleaseHistory(ctx context.Context, namespace, group, fileName string) *apiconfig.ConfigResponse
}

ConfigFileReleaseHistoryOperate 配置文件发布历史接口

type ConfigFileReleaseOperate

type ConfigFileReleaseOperate interface {
	// PublishConfigFile 发布配置文件
	PublishConfigFile(ctx context.Context, configFileRelease *apiconfig.ConfigFileRelease) *apiconfig.ConfigResponse

	// GetConfigFileRelease 获取配置文件发布
	GetConfigFileRelease(ctx context.Context, namespace, group, fileName string) *apiconfig.ConfigResponse

	// DeleteConfigFileRelease 删除配置文件发布内容
	DeleteConfigFileRelease(ctx context.Context, namespace, group, fileName, deleteBy string) *apiconfig.ConfigResponse
}

ConfigFileReleaseOperate 配置文件发布接口

type ConfigFileTemplateOperate

type ConfigFileTemplateOperate interface {
	// GetAllConfigFileTemplates get all config file templates
	GetAllConfigFileTemplates(ctx context.Context) *apiconfig.ConfigBatchQueryResponse

	// CreateConfigFileTemplate create config file template
	CreateConfigFileTemplate(ctx context.Context, template *apiconfig.ConfigFileTemplate) *apiconfig.ConfigResponse

	// GetConfigFileTemplate get config file template
	GetConfigFileTemplate(ctx context.Context, name string) *apiconfig.ConfigResponse
}

ConfigFileTemplateOperate config file template operate

type Event

type Event struct {
	EventType string
	Message   interface{}
}

Event 事件对象,包含类型和事件消息

type FileReleaseCallback

type FileReleaseCallback func(clientId string, rsp *apiconfig.ConfigClientResponse) bool

type ResourceEvent

type ResourceEvent struct {
	ConfigGroup *apiconfig.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 GetOriginServer() (*Server, error)

func (*Server) BatchDeleteConfigFile

func (s *Server) BatchDeleteConfigFile(ctx context.Context, configFiles []*apiconfig.ConfigFile,
	operator string) *apiconfig.ConfigResponse

BatchDeleteConfigFile 批量删除配置文件

func (*Server) Cache

func (s *Server) Cache() cache.FileCache

Cache 获取配置中心缓存模块

func (*Server) ConnManager

func (s *Server) ConnManager() *connManager

ConnManager 获取配置中心连接管理器

func (*Server) CreateConfigFile

func (s *Server) CreateConfigFile(ctx context.Context, configFile *apiconfig.ConfigFile) *apiconfig.ConfigResponse

CreateConfigFile 创建配置文件

func (*Server) CreateConfigFileGroup

func (s *Server) CreateConfigFileGroup(
	ctx context.Context, configFileGroup *apiconfig.ConfigFileGroup) *apiconfig.ConfigResponse

CreateConfigFileGroup 创建配置文件组

func (*Server) CreateConfigFileTemplate

func (s *Server) CreateConfigFileTemplate(
	ctx context.Context, template *apiconfig.ConfigFileTemplate) *apiconfig.ConfigResponse

CreateConfigFileTemplate create config file template

func (*Server) DeleteConfigFile

func (s *Server) DeleteConfigFile(
	ctx context.Context, namespace, group, name, deleteBy string) *apiconfig.ConfigResponse

DeleteConfigFile 删除配置文件,删除配置文件同时会通知客户端 Not_Found

func (*Server) DeleteConfigFileGroup

func (s *Server) DeleteConfigFileGroup(ctx context.Context, namespace, name string) *apiconfig.ConfigResponse

DeleteConfigFileGroup 删除配置文件组

func (*Server) DeleteConfigFileRelease

func (s *Server) DeleteConfigFileRelease(ctx context.Context, namespace,
	group, fileName, deleteBy string) *apiconfig.ConfigResponse

DeleteConfigFileRelease 删除配置文件发布,删除配置文件的时候,同步删除配置文件发布数据

func (*Server) ExportConfigFile added in v1.15.0

func (s *Server) ExportConfigFile(ctx context.Context,
	configFileExport *apiconfig.ConfigFileExportRequest) *apiconfig.ConfigExportResponse

ExportConfigFile 导出配置文件

func (*Server) GetAllConfigFileTemplates

func (s *Server) GetAllConfigFileTemplates(ctx context.Context) *apiconfig.ConfigBatchQueryResponse

GetAllConfigFileTemplates get all config file templates

func (*Server) GetConfigFileBaseInfo

func (s *Server) GetConfigFileBaseInfo(ctx context.Context, namespace, group, name string) *apiconfig.ConfigResponse

GetConfigFileBaseInfo 获取配置文件,只返回基础元信息

func (*Server) GetConfigFileForClient

func (s *Server) GetConfigFileForClient(ctx context.Context,
	client *apiconfig.ClientConfigFileInfo) *apiconfig.ConfigClientResponse

GetConfigFileForClient 从缓存中获取配置文件,如果客户端的版本号大于服务端,则服务端重新加载缓存

func (*Server) GetConfigFileLatestReleaseHistory

func (s *Server) GetConfigFileLatestReleaseHistory(ctx context.Context, namespace, group,
	fileName string) *apiconfig.ConfigResponse

GetConfigFileLatestReleaseHistory 获取配置文件最后一次发布记录

func (*Server) GetConfigFileRelease

func (s *Server) GetConfigFileRelease(
	ctx context.Context, namespace, group, fileName string) *apiconfig.ConfigResponse

GetConfigFileRelease 获取配置文件发布内容

func (*Server) GetConfigFileReleaseHistory

func (s *Server) GetConfigFileReleaseHistory(ctx context.Context, namespace, group, fileName string, offset,
	limit uint32, endId uint64) *apiconfig.ConfigBatchQueryResponse

GetConfigFileReleaseHistory 获取配置文件发布历史记录

func (*Server) GetConfigFileRichInfo

func (s *Server) GetConfigFileRichInfo(ctx context.Context, namespace, group, name string) *apiconfig.ConfigResponse

GetConfigFileRichInfo 获取单个配置文件基础信息,包含发布状态等信息

func (*Server) GetConfigFileTemplate

func (s *Server) GetConfigFileTemplate(ctx context.Context, name string) *apiconfig.ConfigResponse

GetConfigFileTemplate get config file template by name

func (*Server) ImportConfigFile added in v1.15.0

func (s *Server) ImportConfigFile(ctx context.Context,
	configFiles []*apiconfig.ConfigFile, conflictHandling string) *apiconfig.ConfigImportResponse

ImportConfigFile 导入配置文件

func (*Server) PublishConfigFile

func (s *Server) PublishConfigFile(
	ctx context.Context, configFileRelease *apiconfig.ConfigFileRelease) *apiconfig.ConfigResponse

PublishConfigFile 发布配置文件

func (*Server) QueryConfigFileGroups

func (s *Server) QueryConfigFileGroups(ctx context.Context, namespace, groupName,
	fileName string, offset, limit uint32) *apiconfig.ConfigBatchQueryResponse

QueryConfigFileGroups 查询配置文件组

func (*Server) QueryConfigFilesByGroup

func (s *Server) QueryConfigFilesByGroup(ctx context.Context, namespace, group string,
	offset, limit uint32) *apiconfig.ConfigBatchQueryResponse

QueryConfigFilesByGroup querying configuration files

func (*Server) RecordHistory added in v1.14.0

func (s *Server) RecordHistory(ctx context.Context, entry *model.RecordEntry)

RecordHistory server对外提供history插件的简单封装

func (*Server) SearchConfigFile

func (s *Server) SearchConfigFile(ctx context.Context, namespace, group, name, tags string,
	offset, limit uint32) *apiconfig.ConfigBatchQueryResponse

SearchConfigFile 查询配置文件

func (*Server) SetResourceHooks

func (s *Server) SetResourceHooks(hooks ...ResourceHook)

SetResourceHooks 设置资源钩子

func (*Server) StartTxAndSetToContext

func (s *Server) StartTxAndSetToContext(ctx context.Context) (store.Tx, context.Context, error)

StartTxAndSetToContext 开启一个事务,并放入到上下文里

func (*Server) UpdateConfigFile

func (s *Server) UpdateConfigFile(ctx context.Context, configFile *apiconfig.ConfigFile) *apiconfig.ConfigResponse

UpdateConfigFile 更新配置文件

func (*Server) UpdateConfigFileGroup

func (s *Server) UpdateConfigFileGroup(ctx context.Context,
	configFileGroup *apiconfig.ConfigFileGroup) *apiconfig.ConfigResponse

UpdateConfigFileGroup 更新配置文件组

func (*Server) WatchCenter

func (s *Server) WatchCenter() *watchCenter

WatchCenter 获取监听事件中心

func (*Server) WatchConfigFiles

func (s *Server) WatchConfigFiles(ctx context.Context,
	request *apiconfig.ClientWatchConfigFileRequest) (WatchCallback, error)

type WatchCallback

type WatchCallback func() *apiconfig.ConfigClientResponse

WatchCallback 监听回调函数

Directories

Path Synopsis
Package utils contains some common functions
Package utils contains some common functions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL