dubbo.apache.org/dubbo-go/v3@v3.1.1/xds/client/dump.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 /* 19 * 20 * Copyright 2021 gRPC authors. 21 * 22 */ 23 24 package client 25 26 import ( 27 "dubbo.apache.org/dubbo-go/v3/xds/client/resource" 28 ) 29 30 func mergeMaps(maps []map[string]resource.UpdateWithMD) map[string]resource.UpdateWithMD { 31 ret := make(map[string]resource.UpdateWithMD) 32 for _, m := range maps { 33 for k, v := range m { 34 ret[k] = v 35 } 36 } 37 return ret 38 } 39 40 func (c *clientImpl) dump(t resource.ResourceType) map[string]resource.UpdateWithMD { 41 c.authorityMu.Lock() 42 defer c.authorityMu.Unlock() 43 maps := make([]map[string]resource.UpdateWithMD, 0, len(c.authorities)) 44 for _, a := range c.authorities { 45 maps = append(maps, a.dump(t)) 46 } 47 return mergeMaps(maps) 48 } 49 50 // DumpLDS returns the status and contents of LDS. 51 func (c *clientImpl) DumpLDS() map[string]resource.UpdateWithMD { 52 return c.dump(resource.ListenerResource) 53 } 54 55 // DumpRDS returns the status and contents of RDS. 56 func (c *clientImpl) DumpRDS() map[string]resource.UpdateWithMD { 57 return c.dump(resource.RouteConfigResource) 58 } 59 60 // DumpCDS returns the status and contents of CDS. 61 func (c *clientImpl) DumpCDS() map[string]resource.UpdateWithMD { 62 return c.dump(resource.ClusterResource) 63 } 64 65 // DumpEDS returns the status and contents of EDS. 66 func (c *clientImpl) DumpEDS() map[string]resource.UpdateWithMD { 67 return c.dump(resource.EndpointsResource) 68 }