Skip to content

Commit 57ff76d

Browse files
committed
db: implement fmt.Stringer on BackingType
This will be used within Cockroach to implement a custom JSON serialization of the set of sstables returned by the sstable_metrics builtin.
1 parent 5e1ab49 commit 57ff76d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

db.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,8 +2098,21 @@ const (
20982098
// or lifecycle management. An example of an external file is a file restored
20992099
// from a backup.
21002100
BackingTypeExternal
2101+
backingTypeCount
21012102
)
21022103

2104+
var backingTypeToString = [backingTypeCount]string{
2105+
BackingTypeLocal: "local",
2106+
BackingTypeShared: "shared",
2107+
BackingTypeSharedForeign: "shared-foreign",
2108+
BackingTypeExternal: "external",
2109+
}
2110+
2111+
// String implements fmt.Stringer.
2112+
func (b BackingType) String() string {
2113+
return backingTypeToString[b]
2114+
}
2115+
21032116
// SSTableInfo export manifest.TableInfo with sstable.Properties alongside
21042117
// other file backing info.
21052118
type SSTableInfo struct {

0 commit comments

Comments
 (0)