open-consul/agent/consul/state/graveyard_oss.go
2019-11-25 12:57:35 -05:00

29 lines
620 B
Go

// +build !consulent
package state
import (
"fmt"
"github.com/hashicorp/go-memdb"
)
func (g *Graveyard) insertTombstoneWithTxn(tx *memdb.Txn,
table string, stone *Tombstone, updateMax bool) error {
if err := tx.Insert("tombstones", stone); err != nil {
return err
}
if updateMax {
if err := indexUpdateMaxTxn(tx, stone.Index, "tombstones"); err != nil {
return fmt.Errorf("failed updating tombstone index: %v", err)
}
} else {
if err := tx.Insert("index", &IndexEntry{"tombstones", stone.Index}); err != nil {
return fmt.Errorf("failed updating tombstone index: %s", err)
}
}
return nil
}