Documentation
¶
Overview ¶
Package hc represents logic of making the health check.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HealthChecker ¶
type HealthChecker interface {
// Health takes the context and performs the health check.
// Returns nil in case of success or an error in case
// of a failure.
Health(ctx context.Context) error
}
HealthChecker represents logic of making the health check.
type MultiChecker ¶
type MultiChecker struct {
// contains filtered or unexported fields
}
MultiChecker takes multiple health checker and performs health checks for each of them concurrently.
func NewMultiChecker ¶
func NewMultiChecker(hcs ...HealthChecker) *MultiChecker
NewMultiChecker takes several health checkers and performs health checks for each of them concurrently.
func (*MultiChecker) Add ¶ added in v0.1.3
func (c *MultiChecker) Add(hc HealthChecker)
Add appends health HealthChecker to internal slice of HealthCheckers.
type MultiServiceChecker ¶ added in v0.2.0
type MultiServiceChecker struct {
// contains filtered or unexported fields
}
MultiServiceChecker implements the HealthChecker interface for checking multiple services.
func NewMultiServiceChecker ¶ added in v0.2.0
func NewMultiServiceChecker(report *ServiceReport) *MultiServiceChecker
NewMultiServiceChecker creates a new MultiServiceChecker with the given services.
func (*MultiServiceChecker) AddService ¶ added in v0.2.0
func (c *MultiServiceChecker) AddService(name string, checker HealthChecker)
AddService adds a service to be checked.
func (*MultiServiceChecker) Health ¶ added in v0.2.0
func (c *MultiServiceChecker) Health(ctx context.Context) error
Health implements the HealthChecker interface.
func (*MultiServiceChecker) Report ¶ added in v0.2.1
func (c *MultiServiceChecker) Report() *ServiceReport
Report returns a service report.
type NopChecker ¶ added in v0.1.4
type NopChecker struct{}
NopChecker represents nop health checker.
func NewNopChecker ¶ added in v0.1.5
func NewNopChecker() NopChecker
NewNopChecker returns new instance of NopChecker.
type ServiceReport ¶ added in v0.2.0
type ServiceReport struct {
// contains filtered or unexported fields
}
ServiceReport contains the status of all services.
func NewServiceReport ¶ added in v0.2.0
func NewServiceReport() *ServiceReport
NewServiceReport creates a new ServiceReport.
func (*ServiceReport) GetStatuses ¶ added in v0.2.0
func (r *ServiceReport) GetStatuses() map[string]ServiceStatus
GetStatuses returns a copy of all service statuses.
type ServiceStatus ¶ added in v0.2.0
ServiceStatus represents the status of a service health check.
type Synchronizer ¶
type Synchronizer struct {
// contains filtered or unexported fields
}
Synchronizer holds synchronization mechanics. Deprecated: Use errgroup.Group instead.
func (*Synchronizer) Add ¶
func (s *Synchronizer) Add(delta int)
Add wraps the sync.WaitGroup Add method.
func (*Synchronizer) Cancel ¶ added in v0.1.2
func (s *Synchronizer) Cancel()
Cancel calls underlying cancel function to cancel context, which passed to all health checks function.
func (*Synchronizer) Done ¶
func (s *Synchronizer) Done()
Done wraps the sync.WaitGroup Done method.
func (*Synchronizer) Error ¶
func (s *Synchronizer) Error() string
Error returns a string representation of underlying error. Implements builtin error interface.
func (*Synchronizer) SetError ¶
func (s *Synchronizer) SetError(err error)
SetError sets an error to the Synchronizer structure. Uses sync.Once to set error only once.
func (*Synchronizer) Wait ¶
func (s *Synchronizer) Wait()
Wait wraps the sync.WaitGroup Wait method.