apphealth

package
v1.17.21 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Copyright 2024 The Dapr Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppHealth

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

AppHealth manages the health checks for the app.

func New added in v1.11.0

func New(config config.AppHealthConfig, probeFn ProbeFunction) *AppHealth

New creates a new AppHealth object.

func (*AppHealth) Close added in v1.11.0

func (h *AppHealth) Close() error

func (*AppHealth) Enqueue

func (h *AppHealth) Enqueue()

Enqueue adds a new probe request to the queue

func (*AppHealth) GetStatus

func (h *AppHealth) GetStatus() *Status

GetStatus returns the status of the app's health

func (*AppHealth) OnHealthChange

func (h *AppHealth) OnHealthChange(cb ChangeCallback)

OnHealthChange sets the callback that is invoked when the health of the app changes (app becomes either healthy or unhealthy).

func (*AppHealth) ReportHealth

func (h *AppHealth) ReportHealth(status *Status)

ReportHealth is used by the runtime to report a health signal from the app.

func (*AppHealth) StartProbes

func (h *AppHealth) StartProbes(ctx context.Context) error

StartProbes starts polling the app on the interval.

type ChangeCallback

type ChangeCallback func(ctx context.Context, status *Status)

ChangeCallback is the signature of the callback that is invoked when the app's health status changes.

type ProbeFunction

type ProbeFunction func(context.Context) (*Status, error)

ProbeFunction is the signature of the function that performs health probes. Health probe functions return errors only in case of internal errors. Network errors are considered probe failures, and should return nil as errors.

type Status added in v1.16.0

type Status struct {
	IsHealthy bool    `json:"ishealthy"`
	TimeUnix  int64   `json:"timeUnix"`
	Reason    *string `json:"reason,omitempty"`
}

func NewStatus added in v1.16.0

func NewStatus(isHealthy bool, reason *string) *Status

NewStatus returns a default status for the app. This defaults to healthy so subscriptions can start right away, because if there's no health check, then we mark the app as healthy right away so subscriptions can start.

Jump to

Keyboard shortcuts

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