multi: add reset closure to kvdb.View
This commit adds a reset() closure to the kvdb.View function which will be called before each retry (including the first) of the view transaction. The reset() closure can be used to reset external state (eg slices or maps) where the view closure puts intermediate results.
This commit is contained in:
47 files changed
+340
-82
No files matched your search
+3
-1
@@ -23,10 +23,12 @@ type Meta struct {
|
||||
// FetchMeta fetches the meta data from boltdb and returns filled meta
|
||||
// structure.
|
||||
func (d *DB) FetchMeta(tx kvdb.RTx) (*Meta, error) {
|
||||
meta := &Meta{}
|
||||
var meta *Meta
|
||||
|
||||
err := kvdb.View(d, func(tx kvdb.RTx) error {
|
||||
return fetchMeta(meta, tx)
|
||||
}, func() {
|
||||
meta = &Meta{}
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user