getStatsUrls forms the stats url map.
(uuids []string, authType string, nodeDefs *cbgt.NodeDefs)
| 329 | |
| 330 | // getStatsUrls forms the stats url map. |
| 331 | func getStatsUrls(uuids []string, authType string, |
| 332 | nodeDefs *cbgt.NodeDefs) map[string]string { |
| 333 | nodeURL := make(map[string]string) |
| 334 | if nodeDefs == nil { |
| 335 | return nodeURL |
| 336 | } |
| 337 | |
| 338 | urlWithAuth := func(authType, urlStr string) (string, error) { |
| 339 | if authType == "cbauth" { |
| 340 | return cbgt.CBAuthURL(urlStr) |
| 341 | } |
| 342 | return urlStr, nil |
| 343 | } |
| 344 | |
| 345 | ss := cbgt.GetSecuritySetting() |
| 346 | |
| 347 | for _, uuid := range uuids { |
| 348 | if node, ok := nodeDefs.NodeDefs[uuid]; ok { |
| 349 | hostPortUrl := "http://" + node.HostPort |
| 350 | if ss.EncryptionEnabled { |
| 351 | if u, err := node.HttpsURL(); err == nil { |
| 352 | hostPortUrl = u |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | urlStr := hostPortUrl + "/api/stats?partitions=true" |
| 357 | urlStr, err := urlWithAuth(authType, urlStr) |
| 358 | if err != nil { |
| 359 | continue |
| 360 | } |
| 361 | |
| 362 | nodeURL[uuid] = urlStr |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | return nodeURL |
| 367 | } |
| 368 | |
| 369 | // srcPartition wraps the potential source partition |
| 370 | // with additional info to help prioritising it. |
no outgoing calls