Documentation ¶
Index ¶
- type BucketSubCheck
- type CheckStatus
- type HealthCheck
- func (hc *HealthCheck) AddSubcheck(check Subcheck)
- func (hc *HealthCheck) Check(ctx context.Context, _ *healthgrpc.HealthCheckRequest) (*healthgrpc.HealthCheckResponse, error)
- func (hc *HealthCheck) EnableMetrics()
- func (hc *HealthCheck) GRPCRegisterService(s grpc.ServiceRegistrar)
- func (hc *HealthCheck) Register(s grpc.ServiceRegistrar)
- func (hc *HealthCheck) Run(ctx context.Context) *Response
- func (hc *HealthCheck) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (hc *HealthCheck) SetName(name string)
- func (hc *HealthCheck) Shutdown(_ context.Context) error
- func (hc *HealthCheck) String() string
- type IRedisClient
- type IRedisCmd
- type RedisSubCheck
- type Response
- type SpannerSubCheck
- type Subcheck
- type SubcheckResponse
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.
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 ¶
func (hc *HealthCheck) Check(ctx context.Context, _ *healthgrpc.HealthCheckRequest) (*healthgrpc.HealthCheckResponse, error)
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 ¶
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.