dubbo.apache.org/dubbo-go/v3@v3.1.1/remoting/xds/mapping/debug.go (about) 1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package mapping 19 20 import ( 21 "encoding/json" 22 ) 23 24 // ADSZResponse is body got from istiod:8080/debug/adsz 25 type ADSZResponse struct { 26 Clients []ADSZClient `json:"clients"` 27 } 28 29 type ADSZClient struct { 30 Metadata map[string]interface{} `json:"metadata"` 31 } 32 33 func (a *ADSZResponse) GetMap() map[string]string { 34 result := make(map[string]string) 35 for _, c := range a.Clients { 36 if c.Metadata["LABELS"] == nil { 37 continue 38 } 39 labelsMap, ok := c.Metadata["LABELS"].(map[string]interface{}) 40 if !ok { 41 continue 42 } 43 dubbogoMetadata := labelsMap["DUBBO_GO"] 44 if dubbogoMetadata == nil { 45 continue 46 } 47 dubbogoMetadataStr, ok := dubbogoMetadata.(string) 48 if !ok { 49 continue 50 } 51 resultMap := make(map[string]string) 52 _ = json.Unmarshal([]byte(dubbogoMetadataStr), &resultMap) 53 for k, v := range resultMap { 54 result[k] = v 55 } 56 } 57 return result 58 }