mirror of https://github.com/status-im/consul.git
Adding stubs for Health endpoints
This commit is contained in:
parent
65ad4d1c47
commit
9f0e5b99a3
|
@ -114,7 +114,7 @@ func (c *Catalog) ListServices(dc string, reply *structs.Services) error {
|
|||
}
|
||||
|
||||
// ServiceNodes returns all the nodes registered as part of a service
|
||||
func (c *Catalog) ServiceNodes(args *structs.ServiceNodesRequest, reply *structs.ServiceNodes) error {
|
||||
func (c *Catalog) ServiceNodes(args *structs.ServiceSpecificRequest, reply *structs.ServiceNodes) error {
|
||||
if done, err := c.srv.forward("Catalog.ServiceNodes", args.Datacenter, args, reply); done {
|
||||
return err
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ func (c *Catalog) ServiceNodes(args *structs.ServiceNodesRequest, reply *structs
|
|||
}
|
||||
|
||||
// NodeServices returns all the services registered as part of a node
|
||||
func (c *Catalog) NodeServices(args *structs.NodeServicesRequest, reply *structs.NodeServices) error {
|
||||
func (c *Catalog) NodeServices(args *structs.NodeSpecificRequest, reply *structs.NodeServices) error {
|
||||
if done, err := c.srv.forward("Catalog.NodeServices", args.Datacenter, args, reply); done {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -266,7 +266,7 @@ func TestCatalogListServiceNodes(t *testing.T) {
|
|||
client := rpcClient(t, s1)
|
||||
defer client.Close()
|
||||
|
||||
args := structs.ServiceNodesRequest{
|
||||
args := structs.ServiceSpecificRequest{
|
||||
Datacenter: "dc1",
|
||||
ServiceName: "db",
|
||||
ServiceTag: "slave",
|
||||
|
@ -312,7 +312,7 @@ func TestCatalogNodeServices(t *testing.T) {
|
|||
client := rpcClient(t, s1)
|
||||
defer client.Close()
|
||||
|
||||
args := structs.NodeServicesRequest{
|
||||
args := structs.NodeSpecificRequest{
|
||||
Datacenter: "dc1",
|
||||
Node: "foo",
|
||||
}
|
||||
|
@ -381,7 +381,7 @@ func TestCatalogRegister_FailedCase1(t *testing.T) {
|
|||
}
|
||||
|
||||
// Check we can get this back
|
||||
query := &structs.ServiceNodesRequest{
|
||||
query := &structs.ServiceSpecificRequest{
|
||||
Datacenter: "dc1",
|
||||
ServiceName: "web",
|
||||
}
|
||||
|
|
|
@ -13,8 +13,6 @@ methods. The services exposed are:
|
|||
The Raft service is used to manipulate the Raft controls on the Leader
|
||||
node. It is only for internal use. It exposes the following methods:
|
||||
|
||||
* Apply : Used to execute a command against the FSM
|
||||
* AddPeer: Used to add a peer to the group
|
||||
* RemovePeer: Used to remove a peer from the group
|
||||
|
||||
## Status Service
|
||||
|
@ -32,8 +30,8 @@ The catalog service is used to manage service discovery and registration.
|
|||
Nodes can register the services they provide, and deregister them later.
|
||||
The service exposes the following methods:
|
||||
|
||||
* Register : Registers a node, and potentially a node service
|
||||
* Deregister : Deregisters a node, and potentially a node service
|
||||
* Register : Registers a node, and potentially a node service and check
|
||||
* Deregister : Deregisters a node, and potentially a node service or check
|
||||
|
||||
* ListDatacenters: List the known datacenters
|
||||
* ListServices : Lists the available services
|
||||
|
@ -47,11 +45,7 @@ The health service is used to manage health checking. Nodes have system
|
|||
health checks, as well as application health checks. This service is used to
|
||||
query health information, as well as for nodes to publish changes.
|
||||
|
||||
* CheckPass : Used to inform that a check has passed
|
||||
* CheckWarn : Used to inform that a check is warning
|
||||
* CheckFail : Used to inform that a check has failed
|
||||
* RemoveCheck : Used to remove a health check
|
||||
|
||||
* CheckInState : Gets the checks that in a given state
|
||||
* ChecksInState : Gets the checks that in a given state
|
||||
* NodeChecks: Gets the checks a given node has
|
||||
* ServiceChecks: Gets the checks a given service has
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package consul
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/consul/consul/structs"
|
||||
)
|
||||
|
||||
// Health endpoint is used to query the health information
|
||||
type Health struct {
|
||||
srv *Server
|
||||
}
|
||||
|
||||
// ChecksInState is used to get all the checks in a given state
|
||||
func (h *Health) ChecksInState(args *structs.ChecksInStateRequest,
|
||||
reply *structs.HealthChecks) error {
|
||||
if done, err := h.srv.forward("Health.ChecksInState", args.Datacenter, args, reply); done {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO
|
||||
return nil
|
||||
}
|
||||
|
||||
// NodeChecks is used to get all the checks for a node
|
||||
func (h *Health) NodeChecks(args *structs.NodeSpecificRequest,
|
||||
reply *structs.HealthChecks) error {
|
||||
if done, err := h.srv.forward("Health.NodeChecks", args.Datacenter, args, reply); done {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO
|
||||
return nil
|
||||
}
|
||||
|
||||
// ServiceChecks is used to get all the checks for a service
|
||||
func (h *Health) ServiceChecks(args *structs.ServiceSpecificRequest,
|
||||
reply *structs.HealthChecks) error {
|
||||
if done, err := h.srv.forward("Health.ServiceChecks", args.Datacenter, args, reply); done {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO
|
||||
return nil
|
||||
}
|
|
@ -58,8 +58,8 @@ type Nodes []Node
|
|||
// Maps service name to available tags
|
||||
type Services map[string][]string
|
||||
|
||||
// ServiceNodesRequest is used to query the nodes of a service
|
||||
type ServiceNodesRequest struct {
|
||||
// ServiceSpecificRequest is used to query about a specific node
|
||||
type ServiceSpecificRequest struct {
|
||||
Datacenter string
|
||||
ServiceName string
|
||||
ServiceTag string
|
||||
|
@ -77,8 +77,8 @@ type ServiceNode struct {
|
|||
}
|
||||
type ServiceNodes []ServiceNode
|
||||
|
||||
// NodeServiceRequest is used to request the services of a node
|
||||
type NodeServicesRequest struct {
|
||||
// NodeSpecificRequest is used to request the information about a single node
|
||||
type NodeSpecificRequest struct {
|
||||
Datacenter string
|
||||
Node string
|
||||
}
|
||||
|
@ -107,6 +107,12 @@ type HealthCheck struct {
|
|||
}
|
||||
type HealthChecks []*HealthCheck
|
||||
|
||||
// ChecksInStateRequest is used to query for nodes in a state
|
||||
type ChecksInStateRequest struct {
|
||||
Datacenter string
|
||||
State string
|
||||
}
|
||||
|
||||
// Decode is used to decode a MsgPack encoded object
|
||||
func Decode(buf []byte, out interface{}) error {
|
||||
var handle codec.MsgpackHandle
|
||||
|
|
Loading…
Reference in New Issue