Merge pull request #9947 from hashicorp/dnephin/state-ent-index-3
state: move indexer functions out of oss files
This commit is contained in:
commit
3df239b036
|
@ -4,7 +4,6 @@ package state
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
memdb "github.com/hashicorp/go-memdb"
|
||||
|
||||
|
@ -23,59 +22,6 @@ func aclPolicyInsert(tx *txn, policy *structs.ACLPolicy) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func indexNameFromACLPolicy(raw interface{}) ([]byte, error) {
|
||||
p, ok := raw.(*structs.ACLPolicy)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.ACLPolicy index", raw)
|
||||
}
|
||||
|
||||
if p.Name == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(p.Name))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexNameFromACLRole(raw interface{}) ([]byte, error) {
|
||||
p, ok := raw.(*structs.ACLRole)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.ACLRole index", raw)
|
||||
}
|
||||
|
||||
if p.Name == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(p.Name))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func multiIndexPolicyFromACLRole(raw interface{}) ([][]byte, error) {
|
||||
role, ok := raw.(*structs.ACLRole)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.ACLRole index", raw)
|
||||
}
|
||||
|
||||
count := len(role.Policies)
|
||||
if count == 0 {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
vals := make([][]byte, 0, count)
|
||||
for _, link := range role.Policies {
|
||||
v, err := uuidStringToBytes(link.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vals = append(vals, v)
|
||||
}
|
||||
|
||||
return vals, nil
|
||||
}
|
||||
|
||||
func aclPolicyGetByID(tx ReadTxn, id string, _ *structs.EnterpriseMeta) (<-chan struct{}, interface{}, error) {
|
||||
return tx.FirstWatch(tableACLPolicies, indexID, id)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package state
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-memdb"
|
||||
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
|
@ -126,15 +129,30 @@ func policiesTableSchema() *memdb.TableSchema {
|
|||
AllowMissing: false,
|
||||
Unique: true,
|
||||
Indexer: indexerSingleWithPrefix{
|
||||
readIndex: readIndex(indexFromQuery),
|
||||
writeIndex: writeIndex(indexNameFromACLPolicy),
|
||||
prefixIndex: prefixIndex(prefixIndexFromQuery),
|
||||
readIndex: indexFromQuery,
|
||||
writeIndex: indexNameFromACLPolicy,
|
||||
prefixIndex: prefixIndexFromQuery,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func indexNameFromACLPolicy(raw interface{}) ([]byte, error) {
|
||||
p, ok := raw.(*structs.ACLPolicy)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.ACLPolicy index", raw)
|
||||
}
|
||||
|
||||
if p.Name == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(p.Name))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func rolesTableSchema() *memdb.TableSchema {
|
||||
return &memdb.TableSchema{
|
||||
Name: tableACLRoles,
|
||||
|
@ -152,9 +170,9 @@ func rolesTableSchema() *memdb.TableSchema {
|
|||
AllowMissing: false,
|
||||
Unique: true,
|
||||
Indexer: indexerSingleWithPrefix{
|
||||
readIndex: readIndex(indexFromQuery),
|
||||
writeIndex: writeIndex(indexNameFromACLRole),
|
||||
prefixIndex: prefixIndex(prefixIndexFromQuery),
|
||||
readIndex: indexFromQuery,
|
||||
writeIndex: indexNameFromACLRole,
|
||||
prefixIndex: prefixIndexFromQuery,
|
||||
},
|
||||
},
|
||||
indexPolicies: {
|
||||
|
@ -163,14 +181,60 @@ func rolesTableSchema() *memdb.TableSchema {
|
|||
AllowMissing: true,
|
||||
Unique: false,
|
||||
Indexer: indexerMulti{
|
||||
readIndex: readIndex(indexFromUUIDQuery),
|
||||
writeIndexMulti: writeIndexMulti(multiIndexPolicyFromACLRole),
|
||||
readIndex: indexFromUUIDQuery,
|
||||
writeIndexMulti: multiIndexPolicyFromACLRole,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func indexNameFromACLRole(raw interface{}) ([]byte, error) {
|
||||
p, ok := raw.(*structs.ACLRole)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.ACLRole index", raw)
|
||||
}
|
||||
|
||||
if p.Name == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(p.Name))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromUUIDQuery(raw interface{}) ([]byte, error) {
|
||||
q, ok := raw.(Query)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for UUIDQuery index", raw)
|
||||
}
|
||||
return uuidStringToBytes(q.Value)
|
||||
}
|
||||
|
||||
func multiIndexPolicyFromACLRole(raw interface{}) ([][]byte, error) {
|
||||
role, ok := raw.(*structs.ACLRole)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.ACLRole index", raw)
|
||||
}
|
||||
|
||||
count := len(role.Policies)
|
||||
if count == 0 {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
vals := make([][]byte, 0, count)
|
||||
for _, link := range role.Policies {
|
||||
v, err := uuidStringToBytes(link.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vals = append(vals, v)
|
||||
}
|
||||
|
||||
return vals, nil
|
||||
}
|
||||
|
||||
func bindingRulesTableSchema() *memdb.TableSchema {
|
||||
return &memdb.TableSchema{
|
||||
Name: tableACLBindingRules,
|
||||
|
|
|
@ -1794,6 +1794,12 @@ type NodeServiceQuery struct {
|
|||
structs.EnterpriseMeta
|
||||
}
|
||||
|
||||
// NamespaceOrDefault exists because structs.EnterpriseMeta uses a pointer
|
||||
// receiver for this method. Remove once that is fixed.
|
||||
func (q NodeServiceQuery) NamespaceOrDefault() string {
|
||||
return q.EnterpriseMeta.NamespaceOrDefault()
|
||||
}
|
||||
|
||||
// deleteCheckTxn is the inner method used to call a health
|
||||
// check deletion within an existing transaction.
|
||||
func (s *Store) deleteCheckTxn(tx WriteTxn, idx uint64, node string, checkID types.CheckID, entMeta *structs.EnterpriseMeta) error {
|
||||
|
|
|
@ -4,7 +4,6 @@ package state
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
memdb "github.com/hashicorp/go-memdb"
|
||||
|
||||
|
@ -13,128 +12,6 @@ import (
|
|||
|
||||
func withEnterpriseSchema(_ *memdb.DBSchema) {}
|
||||
|
||||
func indexNodeServiceFromHealthCheck(raw interface{}) ([]byte, error) {
|
||||
hc, ok := raw.(*structs.HealthCheck)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.HealthCheck index", raw)
|
||||
}
|
||||
|
||||
if hc.Node == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(hc.Node))
|
||||
b.String(strings.ToLower(hc.ServiceID))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromNodeServiceQuery(arg interface{}) ([]byte, error) {
|
||||
hc, ok := arg.(NodeServiceQuery)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for NodeServiceQuery index", arg)
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(hc.Node))
|
||||
b.String(strings.ToLower(hc.Service))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromNode(raw interface{}) ([]byte, error) {
|
||||
n, ok := raw.(*structs.Node)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.Node index", raw)
|
||||
}
|
||||
|
||||
if n.Node == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(n.Node))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
// indexFromNodeQuery builds an index key where Query.Value is lowercase, and is
|
||||
// a required value.
|
||||
func indexFromNodeQuery(arg interface{}) ([]byte, error) {
|
||||
q, ok := arg.(Query)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for Query index", arg)
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(q.Value))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromNodeIdentity(raw interface{}) ([]byte, error) {
|
||||
n, ok := raw.(interface {
|
||||
NodeIdentity() structs.Identity
|
||||
})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for index, type must provide NodeIdentity()", raw)
|
||||
}
|
||||
|
||||
id := n.NodeIdentity()
|
||||
if id.ID == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(id.ID))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromServiceNode(raw interface{}) ([]byte, error) {
|
||||
n, ok := raw.(*structs.ServiceNode)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.ServiceNode index", raw)
|
||||
}
|
||||
|
||||
if n.Node == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(n.Node))
|
||||
b.String(strings.ToLower(n.ServiceID))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromHealthCheck(raw interface{}) ([]byte, error) {
|
||||
hc, ok := raw.(*structs.HealthCheck)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.HealthCheck index", raw)
|
||||
}
|
||||
|
||||
if hc.Node == "" || hc.CheckID == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(hc.Node))
|
||||
b.String(strings.ToLower(string(hc.CheckID)))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromNodeCheckID(raw interface{}) ([]byte, error) {
|
||||
hc, ok := raw.(NodeCheckQuery)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for NodeCheckQuery index", raw)
|
||||
}
|
||||
|
||||
if hc.Node == "" || hc.CheckID == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(hc.Node))
|
||||
b.String(strings.ToLower(hc.CheckID))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func serviceIndexName(name string, _ *structs.EnterpriseMeta) string {
|
||||
return fmt.Sprintf("service.%s", name)
|
||||
}
|
||||
|
|
|
@ -39,8 +39,8 @@ func nodesTableSchema() *memdb.TableSchema {
|
|||
AllowMissing: false,
|
||||
Unique: true,
|
||||
Indexer: indexerSingle{
|
||||
readIndex: readIndex(indexFromNodeQuery),
|
||||
writeIndex: writeIndex(indexFromNode),
|
||||
readIndex: indexFromQuery,
|
||||
writeIndex: indexFromNode,
|
||||
},
|
||||
},
|
||||
"uuid": {
|
||||
|
@ -62,6 +62,21 @@ func nodesTableSchema() *memdb.TableSchema {
|
|||
}
|
||||
}
|
||||
|
||||
func indexFromNode(raw interface{}) ([]byte, error) {
|
||||
n, ok := raw.(*structs.Node)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.Node index", raw)
|
||||
}
|
||||
|
||||
if n.Node == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(n.Node))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
// servicesTableSchema returns a new table schema used to store information
|
||||
// about services.
|
||||
func servicesTableSchema() *memdb.TableSchema {
|
||||
|
@ -73,9 +88,9 @@ func servicesTableSchema() *memdb.TableSchema {
|
|||
AllowMissing: false,
|
||||
Unique: true,
|
||||
Indexer: indexerSingleWithPrefix{
|
||||
readIndex: readIndex(indexFromNodeServiceQuery),
|
||||
writeIndex: writeIndex(indexFromServiceNode),
|
||||
prefixIndex: prefixIndex(prefixIndexFromQuery),
|
||||
readIndex: indexFromNodeServiceQuery,
|
||||
writeIndex: indexFromServiceNode,
|
||||
prefixIndex: prefixIndexFromQuery,
|
||||
},
|
||||
},
|
||||
indexNode: {
|
||||
|
@ -83,8 +98,8 @@ func servicesTableSchema() *memdb.TableSchema {
|
|||
AllowMissing: false,
|
||||
Unique: false,
|
||||
Indexer: indexerSingle{
|
||||
readIndex: readIndex(indexFromNodeQuery),
|
||||
writeIndex: writeIndex(indexFromNodeIdentity),
|
||||
readIndex: indexFromQuery,
|
||||
writeIndex: indexFromNodeIdentity,
|
||||
},
|
||||
},
|
||||
indexService: {
|
||||
|
@ -112,6 +127,52 @@ func servicesTableSchema() *memdb.TableSchema {
|
|||
}
|
||||
}
|
||||
|
||||
func indexFromNodeServiceQuery(arg interface{}) ([]byte, error) {
|
||||
q, ok := arg.(NodeServiceQuery)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for NodeServiceQuery index", arg)
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(q.Node))
|
||||
b.String(strings.ToLower(q.Service))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromServiceNode(raw interface{}) ([]byte, error) {
|
||||
n, ok := raw.(*structs.ServiceNode)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.ServiceNode index", raw)
|
||||
}
|
||||
|
||||
if n.Node == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(n.Node))
|
||||
b.String(strings.ToLower(n.ServiceID))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromNodeIdentity(raw interface{}) ([]byte, error) {
|
||||
n, ok := raw.(interface {
|
||||
NodeIdentity() structs.Identity
|
||||
})
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for index, type must provide NodeIdentity()", raw)
|
||||
}
|
||||
|
||||
id := n.NodeIdentity()
|
||||
if id.ID == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(id.ID))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
// checksTableSchema returns a new table schema used for storing and indexing
|
||||
// health check information. Health checks have a number of different attributes
|
||||
// we want to filter by, so this table is a bit more complex.
|
||||
|
@ -124,9 +185,9 @@ func checksTableSchema() *memdb.TableSchema {
|
|||
AllowMissing: false,
|
||||
Unique: true,
|
||||
Indexer: indexerSingleWithPrefix{
|
||||
readIndex: readIndex(indexFromNodeCheckID),
|
||||
prefixIndex: prefixIndex(prefixIndexFromQuery),
|
||||
writeIndex: writeIndex(indexFromHealthCheck),
|
||||
readIndex: indexFromNodeCheckQuery,
|
||||
writeIndex: indexFromHealthCheck,
|
||||
prefixIndex: prefixIndexFromQuery,
|
||||
},
|
||||
},
|
||||
indexStatus: {
|
||||
|
@ -152,8 +213,8 @@ func checksTableSchema() *memdb.TableSchema {
|
|||
AllowMissing: true,
|
||||
Unique: false,
|
||||
Indexer: indexerSingle{
|
||||
readIndex: readIndex(indexFromNodeQuery),
|
||||
writeIndex: writeIndex(indexFromNodeIdentity),
|
||||
readIndex: indexFromQuery,
|
||||
writeIndex: indexFromNodeIdentity,
|
||||
},
|
||||
},
|
||||
indexNodeService: {
|
||||
|
@ -161,14 +222,62 @@ func checksTableSchema() *memdb.TableSchema {
|
|||
AllowMissing: true,
|
||||
Unique: false,
|
||||
Indexer: indexerSingle{
|
||||
readIndex: readIndex(indexFromNodeServiceQuery),
|
||||
writeIndex: writeIndex(indexNodeServiceFromHealthCheck),
|
||||
readIndex: indexFromNodeServiceQuery,
|
||||
writeIndex: indexNodeServiceFromHealthCheck,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func indexFromNodeCheckQuery(raw interface{}) ([]byte, error) {
|
||||
hc, ok := raw.(NodeCheckQuery)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for NodeCheckQuery index", raw)
|
||||
}
|
||||
|
||||
if hc.Node == "" || hc.CheckID == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(hc.Node))
|
||||
b.String(strings.ToLower(hc.CheckID))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromHealthCheck(raw interface{}) ([]byte, error) {
|
||||
hc, ok := raw.(*structs.HealthCheck)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.HealthCheck index", raw)
|
||||
}
|
||||
|
||||
if hc.Node == "" || hc.CheckID == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(hc.Node))
|
||||
b.String(strings.ToLower(string(hc.CheckID)))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexNodeServiceFromHealthCheck(raw interface{}) ([]byte, error) {
|
||||
hc, ok := raw.(*structs.HealthCheck)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for structs.HealthCheck index", raw)
|
||||
}
|
||||
|
||||
if hc.Node == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(hc.Node))
|
||||
b.String(strings.ToLower(hc.ServiceID))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
// gatewayServicesTableSchema returns a new table schema used to store information
|
||||
// about services associated with terminating gateways.
|
||||
func gatewayServicesTableSchema() *memdb.TableSchema {
|
||||
|
@ -331,3 +440,9 @@ type NodeCheckQuery struct {
|
|||
CheckID string
|
||||
structs.EnterpriseMeta
|
||||
}
|
||||
|
||||
// NamespaceOrDefault exists because structs.EnterpriseMeta uses a pointer
|
||||
// receiver for this method. Remove once that is fixed.
|
||||
func (q NodeCheckQuery) NamespaceOrDefault() string {
|
||||
return q.EnterpriseMeta.NamespaceOrDefault()
|
||||
}
|
||||
|
|
|
@ -23,49 +23,6 @@ func indexFromConfigEntryKindName(arg interface{}) ([]byte, error) {
|
|||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromConfigEntry(raw interface{}) ([]byte, error) {
|
||||
c, ok := raw.(structs.ConfigEntry)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("type must be structs.ConfigEntry: %T", raw)
|
||||
}
|
||||
|
||||
if c.GetName() == "" || c.GetKind() == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(c.GetKind()))
|
||||
b.String(strings.ToLower(c.GetName()))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
// indexKindFromConfigEntry indexes kinds, it is a shim for enterprise.
|
||||
func indexKindFromConfigEntry(raw interface{}) ([]byte, error) {
|
||||
c, ok := raw.(structs.ConfigEntry)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("type must be structs.ConfigEntry: %T", raw)
|
||||
}
|
||||
|
||||
if c.GetKind() == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(c.GetKind()))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromConfigEntryKindQuery(raw interface{}) ([]byte, error) {
|
||||
q, ok := raw.(ConfigEntryKindQuery)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("type must be structs.ConfigEntry: %T", raw)
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(q.Kind))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func validateConfigEntryEnterprise(_ ReadTxn, _ structs.ConfigEntry) error {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package state
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/go-memdb"
|
||||
|
||||
"github.com/hashicorp/consul/agent/structs"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -23,9 +28,9 @@ func configTableSchema() *memdb.TableSchema {
|
|||
AllowMissing: false,
|
||||
Unique: true,
|
||||
Indexer: indexerSingleWithPrefix{
|
||||
readIndex: readIndex(indexFromConfigEntryKindName),
|
||||
writeIndex: writeIndex(indexFromConfigEntry),
|
||||
prefixIndex: prefixIndex(indexFromConfigEntryKindName),
|
||||
readIndex: indexFromConfigEntryKindName,
|
||||
writeIndex: indexFromConfigEntry,
|
||||
prefixIndex: indexFromConfigEntryKindName,
|
||||
},
|
||||
},
|
||||
indexKind: {
|
||||
|
@ -33,8 +38,8 @@ func configTableSchema() *memdb.TableSchema {
|
|||
AllowMissing: false,
|
||||
Unique: false,
|
||||
Indexer: indexerSingle{
|
||||
readIndex: readIndex(indexFromConfigEntryKindQuery),
|
||||
writeIndex: writeIndex(indexKindFromConfigEntry),
|
||||
readIndex: indexFromConfigEntryKindQuery,
|
||||
writeIndex: indexKindFromConfigEntry,
|
||||
},
|
||||
},
|
||||
indexLink: {
|
||||
|
@ -58,3 +63,47 @@ func configTableSchema() *memdb.TableSchema {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
func indexFromConfigEntry(raw interface{}) ([]byte, error) {
|
||||
c, ok := raw.(structs.ConfigEntry)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("type must be structs.ConfigEntry: %T", raw)
|
||||
}
|
||||
|
||||
if c.GetName() == "" || c.GetKind() == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(c.GetKind()))
|
||||
b.String(strings.ToLower(c.GetName()))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func indexFromConfigEntryKindQuery(raw interface{}) ([]byte, error) {
|
||||
q, ok := raw.(ConfigEntryKindQuery)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("type must be ConfigEntryKindQuery: %T", raw)
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(q.Kind))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
// indexKindFromConfigEntry indexes kinds without a namespace for any config
|
||||
// entries that span all namespaces.
|
||||
func indexKindFromConfigEntry(raw interface{}) ([]byte, error) {
|
||||
c, ok := raw.(structs.ConfigEntry)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("type must be structs.ConfigEntry: %T", raw)
|
||||
}
|
||||
|
||||
if c.GetKind() == "" {
|
||||
return nil, errMissingValueForIndex
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(c.GetKind()))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
|
|
@ -101,6 +101,12 @@ const null = "\x00"
|
|||
// indexBuilder is a buffer used to construct memdb index values.
|
||||
type indexBuilder bytes.Buffer
|
||||
|
||||
func newIndexBuilder(cap int) *indexBuilder {
|
||||
buff := make([]byte, 0, cap)
|
||||
b := bytes.NewBuffer(buff)
|
||||
return (*indexBuilder)(b)
|
||||
}
|
||||
|
||||
// String appends the string and a null terminator to the buffer.
|
||||
func (b *indexBuilder) String(v string) {
|
||||
(*bytes.Buffer)(b).WriteString(v)
|
||||
|
|
|
@ -15,6 +15,25 @@ type Query struct {
|
|||
structs.EnterpriseMeta
|
||||
}
|
||||
|
||||
// NamespaceOrDefault exists because structs.EnterpriseMeta uses a pointer
|
||||
// receiver for this method. Remove once that is fixed.
|
||||
func (q Query) NamespaceOrDefault() string {
|
||||
return q.EnterpriseMeta.NamespaceOrDefault()
|
||||
}
|
||||
|
||||
// indexFromQuery builds an index key where Query.Value is lowercase, and is
|
||||
// a required value.
|
||||
func indexFromQuery(arg interface{}) ([]byte, error) {
|
||||
q, ok := arg.(Query)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for Query index", arg)
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(q.Value))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
// uuidStringToBytes is a modified version of memdb.UUIDFieldIndex.parseString
|
||||
func uuidStringToBytes(uuid string) ([]byte, error) {
|
||||
l := len(uuid)
|
||||
|
|
|
@ -9,19 +9,6 @@ import (
|
|||
"github.com/hashicorp/consul/agent/structs"
|
||||
)
|
||||
|
||||
// indexFromQuery builds an index key where Query.Value is lowercase, and is
|
||||
// a required value.
|
||||
func indexFromQuery(arg interface{}) ([]byte, error) {
|
||||
q, ok := arg.(Query)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for Query index", arg)
|
||||
}
|
||||
|
||||
var b indexBuilder
|
||||
b.String(strings.ToLower(q.Value))
|
||||
return b.Bytes(), nil
|
||||
}
|
||||
|
||||
func prefixIndexFromQuery(arg interface{}) ([]byte, error) {
|
||||
var b indexBuilder
|
||||
switch v := arg.(type) {
|
||||
|
@ -36,11 +23,3 @@ func prefixIndexFromQuery(arg interface{}) ([]byte, error) {
|
|||
|
||||
return nil, fmt.Errorf("unexpected type %T for Query prefix index", arg)
|
||||
}
|
||||
|
||||
func indexFromUUIDQuery(raw interface{}) ([]byte, error) {
|
||||
q, ok := raw.(Query)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unexpected type %T for UUIDQuery index", raw)
|
||||
}
|
||||
return uuidStringToBytes(q.Value)
|
||||
}
|
||||
|
|
|
@ -1,111 +1,12 @@
|
|||
package state
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/go-memdb"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/hashicorp/consul/internal/testing/golden"
|
||||
)
|
||||
|
||||
// TODO: once TestNewDBSchema_Indexers has test cases for all tables and indexes
|
||||
// it is probably safe to remove this test
|
||||
func TestNewDBSchema(t *testing.T) {
|
||||
schema := newDBSchema()
|
||||
require.NoError(t, schema.Validate())
|
||||
|
||||
_, err := memdb.NewMemDB(schema)
|
||||
require.NoError(t, err)
|
||||
|
||||
actual, err := repr(schema)
|
||||
require.NoError(t, err)
|
||||
|
||||
expected := golden.Get(t, actual, stateStoreSchemaExpected)
|
||||
require.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func repr(schema *memdb.DBSchema) (string, error) {
|
||||
tables := make([]string, 0, len(schema.Tables))
|
||||
for name := range schema.Tables {
|
||||
tables = append(tables, name)
|
||||
}
|
||||
sort.Strings(tables)
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
for _, name := range tables {
|
||||
fmt.Fprintf(buf, "table=%v\n", name)
|
||||
|
||||
indexes := indexNames(schema.Tables[name])
|
||||
for _, i := range indexes {
|
||||
index := schema.Tables[name].Indexes[i]
|
||||
fmt.Fprintf(buf, " index=%v", i)
|
||||
if index.Unique {
|
||||
buf.WriteString(" unique")
|
||||
}
|
||||
if index.AllowMissing {
|
||||
buf.WriteString(" allow-missing")
|
||||
}
|
||||
buf.WriteString("\n")
|
||||
buf.WriteString(" indexer=")
|
||||
formatIndexer(buf, index.Indexer)
|
||||
buf.WriteString("\n")
|
||||
}
|
||||
buf.WriteString("\n")
|
||||
}
|
||||
|
||||
return buf.String(), nil
|
||||
}
|
||||
|
||||
func formatIndexer(buf *bytes.Buffer, indexer memdb.Indexer) {
|
||||
v := reflect.Indirect(reflect.ValueOf(indexer))
|
||||
typ := v.Type()
|
||||
buf.WriteString(typ.PkgPath() + "." + typ.Name())
|
||||
for i := 0; i < typ.NumField(); i++ {
|
||||
fmt.Fprintf(buf, " %v=", typ.Field(i).Name)
|
||||
|
||||
formatField(buf, v.Field(i))
|
||||
}
|
||||
}
|
||||
|
||||
func formatField(buf *bytes.Buffer, field reflect.Value) {
|
||||
switch field.Type().Kind() {
|
||||
case reflect.Slice:
|
||||
buf.WriteString("[")
|
||||
for j := 0; j < field.Len(); j++ {
|
||||
if j != 0 {
|
||||
buf.WriteString(", ")
|
||||
}
|
||||
// TODO: handle other types of slices
|
||||
formatIndexer(buf, field.Index(j).Interface().(memdb.Indexer))
|
||||
}
|
||||
buf.WriteString("]")
|
||||
case reflect.Func:
|
||||
// Functions are printed as pointer addresses, which change frequently.
|
||||
// Instead use the name.
|
||||
buf.WriteString(runtime.FuncForPC(field.Pointer()).Name())
|
||||
case reflect.Interface:
|
||||
formatField(buf, field.Elem())
|
||||
default:
|
||||
fmt.Fprintf(buf, "%v", field)
|
||||
}
|
||||
}
|
||||
|
||||
func indexNames(table *memdb.TableSchema) []string {
|
||||
indexes := make([]string, 0, len(table.Indexes))
|
||||
for name := range table.Indexes {
|
||||
indexes = append(indexes, name)
|
||||
}
|
||||
|
||||
sort.Strings(indexes)
|
||||
return indexes
|
||||
}
|
||||
|
||||
type indexerTestCase struct {
|
||||
read indexValue
|
||||
write indexValue
|
||||
|
|
|
@ -1,186 +0,0 @@
|
|||
table=acl-auth-methods
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=Name Lowercase=true
|
||||
|
||||
table=acl-binding-rules
|
||||
index=authmethod
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=AuthMethod Lowercase=true
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.UUIDFieldIndex Field=ID
|
||||
|
||||
table=acl-policies
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.UUIDFieldIndex Field=ID
|
||||
index=name unique
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.indexerSingleWithPrefix readIndex=github.com/hashicorp/consul/agent/consul/state.indexFromQuery writeIndex=github.com/hashicorp/consul/agent/consul/state.indexNameFromACLPolicy prefixIndex=github.com/hashicorp/consul/agent/consul/state.prefixIndexFromQuery
|
||||
|
||||
table=acl-roles
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.UUIDFieldIndex Field=ID
|
||||
index=name unique
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.indexerSingleWithPrefix readIndex=github.com/hashicorp/consul/agent/consul/state.indexFromQuery writeIndex=github.com/hashicorp/consul/agent/consul/state.indexNameFromACLRole prefixIndex=github.com/hashicorp/consul/agent/consul/state.prefixIndexFromQuery
|
||||
index=policies allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.indexerMulti readIndex=github.com/hashicorp/consul/agent/consul/state.indexFromUUIDQuery writeIndexMulti=github.com/hashicorp/consul/agent/consul/state.multiIndexPolicyFromACLRole
|
||||
|
||||
table=acl-tokens
|
||||
index=accessor unique allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.UUIDFieldIndex Field=AccessorID
|
||||
index=authmethod allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=AuthMethod Lowercase=false
|
||||
index=expires-global allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.TokenExpirationIndex LocalFilter=false
|
||||
index=expires-local allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.TokenExpirationIndex LocalFilter=true
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=SecretID Lowercase=false
|
||||
index=local
|
||||
indexer=github.com/hashicorp/go-memdb.ConditionalIndex Conditional=github.com/hashicorp/consul/agent/consul/state.tokensTableSchema.func1
|
||||
index=needs-upgrade
|
||||
indexer=github.com/hashicorp/go-memdb.ConditionalIndex Conditional=github.com/hashicorp/consul/agent/consul/state.tokensTableSchema.func2
|
||||
index=policies allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.TokenPoliciesIndex
|
||||
index=roles allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.TokenRolesIndex
|
||||
|
||||
table=autopilot-config
|
||||
index=id unique allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.ConditionalIndex Conditional=github.com/hashicorp/consul/agent/consul/state.autopilotConfigTableSchema.func1
|
||||
|
||||
table=checks
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.indexerSingleWithPrefix readIndex=github.com/hashicorp/consul/agent/consul/state.indexFromNodeCheckID writeIndex=github.com/hashicorp/consul/agent/consul/state.indexFromHealthCheck prefixIndex=github.com/hashicorp/consul/agent/consul/state.prefixIndexFromQuery
|
||||
index=node allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.indexerSingle readIndex=github.com/hashicorp/consul/agent/consul/state.indexFromNodeQuery writeIndex=github.com/hashicorp/consul/agent/consul/state.indexFromNodeIdentity
|
||||
index=node_service allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.indexerSingle readIndex=github.com/hashicorp/consul/agent/consul/state.indexFromNodeServiceQuery writeIndex=github.com/hashicorp/consul/agent/consul/state.indexNodeServiceFromHealthCheck
|
||||
index=service allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=ServiceName Lowercase=true
|
||||
index=status
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=Status Lowercase=false
|
||||
|
||||
table=config-entries
|
||||
index=id unique
|
||||
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
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.ServiceIntentionLegacyIDIndex uuidFieldIndex={}
|
||||
index=intention-source allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.ServiceIntentionSourceIndex
|
||||
index=kind
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.indexerSingle readIndex=github.com/hashicorp/consul/agent/consul/state.indexFromConfigEntryKindQuery writeIndex=github.com/hashicorp/consul/agent/consul/state.indexKindFromConfigEntry
|
||||
index=link allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.ConfigEntryLinkIndex
|
||||
|
||||
table=connect-ca-builtin
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=ID Lowercase=false
|
||||
|
||||
table=connect-ca-config
|
||||
index=id unique allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.ConditionalIndex Conditional=github.com/hashicorp/consul/agent/consul/state.caConfigTableSchema.func1
|
||||
|
||||
table=connect-ca-roots
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=ID Lowercase=false
|
||||
|
||||
table=connect-intentions
|
||||
index=destination allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.CompoundIndex Indexes=[github.com/hashicorp/go-memdb.StringFieldIndex Field=DestinationNS Lowercase=true, github.com/hashicorp/go-memdb.StringFieldIndex Field=DestinationName Lowercase=true] AllowMissing=false
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.UUIDFieldIndex Field=ID
|
||||
index=source allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.CompoundIndex Indexes=[github.com/hashicorp/go-memdb.StringFieldIndex Field=SourceNS Lowercase=true, github.com/hashicorp/go-memdb.StringFieldIndex Field=SourceName Lowercase=true] AllowMissing=false
|
||||
index=source_destination unique allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.CompoundIndex Indexes=[github.com/hashicorp/go-memdb.StringFieldIndex Field=SourceNS Lowercase=true, github.com/hashicorp/go-memdb.StringFieldIndex Field=SourceName Lowercase=true, github.com/hashicorp/go-memdb.StringFieldIndex Field=DestinationNS Lowercase=true, github.com/hashicorp/go-memdb.StringFieldIndex Field=DestinationName Lowercase=true] AllowMissing=false
|
||||
|
||||
table=coordinates
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.CompoundIndex Indexes=[github.com/hashicorp/go-memdb.StringFieldIndex Field=Node Lowercase=true, github.com/hashicorp/go-memdb.StringFieldIndex Field=Segment Lowercase=true] AllowMissing=true
|
||||
index=node
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=Node Lowercase=true
|
||||
|
||||
table=federation-states
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=Datacenter Lowercase=true
|
||||
|
||||
table=gateway-services
|
||||
index=gateway
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.ServiceNameIndex Field=Gateway
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.CompoundIndex Indexes=[github.com/hashicorp/consul/agent/consul/state.ServiceNameIndex Field=Gateway, github.com/hashicorp/consul/agent/consul/state.ServiceNameIndex Field=Service, github.com/hashicorp/go-memdb.IntFieldIndex Field=Port] AllowMissing=false
|
||||
index=service allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.ServiceNameIndex Field=Service
|
||||
|
||||
table=index
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=Key Lowercase=true
|
||||
|
||||
table=kvs
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=Key Lowercase=false
|
||||
index=session allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.UUIDFieldIndex Field=Session
|
||||
|
||||
table=mesh-topology
|
||||
index=downstream
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.ServiceNameIndex Field=Downstream
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.CompoundIndex Indexes=[github.com/hashicorp/consul/agent/consul/state.ServiceNameIndex Field=Upstream, github.com/hashicorp/consul/agent/consul/state.ServiceNameIndex Field=Downstream] AllowMissing=false
|
||||
index=upstream allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.ServiceNameIndex Field=Upstream
|
||||
|
||||
table=nodes
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.indexerSingle readIndex=github.com/hashicorp/consul/agent/consul/state.indexFromNodeQuery writeIndex=github.com/hashicorp/consul/agent/consul/state.indexFromNode
|
||||
index=meta allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.StringMapFieldIndex Field=Meta Lowercase=false
|
||||
index=uuid unique allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.UUIDFieldIndex Field=ID
|
||||
|
||||
table=prepared-queries
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.UUIDFieldIndex Field=ID
|
||||
index=name unique allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=Name Lowercase=true
|
||||
index=session allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.UUIDFieldIndex Field=Session
|
||||
index=template unique allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.PreparedQueryIndex
|
||||
|
||||
table=services
|
||||
index=connect allow-missing
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.IndexConnectService
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.indexerSingleWithPrefix readIndex=github.com/hashicorp/consul/agent/consul/state.indexFromNodeServiceQuery writeIndex=github.com/hashicorp/consul/agent/consul/state.indexFromServiceNode prefixIndex=github.com/hashicorp/consul/agent/consul/state.prefixIndexFromQuery
|
||||
index=kind
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.IndexServiceKind
|
||||
index=node
|
||||
indexer=github.com/hashicorp/consul/agent/consul/state.indexerSingle readIndex=github.com/hashicorp/consul/agent/consul/state.indexFromNodeQuery writeIndex=github.com/hashicorp/consul/agent/consul/state.indexFromNodeIdentity
|
||||
index=service allow-missing
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=ServiceName Lowercase=true
|
||||
|
||||
table=session_checks
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.CompoundIndex Indexes=[github.com/hashicorp/go-memdb.StringFieldIndex Field=Node Lowercase=true, github.com/hashicorp/consul/agent/consul/state.CheckIDIndex, github.com/hashicorp/go-memdb.UUIDFieldIndex Field=Session] AllowMissing=false
|
||||
index=node_check
|
||||
indexer=github.com/hashicorp/go-memdb.CompoundIndex Indexes=[github.com/hashicorp/go-memdb.StringFieldIndex Field=Node Lowercase=true, github.com/hashicorp/consul/agent/consul/state.CheckIDIndex] AllowMissing=false
|
||||
index=session
|
||||
indexer=github.com/hashicorp/go-memdb.UUIDFieldIndex Field=Session
|
||||
|
||||
table=sessions
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.UUIDFieldIndex Field=ID
|
||||
index=node
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=Node Lowercase=true
|
||||
|
||||
table=system-metadata
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=Key Lowercase=true
|
||||
|
||||
table=tombstones
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=Key Lowercase=false
|
||||
|
||||
table=usage
|
||||
index=id unique
|
||||
indexer=github.com/hashicorp/go-memdb.StringFieldIndex Field=ID Lowercase=true
|
||||
|
Loading…
Reference in New Issue