Documentation ¶
Index ¶
- type CheckGroup
- type CheckResult
- type Health
- func (h *Health) AddLiveChecker(subsystem string, check checkFunc)
- func (h *Health) AddReadyChecker(subsystem string, check checkFunc)
- func (h *Health) AddSubsystem(subsystem string, liveness, readiness checkFunc)
- func (h *Health) Heartbeat(ctx context.Context) error
- func (h *Health) Stop(ctx context.Context) error
- type Option
- func WithCheckPeriod(period time.Duration) Option
- func WithHealthzEndpoint(endpoint string) Option
- func WithLivenessTimeout(timeout time.Duration) Option
- func WithMetrics(endpoint string) Option
- func WithPProf() Option
- func WithReadinessTimeout(timeout time.Duration) Option
- func WithReadyEndpoint(endpoint string) Option
- func WithRequestTimeout(timeout time.Duration) Option
- type SubsystemStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckGroup ¶
type CheckGroup struct {
// contains filtered or unexported fields
}
CheckGroup launch checker concurrently.
func NewCheckGroup ¶
func NewCheckGroup(timeout time.Duration) *CheckGroup
NewCheckGroup returns new instacnce CheckGroup.
func (*CheckGroup) AddChecker ¶
func (g *CheckGroup) AddChecker(subsystem string, checker checkFunc)
AddChecker adds checker to CheckGroup.
func (*CheckGroup) GetDetails ¶ added in v1.0.0
func (g *CheckGroup) GetDetails() map[string]CheckResult
GetDetails returns result of checks.
func (*CheckGroup) IsOK ¶
func (g *CheckGroup) IsOK() bool
IsOK returns true if all checks passed normal.
type CheckResult ¶ added in v1.0.0
type CheckResult struct { Error error `json:"error,omitempty"` Status SubsystemStatus `json:"status"` }
type Health ¶
type Health struct {
// contains filtered or unexported fields
}
func (*Health) AddLiveChecker ¶
AddLiveChecker adds a check routine for `live` state of your service to the registry. Service health check only applies to internal components, whose state identifies the service liveness. see https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#when-should-you-use-a-liveness-probe.
func (*Health) AddReadyChecker ¶
AddReadyChecker adds a check routine for `ready` state of your service to the registry. Service readiness check only applies to external dependencies, whose state identifies the service readiness to accept load. see https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#when-should-you-use-a-readiness-probe.
func (*Health) AddSubsystem ¶ added in v1.14.1
AddSubsystem adds liveness and readiness checks for given subsystem. For more details see AddLiveChecker and AddReadChecker.
type Option ¶
type Option func(*Health)
func WithCheckPeriod ¶
WithCheckPeriod sets period of launch checks.
func WithHealthzEndpoint ¶
WithHealthzEndpoint sets custom endpoint to probe liveness.
func WithLivenessTimeout ¶
WithLivenessTimeout sets custom timeout for check liveness.
func WithMetrics ¶ added in v1.9.0
WithMetrics sets route for metrics handler.
func WithReadinessTimeout ¶
WithReadinessTimeout sets custom timeout for check readiness.
func WithReadyEndpoint ¶
WithReadyEndpoint sets custom endpoint to probe readiness.
func WithRequestTimeout ¶ added in v1.8.0
WithRequestTimeout sets http server write timeout. see: https://github.com/golang/go/blob/180bcad33dcd3d59443fe8eda5ae7556b1b2945b/src/net/http/server.go#L978-L986.
type SubsystemStatus ¶ added in v1.6.0
type SubsystemStatus string
const ( UP SubsystemStatus = "UP" DOWN SubsystemStatus = "DOWN" )