mirror of https://github.com/status-im/consul.git
state: remove config-entries namespace index
Use a prefix of the ID index instead.
This commit is contained in:
parent
d70bbf671a
commit
aadf187094
|
@ -44,11 +44,11 @@ func validateConfigEntryEnterprise(_ ReadTxn, _ structs.ConfigEntry) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getAllConfigEntriesWithTxn(tx ReadTxn, _ *structs.EnterpriseMeta) (memdb.ResultIterator, error) {
|
func getAllConfigEntriesWithTxn(tx ReadTxn, _ *structs.EnterpriseMeta) (memdb.ResultIterator, error) {
|
||||||
return tx.Get(tableConfigEntries, "id")
|
return tx.Get(tableConfigEntries, indexID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getConfigEntryKindsWithTxn(tx ReadTxn, kind string, _ *structs.EnterpriseMeta) (memdb.ResultIterator, error) {
|
func getConfigEntryKindsWithTxn(tx ReadTxn, kind string, _ *structs.EnterpriseMeta) (memdb.ResultIterator, error) {
|
||||||
return tx.Get(tableConfigEntries, "kind", kind)
|
return tx.Get(tableConfigEntries, indexKind, kind)
|
||||||
}
|
}
|
||||||
|
|
||||||
func configIntentionsConvertToList(iter memdb.ResultIterator, _ *structs.EnterpriseMeta) structs.Intentions {
|
func configIntentionsConvertToList(iter memdb.ResultIterator, _ *structs.EnterpriseMeta) structs.Intentions {
|
||||||
|
|
|
@ -22,9 +22,10 @@ func configTableSchema() *memdb.TableSchema {
|
||||||
Name: indexID,
|
Name: indexID,
|
||||||
AllowMissing: false,
|
AllowMissing: false,
|
||||||
Unique: true,
|
Unique: true,
|
||||||
Indexer: indexerSingle{
|
Indexer: indexerSingleWithPrefix{
|
||||||
readIndex: readIndex(indexFromConfigEntryKindName),
|
readIndex: readIndex(indexFromConfigEntryKindName),
|
||||||
writeIndex: writeIndex(indexFromConfigEntry),
|
writeIndex: writeIndex(indexFromConfigEntry),
|
||||||
|
prefixIndex: prefixIndex(indexFromConfigEntryKindName),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
indexKind: {
|
indexKind: {
|
||||||
|
|
|
@ -30,6 +30,13 @@ type indexerMulti struct {
|
||||||
writeIndexMulti
|
writeIndexMulti
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// indexerSingleWithPrefix is a indexerSingle which also supports prefix queries.
|
||||||
|
type indexerSingleWithPrefix struct {
|
||||||
|
readIndex
|
||||||
|
writeIndex
|
||||||
|
prefixIndex
|
||||||
|
}
|
||||||
|
|
||||||
// readIndex implements memdb.Indexer. It exists so that a function can be used
|
// readIndex implements memdb.Indexer. It exists so that a function can be used
|
||||||
// to provide the interface.
|
// to provide the interface.
|
||||||
//
|
//
|
||||||
|
@ -78,6 +85,17 @@ func (f writeIndexMulti) FromObject(raw interface{}) (bool, [][]byte, error) {
|
||||||
return err == nil, v, err
|
return err == nil, v, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// prefixIndex implements memdb.PrefixIndexer. It exists so that a function
|
||||||
|
// can be used to provide this interface.
|
||||||
|
type prefixIndex func(args interface{}) ([]byte, error)
|
||||||
|
|
||||||
|
func (f prefixIndex) PrefixFromArgs(args ...interface{}) ([]byte, error) {
|
||||||
|
if len(args) != 1 {
|
||||||
|
return nil, fmt.Errorf("index supports only a single arg")
|
||||||
|
}
|
||||||
|
return f(args[0])
|
||||||
|
}
|
||||||
|
|
||||||
const null = "\x00"
|
const null = "\x00"
|
||||||
|
|
||||||
// indexBuilder is a buffer used to construct memdb index values.
|
// indexBuilder is a buffer used to construct memdb index values.
|
||||||
|
|
|
@ -60,7 +60,7 @@ table=checks
|
||||||
|
|
||||||
table=config-entries
|
table=config-entries
|
||||||
index=id unique
|
index=id unique
|
||||||
indexer=github.com/hashicorp/consul/agent/consul/state.indexerSingle readIndex=github.com/hashicorp/consul/agent/consul/state.indexFromConfigEntryKindName writeIndex=github.com/hashicorp/consul/agent/consul/state.indexFromConfigEntry
|
indexer=github.com/hashicorp/consul/agent/consul/state.indexerSingleWithPrefix readIndex=github.com/hashicorp/consul/agent/consul/state.indexFromConfigEntryKindName writeIndex=github.com/hashicorp/consul/agent/consul/state.indexFromConfigEntry prefixIndex=github.com/hashicorp/consul/agent/consul/state.indexFromConfigEntryKindName
|
||||||
index=intention-legacy-id unique allow-missing
|
index=intention-legacy-id unique allow-missing
|
||||||
indexer=github.com/hashicorp/consul/agent/consul/state.ServiceIntentionLegacyIDIndex uuidFieldIndex={}
|
indexer=github.com/hashicorp/consul/agent/consul/state.ServiceIntentionLegacyIDIndex uuidFieldIndex={}
|
||||||
index=intention-source allow-missing
|
index=intention-source allow-missing
|
||||||
|
|
Loading…
Reference in New Issue