open-consul/agent/consul/state/coordinate_oss.go
R.B. Boyer e50e13d2ab
state: partition nodes and coordinates in the state store (#10859)
Additionally:

- partitioned the catalog indexes appropriately for partitioning
- removed a stray reference to a non-existent index named "node.checks"
2021-08-17 13:29:39 -05:00

37 lines
956 B
Go

// +build !consulent
package state
import (
"fmt"
"github.com/hashicorp/consul/agent/structs"
)
func coordinatesMaxIndex(tx ReadTxn, entMeta *structs.EnterpriseMeta) uint64 {
return maxIndexTxn(tx, tableCoordinates)
}
func updateCoordinatesIndexes(tx WriteTxn, idx uint64, entMeta *structs.EnterpriseMeta) error {
// Update the index.
if err := indexUpdateMaxTxn(tx, idx, tableCoordinates); err != nil {
return fmt.Errorf("failed updating index: %s", err)
}
return nil
}
func ensureCoordinateTxn(tx WriteTxn, idx uint64, coord *structs.Coordinate) error {
// ensure that the Partition is always empty within the state store
coord.Partition = ""
if err := tx.Insert(tableCoordinates, coord); err != nil {
return fmt.Errorf("failed inserting coordinate: %s", err)
}
if err := updateCoordinatesIndexes(tx, idx, coord.GetEnterpriseMeta()); err != nil {
return fmt.Errorf("failed updating coordinate index: %s", err)
}
return nil
}