[#1992] writecache: Allow to open in NOSYNC mode

Applicable only to FSTree as we cannot handle corrupted databases
properly yet.

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-10-28 13:09:38 +03:00 committed by fyrchik
parent b6930f2219
commit 98a152256b
8 changed files with 33 additions and 9 deletions

View file

@ -50,6 +50,8 @@ type options struct {
maxBatchSize int
// maxBatchDelay is the maximum batch wait time for the small object database.
maxBatchDelay time.Duration
// noSync is true iff FSTree allows unsynchronized writes.
noSync bool
}
// WithLogger sets logger.
@ -130,3 +132,13 @@ func WithMaxBatchDelay(d time.Duration) Option {
}
}
}
// WithNoSync sets an option to allow returning to caller on PUT before write is persisted.
// Note, that we use this flag for FSTree only and DO NOT use it for a bolt DB because
// we cannot yet properly handle the corrupted database during the startup. This SHOULD NOT
// be relied upon and may be changed in future.
func WithNoSync(noSync bool) Option {
return func(o *options) {
o.noSync = noSync
}
}