Skip to content

Commit

Permalink
CBG-2979 remove unused fields and docs for GET /db/ (#6565)
Browse files Browse the repository at this point in the history
  • Loading branch information
torcolvin authored Nov 6, 2023
1 parent e8f9645 commit a9033a3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 60 deletions.
24 changes: 0 additions & 24 deletions docs/api/paths/admin/db-.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,30 +66,6 @@ get:
description: Unique server identifier.
type: string
example: 995618a6a6cc9ac79731bd13240e19b5
scopes:
description: 'Scopes that are used by the database.'
type: object
example:
scope1:
collections:
collection1:
update_seq: 123456
collection2:
update_seq: 654321
additionalProperties:
description: 'The name of the scope.'
type: object
properties:
collections:
description: 'The set of collections within the scope.'
additionalProperties:
description: 'The name of the collection.'
type: object
properties:
update_seq:
description: 'The last sequence number that was committed to the collection.'
type: integer
example: 123456
'404':
$ref: ../../components/responses.yaml#/Not-found
tags:
Expand Down
50 changes: 14 additions & 36 deletions rest/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,17 +394,16 @@ func (h *handler) instanceStartTimeMicro() int64 {
}

type DatabaseRoot struct {
DBName string `json:"db_name"`
SequenceNumber *uint64 `json:"update_seq,omitempty"` // The last sequence written to the _default collection, if not running with multiple collections.
CommittedUpdateSequenceNumber *uint64 `json:"committed_update_seq,omitempty"` // Same as above - Used by perf tests, shouldn't be removed
InstanceStartTimeMicro int64 `json:"instance_start_time"` // microseconds since epoch
CompactRunning bool `json:"compact_running"`
PurgeSequenceNumber uint64 `json:"purge_seq"`
DiskFormatVersion uint64 `json:"disk_format_version"`
State string `json:"state"`
ServerUUID string `json:"server_uuid,omitempty"`
RequireResync []string `json:"require_resync,omitempty"`
Scopes map[string]databaseRootScope `json:"scopes,omitempty"` // stats for each scope/collection
DBName string `json:"db_name"`
SequenceNumber *uint64 `json:"update_seq,omitempty"` // The last sequence written to the _default collection, if not running with multiple collections.
CommittedUpdateSequenceNumber *uint64 `json:"committed_update_seq,omitempty"` // Same as above - Used by perf tests, shouldn't be removed
InstanceStartTimeMicro int64 `json:"instance_start_time"` // microseconds since epoch
CompactRunning bool `json:"compact_running"`
PurgeSequenceNumber uint64 `json:"purge_seq"`
DiskFormatVersion uint64 `json:"disk_format_version"`
State string `json:"state"`
ServerUUID string `json:"server_uuid,omitempty"`
RequireResync []string `json:"require_resync,omitempty"`
}

type dbSummary struct {
Expand All @@ -413,50 +412,29 @@ type dbSummary struct {
State string `json:"state"`
}

type databaseRootScope struct {
Collections map[string]databaseRootCollection `json:"collections,omitempty"`
}

type databaseRootCollection struct {
SequenceNumber uint64 `json:"update_seq"` // The last sequence written for this collection
}

func (h *handler) handleGetDB() error {
if h.rq.Method == "HEAD" {
return nil
}

// TODO: If running with multiple collections, leave nil
var defaultCollectionLastSeq *uint64

// Don't bother trying to lookup LastSequence() if offline
var lastSeq uint64
runState := db.RunStateString[atomic.LoadUint32(&h.db.State)]
if runState != db.RunStateString[db.DBOffline] {
lastSeq, _ := h.db.LastSequence(h.ctx())
defaultCollectionLastSeq = &lastSeq
lastSeq, _ = h.db.LastSequence(h.ctx())
}

var response = DatabaseRoot{
DBName: h.db.Name,
SequenceNumber: defaultCollectionLastSeq,
CommittedUpdateSequenceNumber: defaultCollectionLastSeq,
SequenceNumber: &lastSeq,
CommittedUpdateSequenceNumber: &lastSeq,
InstanceStartTimeMicro: h.instanceStartTimeMicro(),
CompactRunning: h.db.IsCompactRunning(),
PurgeSequenceNumber: 0, // TODO: Should track this value
DiskFormatVersion: 0, // Probably meaningless, but add for compatibility
State: runState,
ServerUUID: h.db.DatabaseContext.ServerUUID,
RequireResync: h.db.RequireResync.ScopeAndCollectionNames(),

// TODO: If running with multiple scope/collections
// Scopes: map[string]databaseRootScope{
// "scope1": {
// Collections: map[string]databaseRootCollection{
// "collection1": {SequenceNumber: 123456},
// "collection2": {SequenceNumber: 987654},
// },
// },
// },
}

h.writeJSON(response)
Expand Down

0 comments on commit a9033a3

Please sign in to comment.