healthcheck

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BucketSubCheck

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

BucketSubCheck is a subcheck for GCS bucket.

func WithBucketCheck

func WithBucketCheck(bucket *storage.BucketHandle) *BucketSubCheck

WithBucketCheck returns a BucketSubCheck.

type CheckStatus

type CheckStatus int

CheckStatus is a type to represent check status.

const (
	// StatusOK represents normal status.
	StatusOK CheckStatus = iota
	// StatusWarn represents warning status.
	StatusWarn
	// StatusError represents errored status.
	StatusError
)

func (CheckStatus) MarshalJSON

func (c CheckStatus) MarshalJSON() ([]byte, error)

MarshalJSON returns json of the status as string.

func (CheckStatus) String

func (c CheckStatus) String() string

String returns status as a string.

type HealthCheck

type HealthCheck struct {
	healthgrpc.UnimplementedHealthServer
	// contains filtered or unexported fields
}

HealthCheck is a subchecks runner and exposer as HTTP and GRPC handlers.

func (*HealthCheck) AddSubcheck

func (hc *HealthCheck) AddSubcheck(check Subcheck)

AddSubcheck adds new subcheck.

func (*HealthCheck) Check

Check runs the healthcheck.

func (*HealthCheck) EnableMetrics

func (hc *HealthCheck) EnableMetrics()

EnableMetrics enables metrics collection.

func (*HealthCheck) GRPCRegisterService

func (hc *HealthCheck) GRPCRegisterService(s grpc.ServiceRegistrar)

GRPCRegisterService registers GRPC method implementations in GRPC server.

func (*HealthCheck) Register

func (hc *HealthCheck) Register(s grpc.ServiceRegistrar)

Register registers GRPC method implementations in GRPC server.

func (*HealthCheck) Run

func (hc *HealthCheck) Run(ctx context.Context) *Response

Run runs all subchecks and returns Response.

func (*HealthCheck) ServeHTTP

func (hc *HealthCheck) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is an HTTP Handler.

func (*HealthCheck) SetName

func (hc *HealthCheck) SetName(name string)

SetName sets healthcheck name (used for metrics).

func (*HealthCheck) Shutdown

func (hc *HealthCheck) Shutdown(_ context.Context) error

Shutdown forces healthcheck to fail always. Used for graceful shutdown.

func (*HealthCheck) String

func (hc *HealthCheck) String() string

String returns healthcheck name.

type IRedisClient

type IRedisClient interface {
	fmt.Stringer

	Ping(ctx context.Context) IRedisCmd
}

IRedisClient is an interface for redis client.

type IRedisCmd

type IRedisCmd interface {
	Err() error
}

IRedisCmd is an interface for redis command.

type RedisSubCheck

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

RedisSubCheck is a subcheck for Redis.

func WithRedisCheck

func WithRedisCheck(client IRedisClient, warn bool) *RedisSubCheck

WithRedisCheck returns a RedisSubCheck.

type Response

type Response struct {
	Status   CheckStatus         `json:"status"`
	Checks   []*SubcheckResponse `json:"checks"`
	Duration float64             `json:"duration_seconds"`
}

Response is a struct for storing complete healthcheck response.

type SpannerSubCheck

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

SpannerSubCheck is a subcheck for Cloud Spanner.

func WithSpannerCheck

func WithSpannerCheck(client *spanner.Client) *SpannerSubCheck

WithSpannerCheck returns a SpannerSubCheck.

type Subcheck

type Subcheck interface {
	// contains filtered or unexported methods
}

Subcheck is an interface to run individual check.

type SubcheckResponse

type SubcheckResponse struct {
	Name     string      `json:"name"`
	Status   CheckStatus `json:"status"`
	Error    string      `json:"error,omitempty"`
	Duration float64     `json:"duration_seconds"`
}

SubcheckResponse is a struct for storing subcheck response.

Jump to

Keyboard shortcuts

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