github.com/polarismesh/polaris@v1.17.8/config/api.go (about) 1 /** 2 * Tencent is pleased to support the open source community by making Polaris available. 3 * 4 * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. 5 * 6 * Licensed under the BSD 3-Clause License (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * https://opensource.org/licenses/BSD-3-Clause 11 * 12 * Unless required by applicable law or agreed to in writing, software distributed 13 * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 14 * CONDITIONS OF ANY KIND, either express or implied. See the License for the 15 * specific language governing permissions and limitations under the License. 16 */ 17 18 package config 19 20 import ( 21 "context" 22 23 apiconfig "github.com/polarismesh/specification/source/go/api/v1/config_manage" 24 ) 25 26 type ( 27 // WatchCallback 监听回调函数 28 WatchCallback func() *apiconfig.ConfigClientResponse 29 ) 30 31 const ( 32 // MaxPageSize 最大分页大小 33 MaxPageSize = 100 34 ) 35 36 // ConfigFileGroupOperate 配置文件组接口 37 type ConfigFileGroupOperate interface { 38 // CreateConfigFileGroup 创建配置文件组 39 CreateConfigFileGroup(ctx context.Context, configFileGroup *apiconfig.ConfigFileGroup) *apiconfig.ConfigResponse 40 // QueryConfigFileGroups 查询配置文件组 41 QueryConfigFileGroups(ctx context.Context, filter map[string]string) *apiconfig.ConfigBatchQueryResponse 42 // DeleteConfigFileGroup 删除配置文件组 43 DeleteConfigFileGroup(ctx context.Context, namespace, name string) *apiconfig.ConfigResponse 44 // UpdateConfigFileGroup 更新配置文件组 45 UpdateConfigFileGroup(ctx context.Context, configFileGroup *apiconfig.ConfigFileGroup) *apiconfig.ConfigResponse 46 } 47 48 // ConfigFileOperate 配置文件接口 49 type ConfigFileOperate interface { 50 // CreateConfigFile 创建配置文件 51 CreateConfigFile(ctx context.Context, configFile *apiconfig.ConfigFile) *apiconfig.ConfigResponse 52 // GetConfigFileRichInfo 获取单个配置文件基础信息,包含发布状态等信息 53 GetConfigFileRichInfo(ctx context.Context, req *apiconfig.ConfigFile) *apiconfig.ConfigResponse 54 // SearchConfigFile 按 group 和 name 模糊搜索配置文件 55 SearchConfigFile(ctx context.Context, filter map[string]string) *apiconfig.ConfigBatchQueryResponse 56 // UpdateConfigFile 更新配置文件 57 UpdateConfigFile(ctx context.Context, configFile *apiconfig.ConfigFile) *apiconfig.ConfigResponse 58 // DeleteConfigFile 删除配置文件 59 DeleteConfigFile(ctx context.Context, req *apiconfig.ConfigFile) *apiconfig.ConfigResponse 60 // BatchDeleteConfigFile 批量删除配置文件 61 BatchDeleteConfigFile(ctx context.Context, req []*apiconfig.ConfigFile) *apiconfig.ConfigResponse 62 // ExportConfigFile 导出配置文件 63 ExportConfigFile(ctx context.Context, 64 configFileExport *apiconfig.ConfigFileExportRequest) *apiconfig.ConfigExportResponse 65 // ImportConfigFile 导入配置文件 66 ImportConfigFile(ctx context.Context, 67 configFiles []*apiconfig.ConfigFile, conflictHandling string) *apiconfig.ConfigImportResponse 68 // GetAllConfigEncryptAlgorithms 获取配置加密算法 69 GetAllConfigEncryptAlgorithms(ctx context.Context) *apiconfig.ConfigEncryptAlgorithmResponse 70 } 71 72 // ConfigFileReleaseOperate 配置文件发布接口 73 type ConfigFileReleaseOperate interface { 74 // PublishConfigFile 发布配置文件 75 PublishConfigFile(ctx context.Context, configFileRelease *apiconfig.ConfigFileRelease) *apiconfig.ConfigResponse 76 // GetConfigFileRelease 获取配置文件发布 77 GetConfigFileRelease(ctx context.Context, req *apiconfig.ConfigFileRelease) *apiconfig.ConfigResponse 78 // DeleteConfigFileReleases 删除配置文件发布内容 79 DeleteConfigFileReleases(ctx context.Context, reqs []*apiconfig.ConfigFileRelease) *apiconfig.ConfigBatchWriteResponse 80 // RollbackConfigFileReleases 批量回滚配置到指定版本 81 RollbackConfigFileReleases(ctx context.Context, releases []*apiconfig.ConfigFileRelease) *apiconfig.ConfigBatchWriteResponse 82 // GetConfigFileReleases 查询所有的配置发布版本信息 83 GetConfigFileReleases(ctx context.Context, filters map[string]string) *apiconfig.ConfigBatchQueryResponse 84 // GetConfigFileReleaseVersions 查询所有的配置发布版本信息 85 GetConfigFileReleaseVersions(ctx context.Context, filters map[string]string) *apiconfig.ConfigBatchQueryResponse 86 // GetConfigFileReleaseHistories 获取配置文件的发布历史 87 GetConfigFileReleaseHistories(ctx context.Context, filter map[string]string) *apiconfig.ConfigBatchQueryResponse 88 // UpsertAndReleaseConfigFile 创建/更新配置文件并发布 89 UpsertAndReleaseConfigFile(ctx context.Context, req *apiconfig.ConfigFilePublishInfo) *apiconfig.ConfigResponse 90 } 91 92 // ConfigFileClientOperate 给客户端提供服务接口,不同的上层协议抽象的公共服务逻辑 93 type ConfigFileClientOperate interface { 94 // GetConfigFileForClient 获取配置文件 95 GetConfigFileForClient(ctx context.Context, req *apiconfig.ClientConfigFileInfo) *apiconfig.ConfigClientResponse 96 // CreateConfigFileFromClient 调用config_file的方法创建配置文件 97 CreateConfigFileFromClient(ctx context.Context, req *apiconfig.ConfigFile) *apiconfig.ConfigClientResponse 98 // UpdateConfigFileFromClient 调用config_file的方法更新配置文件 99 UpdateConfigFileFromClient(ctx context.Context, req *apiconfig.ConfigFile) *apiconfig.ConfigClientResponse 100 // PublishConfigFileFromClient 调用config_file_release的方法发布配置文件 101 PublishConfigFileFromClient(ctx context.Context, req *apiconfig.ConfigFileRelease) *apiconfig.ConfigClientResponse 102 // WatchConfigFiles 客户端监听配置文件 103 WatchConfigFiles(ctx context.Context, req *apiconfig.ClientWatchConfigFileRequest) (WatchCallback, error) 104 // GetConfigFileNamesWithCache 获取某个配置分组下的配置文件 105 GetConfigFileNamesWithCache(ctx context.Context, 106 req *apiconfig.ConfigFileGroupRequest) *apiconfig.ConfigClientListResponse 107 } 108 109 // ConfigFileTemplateOperate config file template operate 110 type ConfigFileTemplateOperate interface { 111 // GetAllConfigFileTemplates get all config file templates 112 GetAllConfigFileTemplates(ctx context.Context) *apiconfig.ConfigBatchQueryResponse 113 // CreateConfigFileTemplate create config file template 114 CreateConfigFileTemplate(ctx context.Context, template *apiconfig.ConfigFileTemplate) *apiconfig.ConfigResponse 115 // GetConfigFileTemplate get config file template 116 GetConfigFileTemplate(ctx context.Context, name string) *apiconfig.ConfigResponse 117 } 118 119 // ConfigCenterServer 配置中心server 120 type ConfigCenterServer interface { 121 ConfigFileGroupOperate 122 ConfigFileOperate 123 ConfigFileReleaseOperate 124 ConfigFileClientOperate 125 ConfigFileTemplateOperate 126 }