From 918b83bf4e098ec223d8edf1ffb5a0e43cb1ffa6 Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Wed, 8 Jan 2014 13:56:34 -0800 Subject: [PATCH] First pass at health endpoints --- consul/health_endpoint.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/consul/health_endpoint.go b/consul/health_endpoint.go index f69e233bf..b915acc49 100644 --- a/consul/health_endpoint.go +++ b/consul/health_endpoint.go @@ -1,6 +1,7 @@ package consul import ( + "fmt" "github.com/hashicorp/consul/consul/structs" ) @@ -16,7 +17,10 @@ func (h *Health) ChecksInState(args *structs.ChecksInStateRequest, return err } - // TODO + // Get the state specific checks + state := h.srv.fsm.State() + checks := state.ChecksInState(args.State) + *reply = checks return nil } @@ -27,17 +31,29 @@ func (h *Health) NodeChecks(args *structs.NodeSpecificRequest, return err } - // TODO + // Get the node checks + state := h.srv.fsm.State() + checks := state.NodeChecks(args.Node) + *reply = checks return nil } // ServiceChecks is used to get all the checks for a service func (h *Health) ServiceChecks(args *structs.ServiceSpecificRequest, reply *structs.HealthChecks) error { + // Reject if tag filtering is on + if args.TagFilter { + return fmt.Errorf("Tag filtering is not supported") + } + + // Potentially forward if done, err := h.srv.forward("Health.ServiceChecks", args.Datacenter, args, reply); done { return err } - // TODO + // Get the service checks + state := h.srv.fsm.State() + checks := state.ServiceChecks(args.ServiceName) + *reply = checks return nil }