MCPcopy
hub / github.com/zalando/skipper / getRemoteURLShardAddrUpdater

Function getRemoteURLShardAddrUpdater

skipper.go:1718–1749  ·  view source on GitHub ↗
(address string)

Source from the content-addressed store, hash-verified

1716}
1717
1718func getRemoteURLShardAddrUpdater(address string) func() ([]string, error) {
1719 /* #nosec */
1720 return func() ([]string, error) {
1721 resp, err := http.Get(address)
1722 if err != nil {
1723 log.Errorf("failed to connect to redis/valkey endpoint %v, due to: %v", address, err)
1724 return nil, err
1725 }
1726 defer resp.Body.Close()
1727
1728 body, err := io.ReadAll(resp.Body)
1729 if err != nil {
1730 log.Errorf("failed to read to redis/valkey response %v", err)
1731 return nil, err
1732 }
1733
1734 target := &ShardEndpoints{}
1735
1736 err = json.Unmarshal(body, target)
1737 if err != nil {
1738 log.Errorf("Failed to decode body to json %v", err)
1739 return nil, err
1740 }
1741
1742 a := make([]string, 0, len(target.Endpoints))
1743 for _, endpoint := range target.Endpoints {
1744 a = append(a, endpoint.Address)
1745 }
1746
1747 return a, nil
1748 }
1749}
1750
1751func run(o Options, sig chan os.Signal, idleConnsCH chan struct{}) error {
1752 // init log

Callers 1

runFunction · 0.85

Calls 3

GetMethod · 0.65
ErrorfMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…