github.com/polarismesh/polaris@v1.17.8/store/config_file_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 store 19 20 import ( 21 "time" 22 23 "github.com/polarismesh/polaris/common/model" 24 ) 25 26 // ConfigFileModuleStore 配置中心模块存储接口 27 type ConfigFileModuleStore interface { 28 ConfigFileGroupStore 29 ConfigFileStore 30 ConfigFileReleaseStore 31 ConfigFileReleaseHistoryStore 32 ConfigFileTemplateStore 33 } 34 35 // ConfigFileGroupStore 配置文件组存储接口 36 type ConfigFileGroupStore interface { 37 // CreateConfigFileGroup 创建配置文件组 38 CreateConfigFileGroup(fileGroup *model.ConfigFileGroup) (*model.ConfigFileGroup, error) 39 // UpdateConfigFileGroup 更新配置文件组 40 UpdateConfigFileGroup(fileGroup *model.ConfigFileGroup) error 41 // GetConfigFileGroup 获取单个配置文件组 42 GetConfigFileGroup(namespace, name string) (*model.ConfigFileGroup, error) 43 // DeleteConfigFileGroup 删除配置文件组 44 DeleteConfigFileGroup(namespace, name string) error 45 // GetMoreConfigGroup 获取配置分组 46 GetMoreConfigGroup(firstUpdate bool, mtime time.Time) ([]*model.ConfigFileGroup, error) 47 // CountConfigGroups 获取一个命名空间下的配置分组数量 48 CountConfigGroups(namespace string) (uint64, error) 49 } 50 51 // ConfigFileStore 配置文件存储接口 52 type ConfigFileStore interface { 53 // LockConfigFile 加锁配置文件 54 LockConfigFile(tx Tx, file *model.ConfigFileKey) (*model.ConfigFile, error) 55 // CreateConfigFileTx 创建配置文件 56 CreateConfigFileTx(tx Tx, file *model.ConfigFile) error 57 // GetConfigFile 获取配置文件 58 GetConfigFile(namespace, group, name string) (*model.ConfigFile, error) 59 // GetConfigFileTx 获取配置文件 60 GetConfigFileTx(tx Tx, namespace, group, name string) (*model.ConfigFile, error) 61 // QueryConfigFiles 翻页查询配置文件,group、name可为模糊匹配 62 QueryConfigFiles(filter map[string]string, offset uint32, limit uint32) (uint32, []*model.ConfigFile, error) 63 // UpdateConfigFileTx 更新配置文件 64 UpdateConfigFileTx(tx Tx, file *model.ConfigFile) error 65 // DeleteConfigFileTx 删除配置文件 66 DeleteConfigFileTx(tx Tx, namespace, group, name string) error 67 // CountConfigFiles 获取一个配置文件组下的文件数量 68 CountConfigFiles(namespace, group string) (uint64, error) 69 // CountConfigFileEachGroup 统计 namespace.group 下的配置文件数量 70 CountConfigFileEachGroup() (map[string]map[string]int64, error) 71 } 72 73 // ConfigFileReleaseStore 配置文件发布存储接口 74 type ConfigFileReleaseStore interface { 75 // GetConfigFileActiveRelease 获取配置文件处于 Active 的配置发布记录 76 GetConfigFileActiveRelease(file *model.ConfigFileKey) (*model.ConfigFileRelease, error) 77 // GetConfigFileActiveReleaseTx 获取配置文件处于 Active 的配置发布记录 78 GetConfigFileActiveReleaseTx(tx Tx, file *model.ConfigFileKey) (*model.ConfigFileRelease, error) 79 // CreateConfigFileReleaseTx 创建配置文件发布 80 CreateConfigFileReleaseTx(tx Tx, fileRelease *model.ConfigFileRelease) error 81 // GetConfigFileRelease 获取配置文件发布内容,只获取 flag=0 的记录 82 GetConfigFileRelease(req *model.ConfigFileReleaseKey) (*model.ConfigFileRelease, error) 83 // GetConfigFileReleaseTx 在已开启的事务中获取配置文件发布内容,只获取 flag=0 的记录 84 GetConfigFileReleaseTx(tx Tx, req *model.ConfigFileReleaseKey) (*model.ConfigFileRelease, error) 85 // DeleteConfigFileReleaseTx 删除配置文件发布内容 86 DeleteConfigFileReleaseTx(tx Tx, data *model.ConfigFileReleaseKey) error 87 // ActiveConfigFileReleaseTx 指定激活发布的配置文件(激活具有排他性,同一个配置文件的所有 release 中只能有一个处于 active == true 状态) 88 ActiveConfigFileReleaseTx(tx Tx, release *model.ConfigFileRelease) error 89 // CleanConfigFileReleasesTx 清空配置文件发布 90 CleanConfigFileReleasesTx(tx Tx, namespace, group, fileName string) error 91 // GetMoreReleaseFile 获取最近更新的配置文件发布, 此方法用于 cache 增量更新,需要注意 modifyTime 应为数据库时间戳 92 GetMoreReleaseFile(firstUpdate bool, modifyTime time.Time) ([]*model.ConfigFileRelease, error) 93 // CountConfigReleases 获取一个配置文件组下的文件数量 94 CountConfigReleases(namespace, group string, onlyActive bool) (uint64, error) 95 } 96 97 // ConfigFileReleaseHistoryStore 配置文件发布历史存储接口 98 type ConfigFileReleaseHistoryStore interface { 99 // CreateConfigFileReleaseHistory 创建配置文件发布历史记录 100 CreateConfigFileReleaseHistory(history *model.ConfigFileReleaseHistory) error 101 // QueryConfigFileReleaseHistories 获取配置文件的发布历史记录 102 QueryConfigFileReleaseHistories(filter map[string]string, offset, limit uint32) (uint32, []*model.ConfigFileReleaseHistory, error) 103 // CleanConfigFileReleaseHistory 清理配置发布历史 104 CleanConfigFileReleaseHistory(endTime time.Time, limit uint64) error 105 } 106 107 // ConfigFileTemplateStore config file template store 108 type ConfigFileTemplateStore interface { 109 // QueryAllConfigFileTemplates query all config file templates 110 QueryAllConfigFileTemplates() ([]*model.ConfigFileTemplate, error) 111 // CreateConfigFileTemplate create config file template 112 CreateConfigFileTemplate(template *model.ConfigFileTemplate) (*model.ConfigFileTemplate, error) 113 // GetConfigFileTemplate get config file template by name 114 GetConfigFileTemplate(name string) (*model.ConfigFileTemplate, error) 115 }