github.com/polarismesh/polaris@v1.17.8/apiserver/grpcserver/config/client_access.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 "github.com/polarismesh/polaris/apiserver/grpcserver" 26 ) 27 28 // GetConfigFile 拉取配置 29 func (g *ConfigGRPCServer) GetConfigFile(ctx context.Context, 30 configFile *apiconfig.ClientConfigFileInfo) (*apiconfig.ConfigClientResponse, error) { 31 ctx = grpcserver.ConvertContext(ctx) 32 response := g.configServer.GetConfigFileForClient(ctx, configFile) 33 return response, nil 34 } 35 36 // CreateConfigFile 创建或更新配置 37 func (g *ConfigGRPCServer) CreateConfigFile(ctx context.Context, 38 configFile *apiconfig.ConfigFile) (*apiconfig.ConfigClientResponse, error) { 39 ctx = grpcserver.ConvertContext(ctx) 40 response := g.configServer.CreateConfigFileFromClient(ctx, configFile) 41 return response, nil 42 } 43 44 // UpdateConfigFile 创建或更新配置 45 func (g *ConfigGRPCServer) UpdateConfigFile(ctx context.Context, 46 configFile *apiconfig.ConfigFile) (*apiconfig.ConfigClientResponse, error) { 47 ctx = grpcserver.ConvertContext(ctx) 48 response := g.configServer.UpdateConfigFileFromClient(ctx, configFile) 49 return response, nil 50 } 51 52 // PublishConfigFile 发布配置 53 func (g *ConfigGRPCServer) PublishConfigFile(ctx context.Context, 54 configFile *apiconfig.ConfigFileRelease) (*apiconfig.ConfigClientResponse, error) { 55 ctx = grpcserver.ConvertContext(ctx) 56 response := g.configServer.PublishConfigFileFromClient(ctx, configFile) 57 return response, nil 58 } 59 60 // WatchConfigFiles 订阅配置变更 61 func (g *ConfigGRPCServer) WatchConfigFiles(ctx context.Context, 62 request *apiconfig.ClientWatchConfigFileRequest) (*apiconfig.ConfigClientResponse, error) { 63 ctx = grpcserver.ConvertContext(ctx) 64 65 // 阻塞等待响应 66 callback, err := g.configServer.WatchConfigFiles(ctx, request) 67 if err != nil { 68 return nil, err 69 } 70 return callback(), nil 71 } 72 73 func (g *ConfigGRPCServer) GetConfigFileMetadataList(ctx context.Context, 74 req *apiconfig.ConfigFileGroupRequest) (*apiconfig.ConfigClientListResponse, error) { 75 76 ctx = grpcserver.ConvertContext(ctx) 77 return g.configServer.GetConfigFileNamesWithCache(ctx, req), nil 78 }