func (d *ElasticacheBackend) GetProxyConfigurations() ([]backends.ConnectionConfig, error) { if d.logLevel > 0 { log.Println("Describing cluster", d.cacheClusterId) } // Paging shouldn't be a concern, as only 0 or 1 clusters should be returned by this call. clusters, err := d.elasticache.DescribeCacheClusters(&elasticache.DescribeCacheClustersInput{ CacheClusterId: aws.String(d.cacheClusterId), MaxRecords: aws.Int64(100), ShowCacheNodeInfo: aws.Bool(true), }) if err != nil { log.Println("Error describing cluster", d.cacheClusterId, err) return nil, err } var pollResults = make(map[int]backends.ConnectionConfig, 0) var nodeIDs = make([]int, 0) // Get all of the nodes for this cluster for _, cluster := range clusters.CacheClusters { for _, node := range cluster.CacheNodes { backend, err := backends.ParseConnection(fmt.Sprintf("%v:%s:%v", d.localPort, *node.Endpoint.Address, *node.Endpoint.Port)) if err != nil { return nil, err } backend.Name = *cluster.CacheClusterId + "::" + *node.CacheNodeId id, err := strconv.Atoi(*node.CacheNodeId) if err != nil { return nil, err } pollResults[id] = *backend nodeIDs = append(nodeIDs, id) } } if d.logLevel > 0 { log.Println("Found", len(nodeIDs), "nodeIDs") } sort.Sort(sort.IntSlice(nodeIDs)) // Select the lowest id no if len(nodeIDs) == 0 { return []backends.ConnectionConfig{}, nil } else { return []backends.ConnectionConfig{pollResults[nodeIDs[0]]}, nil } }
func (d *DynamoDbBackend) GetProxyConfigurations() ([]backends.ConnectionConfig, error) { // TODO For now this is limited to 1MB of items before it hits pagination, which it doesnt implement yet. result, err := d.database.Query(getProxiesWithName(d.tablename, d.proxy_name)) if err != nil { return nil, err } var connections = make([]backends.ConnectionConfig, len(result.Items)) for i := range result.Items { connection, err := backends.ParseConnection(*result.Items[i]["proxy_configuration"].S) if err != nil { return nil, err } connections[i] = *connection } return connections, nil }