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

Method handleGetStatus

rest/admin_api.go:1534–1580  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1532}
1533
1534func (h *handler) handleGetStatus() error {
1535
1536 var status = Status{
1537 Databases: make(map[string]DatabaseStatus),
1538 Vendor: vendor{Name: base.ProductNameString},
1539 }
1540
1541 // This handler is supposed to be admin-only anyway, but being defensive if this is opened up in the routes file.
1542 if h.shouldShowProductVersion() {
1543 status.Version = base.LongVersionString
1544 status.Vendor.Version = base.ProductAPIVersion
1545 }
1546
1547 for _, database := range h.server._databases {
1548 lastSeq := uint64(0)
1549 runState := db.RunStateString[atomic.LoadUint32(&database.State)]
1550
1551 // Don't bother trying to lookup LastSequence() if offline
1552 if runState != db.RunStateString[db.DBOffline] {
1553 lastSeq, _ = database.LastSequence(h.ctx())
1554 }
1555
1556 replicationsStatus, err := database.SGReplicateMgr.GetReplicationStatusAll(h.ctx(), db.DefaultReplicationStatusOptions())
1557 if err != nil {
1558 return err
1559 }
1560 cluster, err := database.SGReplicateMgr.GetSGRCluster()
1561 if err != nil {
1562 return err
1563 }
1564 for _, replication := range cluster.Replications {
1565 replication.ReplicationConfig = *replication.Redacted(h.ctx())
1566 }
1567
1568 status.Databases[database.Name] = DatabaseStatus{
1569 SequenceNumber: lastSeq,
1570 State: runState,
1571 ServerUUID: database.ServerUUID,
1572 ReplicationStatus: replicationsStatus,
1573 SGRCluster: cluster,
1574 RequireResync: database.RequireResync.ScopeAndCollectionNames(),
1575 }
1576 }
1577
1578 h.writeJSON(status)
1579 return nil
1580}
1581
1582func (h *handler) handleSetLogging() error {
1583 base.WarnfCtx(h.ctx(), "Using deprecated /_logging endpoint. Use /_config endpoints instead.")

Callers

nothing calls this directly

Calls 9

ctxMethod · 0.95
writeJSONMethod · 0.95
GetSGRClusterMethod · 0.80
LastSequenceMethod · 0.45
RedactedMethod · 0.45

Tested by

no test coverage detected