First pass at health endpoints

This commit is contained in:
Armon Dadgar 2014-01-08 13:56:34 -08:00
parent dff6b6e3c5
commit 918b83bf4e
1 changed files with 19 additions and 3 deletions

View File

@ -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
}