mirror of https://github.com/status-im/consul.git
Rename `nodeName` to `nodeNameOrID`.
This commit is contained in:
parent
13fb395010
commit
e86cefe640
|
@ -681,7 +681,7 @@ func (s *StateStore) NodeService(nodeName string, serviceID string) (uint64, *st
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeServices is used to query service registrations by node ID.
|
// NodeServices is used to query service registrations by node ID.
|
||||||
func (s *StateStore) NodeServices(ws memdb.WatchSet, nodeName string) (uint64, *structs.NodeServices, error) {
|
func (s *StateStore) NodeServices(ws memdb.WatchSet, nodeNameOrID string) (uint64, *structs.NodeServices, error) {
|
||||||
tx := s.db.Txn(false)
|
tx := s.db.Txn(false)
|
||||||
defer tx.Abort()
|
defer tx.Abort()
|
||||||
|
|
||||||
|
@ -689,16 +689,16 @@ func (s *StateStore) NodeServices(ws memdb.WatchSet, nodeName string) (uint64, *
|
||||||
idx := maxIndexTxn(tx, "nodes", "services")
|
idx := maxIndexTxn(tx, "nodes", "services")
|
||||||
|
|
||||||
// Query the node by node name
|
// Query the node by node name
|
||||||
watchCh, n, err := tx.FirstWatch("nodes", "id", nodeName)
|
watchCh, n, err := tx.FirstWatch("nodes", "id", nodeNameOrID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, fmt.Errorf("node lookup failed: %s", err)
|
return 0, nil, fmt.Errorf("node lookup failed: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if n == nil {
|
if n == nil {
|
||||||
if len(nodeName) >= minUUIDLookupLen {
|
if len(nodeNameOrID) >= minUUIDLookupLen {
|
||||||
// Attempt to lookup the node by it's node ID
|
// Attempt to lookup the node by it's node ID
|
||||||
var idWatchCh <-chan struct{}
|
var idWatchCh <-chan struct{}
|
||||||
idWatchCh, n, err = tx.FirstWatch("nodes", "uuid_prefix", nodeName)
|
idWatchCh, n, err = tx.FirstWatch("nodes", "uuid_prefix", nodeNameOrID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, fmt.Errorf("node ID lookup failed: %s", err)
|
return 0, nil, fmt.Errorf("node ID lookup failed: %s", err)
|
||||||
}
|
}
|
||||||
|
@ -719,9 +719,9 @@ func (s *StateStore) NodeServices(ws memdb.WatchSet, nodeName string) (uint64, *
|
||||||
node := n.(*structs.Node)
|
node := n.(*structs.Node)
|
||||||
|
|
||||||
// Read all of the services
|
// Read all of the services
|
||||||
services, err := tx.Get("services", "node", nodeName)
|
services, err := tx.Get("services", "node", nodeNameOrID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, nil, fmt.Errorf("failed querying services for node %q: %s", nodeName, err)
|
return 0, nil, fmt.Errorf("failed querying services for node %q: %s", nodeNameOrID, err)
|
||||||
}
|
}
|
||||||
ws.Add(services.WatchCh())
|
ws.Add(services.WatchCh())
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue