channeldb/db: adds optional dry-run abort for migrations

This commit is contained in:
Conner Fromknecht committed 2020-05-11 15:38:45 -07:00
1 parent f3a427724b
commit c775819372
4 files changed
+87 -4

No files matched your search

+12
View File
@@ -31,6 +31,10 @@ type Options struct {
// clock is the time source used by the database.
clock clock.Clock
// dryRun will fail to commit a successful migration when opening the
// database if set to true.
dryRun bool
}
// DefaultOptions returns an Options populated with default values.
@@ -73,3 +77,11 @@ func OptionClock(clock clock.Clock) OptionModifier {
o.clock = clock
}
}
// OptionDryRunMigration controls whether or not to intentially fail to commit a
// successful migration that occurs when opening the database.
func OptionDryRunMigration(dryRun bool) OptionModifier {
return func(o *Options) {
o.dryRun = dryRun
}
}