Skip to content

Commit

Permalink
introduce MemDB.DBSchema() method for introspection (#121)
Browse files Browse the repository at this point in the history
* introduce MemDB.DBSchema() method for introspection

* add comment about schema being read-only
  • Loading branch information
radeksimko authored Mar 14, 2022
1 parent 73d1a50 commit 96a58bd
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions memdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ func NewMemDB(schema *DBSchema) (*MemDB, error) {
return db, nil
}

// DBSchema returns schema in use for introspection.
//
// The method is intended for *read-only* debugging use cases,
// returned schema should *never be modified in-place*.
func (db *MemDB) DBSchema() *DBSchema {
return db.schema
}

// getRoot is used to do an atomic load of the root pointer
func (db *MemDB) getRoot() *iradix.Tree {
root := (*iradix.Tree)(atomic.LoadPointer(&db.root))
Expand Down

0 comments on commit 96a58bd

Please sign in to comment.