MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / handleGetClusterInfo

Method handleGetClusterInfo

rest/admin_api.go:2318–2363  ·  view source on GitHub ↗

Get SG cluster information. Iterates over all buckets associated with the server, and returns cluster information (registry) for each

()

Source from the content-addressed store, hash-verified

2316// Get SG cluster information. Iterates over all buckets associated with the server, and returns cluster
2317// information (registry) for each
2318func (h *handler) handleGetClusterInfo() error {
2319
2320 clusterInfo := ClusterInfo{
2321 Buckets: make(map[string]BucketInfo),
2322 }
2323
2324 eccv := h.server.getBucketCCVSettings()
2325 if h.server.persistentConfig {
2326
2327 bucketNames, err := h.server.GetBucketNames()
2328 if err != nil {
2329 return err
2330 }
2331
2332 clusterInfo = ClusterInfo{
2333 Buckets: make(map[string]BucketInfo, len(bucketNames)),
2334 }
2335
2336 for _, bucketName := range bucketNames {
2337 registry, err := h.server.BootstrapContext.getGatewayRegistry(h.ctx(), bucketName)
2338 if err != nil {
2339 base.InfofCtx(h.ctx(), base.KeyAll, "Unable to retrieve registry for bucket %s during getClusterInfo: %v", base.MD(bucketName), err)
2340 continue
2341 }
2342
2343 bucketInfo := BucketInfo{
2344 Registry: registry,
2345 EnableCrossClusterVersioning: eccv[bucketName],
2346 }
2347 clusterInfo.Buckets[bucketName] = bucketInfo
2348 }
2349 } else {
2350 clusterInfo.LegacyConfig = true
2351
2352 for bucketName, eccvVal := range eccv {
2353 bucketInfo := BucketInfo{
2354 EnableCrossClusterVersioning: eccvVal,
2355 }
2356 clusterInfo.Buckets[bucketName] = bucketInfo
2357 }
2358 }
2359
2360 base.Audit(h.ctx(), base.AuditIDClusterInfoRead, nil)
2361 h.writeJSON(clusterInfo)
2362 return nil
2363}
2364
2365// databaseLoadErrorAsHTTPError converts an error loading a database into an error with an http status code. Pulled into a function so we can duplicate persistent and non persistent config logic.
2366func databaseLoadErrorAsHTTPError(err error) error {

Callers

nothing calls this directly

Calls 8

ctxMethod · 0.95
writeJSONMethod · 0.95
InfofCtxFunction · 0.92
MDFunction · 0.92
AuditFunction · 0.92
getBucketCCVSettingsMethod · 0.80
GetBucketNamesMethod · 0.80
getGatewayRegistryMethod · 0.80

Tested by

no test coverage detected