github.com/polarismesh/polaris@v1.17.8/apiserver/xdsserverv3/resource/model.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 resource 19 20 import ( 21 "github.com/polarismesh/specification/source/go/api/v1/fault_tolerance" 22 apimodel "github.com/polarismesh/specification/source/go/api/v1/model" 23 apiservice "github.com/polarismesh/specification/source/go/api/v1/service_manage" 24 "github.com/polarismesh/specification/source/go/api/v1/traffic_manage" 25 26 "github.com/polarismesh/polaris/common/model" 27 ) 28 29 type XDSType int16 30 31 const ( 32 _ XDSType = iota 33 LDS 34 RDS 35 EDS 36 CDS 37 RLS 38 SDS 39 ) 40 41 const ( 42 K8sDnsResolveSuffixSvc = ".svc" 43 K8sDnsResolveSuffixSvcCluster = ".svc.cluster" 44 K8sDnsResolveSuffixSvcClusterLocal = ".svc.cluster.local" 45 ) 46 47 type TLSMode string 48 49 const ( 50 TLSModeTag = "polarismesh.cn/tls-mode" 51 TLSModeNone TLSMode = "none" 52 TLSModeStrict TLSMode = "strict" 53 TLSModePermissive TLSMode = "permissive" 54 ) 55 56 const ( 57 // 这个是特殊指定的 prefix 58 MatchString_Prefix = apimodel.MatchString_MatchStringType(-1) 59 ) 60 61 // ServiceInfo 北极星服务结构体 62 type ServiceInfo struct { 63 ID string 64 Name string 65 Namespace string 66 ServiceKey model.ServiceKey 67 AliasFor *model.Service 68 Instances []*apiservice.Instance 69 SvcInsRevision string 70 Routing *traffic_manage.Routing 71 SvcRoutingRevision string 72 Ports []*model.ServicePort 73 RateLimit *traffic_manage.RateLimit 74 SvcRateLimitRevision string 75 CircuitBreaker *fault_tolerance.CircuitBreaker 76 CircuitBreakerRevision string 77 FaultDetect *fault_tolerance.FaultDetector 78 FaultDetectRevision string 79 } 80 81 func (s *ServiceInfo) MatchService(ns, name string) bool { 82 if s.Namespace == ns && s.Name == name { 83 return true 84 } 85 86 if s.AliasFor != nil { 87 if s.AliasFor.Namespace == ns && s.AliasFor.Name == name { 88 return true 89 } 90 } 91 return false 92 }