health

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker 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
}

Checker represents logic of making the health check.

type DisabledChecker

type DisabledChecker struct{}

DisabledChecker implements Checker interface simply returns error value of passed context.

func NewDisabledChecker

func NewDisabledChecker() *DisabledChecker

NewDisabledChecker returns a pointer to a new instance of DisabledChecker struct.

func (*DisabledChecker) Health

func (c *DisabledChecker) Health(ctx context.Context) error

type MultiChecker

type MultiChecker struct {
	// contains filtered or unexported fields
}

MultiChecker takes several health checker and performs health checks for each of them concurrently.

func NewMultiChecker

func NewMultiChecker(hcs ...Checker) *MultiChecker

NewMultiChecker takes several health checkers and performs health checks for each of them concurrently.

func (*MultiChecker) Add

func (c *MultiChecker) Add(hc Checker)

Add appends health Checker to internal slice of HealthCheckers.

func (*MultiChecker) Health

func (c *MultiChecker) Health(ctx context.Context) error

type Synchronizer

type Synchronizer struct {
	// contains filtered or unexported fields
}

Synchronizer holds synchronization mechanics.

func (*Synchronizer) Add

func (s *Synchronizer) Add(delta int)

Add wraps the sync.WaitGroup Add method.

func (*Synchronizer) Cancel

func (s *Synchronizer) Cancel()

Cancel calls underlying cancel function to cancel context, which passed to all health checks function.

func (*Synchronizer) Do

func (s *Synchronizer) Do(f func())

Do wraps the sync.Once Do method.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL