Merge pull request #12855 from ptabor/20210409-backend-hooks

(no)StoreV2 (Part 4): Backend hooks:  precommit updates consistency_index
This commit is contained in:
Piotr Tabor
2021-05-08 09:34:31 +02:00
committed by GitHub
34 changed files with 420 additions and 266 deletions

View File

@@ -106,6 +106,8 @@ type backend struct {
stopc chan struct{}
donec chan struct{}
hooks Hooks
lg *zap.Logger
}
@@ -126,6 +128,9 @@ type BackendConfig struct {
UnsafeNoFsync bool `json:"unsafe-no-fsync"`
// Mlock prevents backend database file to be swapped
Mlock bool
// Hooks are getting executed during lifecycle of Backend's transactions.
Hooks Hooks
}
func DefaultBackendConfig() BackendConfig {
@@ -192,6 +197,9 @@ func newBackend(bcfg BackendConfig) *backend {
lg: bcfg.Logger,
}
b.batchTx = newBatchTxBuffered(b)
// We set it after newBatchTxBuffered to skip the 'empty' commit.
b.hooks = bcfg.Hooks
go b.run()
return b
}