()
| 504 | } |
| 505 | |
| 506 | func (h *handler) handleGetDB() error { |
| 507 | if h.rq.Method == "HEAD" { |
| 508 | return nil |
| 509 | } |
| 510 | |
| 511 | // Don't bother trying to lookup LastSequence() if offline |
| 512 | var lastSeq uint64 |
| 513 | runState := db.RunStateString[atomic.LoadUint32(&h.db.State)] |
| 514 | if runState != db.RunStateString[db.DBOffline] { |
| 515 | lastSeq, _ = h.db.LastSequence(h.ctx()) |
| 516 | } |
| 517 | |
| 518 | var response = DatabaseRoot{ |
| 519 | DBName: h.db.Name, |
| 520 | SequenceNumber: &lastSeq, |
| 521 | CommittedUpdateSequenceNumber: &lastSeq, |
| 522 | InstanceStartTimeMicro: h.instanceStartTimeMicro(), |
| 523 | CompactRunning: h.db.IsCompactRunning(), |
| 524 | PurgeSequenceNumber: 0, // TODO: Should track this value |
| 525 | DiskFormatVersion: 0, // Probably meaningless, but add for compatibility |
| 526 | State: runState, |
| 527 | ServerUUID: h.db.DatabaseContext.ServerUUID, |
| 528 | RequireResync: h.db.RequireResync.ScopeAndCollectionNames(), |
| 529 | InitializationActive: h.server.DatabaseInitManager.HasActiveInitialization(h.db.Name), |
| 530 | } |
| 531 | |
| 532 | base.Audit(h.ctx(), base.AuditIDReadDatabase, nil) |
| 533 | h.writeJSON(response) |
| 534 | return nil |
| 535 | } |
| 536 | |
| 537 | // Stub handler for hadling create DB on the public API returns HTTP status 412 |
| 538 | // if the db exists, and 403 if it doesn't. |
nothing calls this directly
no test coverage detected