From 490abc75a64d19f6b6a7f011fbafe8f2ac0c4841 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Wed, 8 Jan 2014 14:43:36 -0800 Subject: [PATCH] Minor structs cleanup --- consul/catalog_endpoint_test.go | 2 +- consul/state_store.go | 2 +- consul/structs/structs.go | 46 +++++++++++++++++++-------------- 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/consul/catalog_endpoint_test.go b/consul/catalog_endpoint_test.go index 1f4a57908..85fa6a141 100644 --- a/consul/catalog_endpoint_test.go +++ b/consul/catalog_endpoint_test.go @@ -334,7 +334,7 @@ func TestCatalogNodeServices(t *testing.T) { t.Fatalf("err: %v", err) } - if out.Address != "127.0.0.1" { + if out.Node.Address != "127.0.0.1" { t.Fatalf("bad: %v", out) } if len(out.Services) != 2 { diff --git a/consul/state_store.go b/consul/state_store.go index 26745007e..cbdc49053 100644 --- a/consul/state_store.go +++ b/consul/state_store.go @@ -279,7 +279,7 @@ func (s *StateStore) parseNodeServices(tx *MDBTxn, name string) *structs.NodeSer // Set the address node := res[0].(*structs.Node) - ns.Address = node.Address + ns.Node = *node // Get the services res, err = s.serviceTable.GetTxn(tx, "id", name) diff --git a/consul/structs/structs.go b/consul/structs/structs.go index 318145e75..2c86a187d 100644 --- a/consul/structs/structs.go +++ b/consul/structs/structs.go @@ -47,6 +47,26 @@ type DeregisterRequest struct { CheckID string } +// ServiceSpecificRequest is used to query about a specific node +type ServiceSpecificRequest struct { + Datacenter string + ServiceName string + ServiceTag string + TagFilter bool // Controls tag filtering +} + +// NodeSpecificRequest is used to request the information about a single node +type NodeSpecificRequest struct { + Datacenter string + Node string +} + +// ChecksInStateRequest is used to query for nodes in a state +type ChecksInStateRequest struct { + Datacenter string + State string +} + // Used to return information about a node type Node struct { Node string @@ -58,14 +78,6 @@ type Nodes []Node // Maps service name to available tags type Services map[string][]string -// ServiceSpecificRequest is used to query about a specific node -type ServiceSpecificRequest struct { - Datacenter string - ServiceName string - ServiceTag string - TagFilter bool // Controls tag filtering -} - // ServiceNode represents a node that is part of a service type ServiceNode struct { Node string @@ -77,12 +89,6 @@ type ServiceNode struct { } type ServiceNodes []ServiceNode -// NodeSpecificRequest is used to request the information about a single node -type NodeSpecificRequest struct { - Datacenter string - Node string -} - // NodeService is a service provided by a node type NodeService struct { ID string @@ -91,7 +97,7 @@ type NodeService struct { Port int } type NodeServices struct { - Address string + Node Node Services map[string]*NodeService } @@ -107,10 +113,12 @@ type HealthCheck struct { } type HealthChecks []*HealthCheck -// ChecksInStateRequest is used to query for nodes in a state -type ChecksInStateRequest struct { - Datacenter string - State string +// NodeServiceStatus is used to provide the node, it's service +// definition, as well as a HealthCheck that is associated +type NodeServiceStatus struct { + Node Node + Service NodeService + Check HealthCheck } // Decode is used to decode a MsgPack encoded object