health

package
v0.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Interval between health checks
	CheckInterval time.Duration `json:"check_interval" yaml:"check_interval"`
	// Interval between blockchain submissions
	ReportInterval time.Duration `json:"report_interval" yaml:"report_interval"`
	// Whether to enable health reporting
	Enabled bool `json:"enabled" yaml:"enabled"`
	// Provider address
	ProviderAddress string `json:"provider_address" yaml:"provider_address"`
}

Config holds configuration for the health reporter

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default configuration

type HealthChecker

type HealthChecker interface {
	// CheckLeaseHealth checks the health of all containers for a lease
	CheckLeaseHealth(ctx context.Context, leaseID mv1.LeaseID) (*LeaseHealth, error)
	// GetActiveLeases returns all active leases for this provider
	GetActiveLeases(ctx context.Context) ([]mv1.LeaseID, error)
}

HealthChecker is the interface for checking container health

type HealthStatus

type HealthStatus string

HealthStatus represents the health status of a lease

const (
	HealthStatusHealthy  HealthStatus = "healthy"
	HealthStatusDegraded HealthStatus = "degraded"
	HealthStatusFailed   HealthStatus = "failed"
	HealthStatusUnknown  HealthStatus = "unknown"
)

type KubeHealthChecker

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

KubeHealthChecker checks health of containers via Kubernetes API

func NewKubeHealthChecker

func NewKubeHealthChecker(
	client kubernetes.Interface,
	logger log.Logger,
	providerAddress string,
) *KubeHealthChecker

NewKubeHealthChecker creates a new Kubernetes health checker

func (*KubeHealthChecker) CheckLeaseHealth

func (c *KubeHealthChecker) CheckLeaseHealth(ctx context.Context, leaseID mv1.LeaseID) (*LeaseHealth, error)

CheckLeaseHealth checks the health of all containers for a lease

func (*KubeHealthChecker) GetActiveLeases

func (c *KubeHealthChecker) GetActiveLeases(ctx context.Context) ([]mv1.LeaseID, error)

GetActiveLeases returns all active leases for this provider This is a simplified implementation - actual implementation would query the provider's lease tracking system

func (*KubeHealthChecker) SetLeaseNamespaceFunc

func (c *KubeHealthChecker) SetLeaseNamespaceFunc(fn func(mv1.LeaseID) string)

SetLeaseNamespaceFunc allows overriding the namespace generation function

type LeaseHealth

type LeaseHealth struct {
	LeaseID     mv1.LeaseID  `json:"lease_id"`
	Status      HealthStatus `json:"status"`
	LastChecked time.Time    `json:"last_checked"`
	Message     string       `json:"message,omitempty"`
	PodCount    int          `json:"pod_count"`
	ReadyCount  int          `json:"ready_count"`
}

LeaseHealth represents the health of a specific lease

type MsgHealthAttestation

type MsgHealthAttestation struct {
	LeaseID   mv1.LeaseID `json:"lease_id"`
	Provider  string      `json:"provider"`
	Status    int32       `json:"status"` // 0=unknown, 1=healthy, 2=degraded, 3=failed
	Timestamp int64       `json:"timestamp"`
	Message   string      `json:"message,omitempty"`
}

MsgHealthAttestation is the message for submitting health attestations to the chain

func (MsgHealthAttestation) GetSignBytes

func (msg MsgHealthAttestation) GetSignBytes() []byte

func (MsgHealthAttestation) GetSigners

func (msg MsgHealthAttestation) GetSigners() []sdk.AccAddress

func (*MsgHealthAttestation) ProtoMessage

func (msg *MsgHealthAttestation) ProtoMessage()

func (*MsgHealthAttestation) Reset

func (msg *MsgHealthAttestation) Reset()

Implement sdk.Msg interface

func (MsgHealthAttestation) Route

func (msg MsgHealthAttestation) Route() string

func (*MsgHealthAttestation) String

func (msg *MsgHealthAttestation) String() string

func (MsgHealthAttestation) Type

func (msg MsgHealthAttestation) Type() string

func (MsgHealthAttestation) ValidateBasic

func (msg MsgHealthAttestation) ValidateBasic() error

type Reporter

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

Reporter is the health reporting service

func NewReporter

func NewReporter(
	cfg Config,
	logger log.Logger,
	checker HealthChecker,
	txClient client.Context,
) *Reporter

NewReporter creates a new health reporter

func (*Reporter) GetAllHealth

func (r *Reporter) GetAllHealth() map[string]*LeaseHealth

GetAllHealth returns all cached health data

func (*Reporter) GetHealth

func (r *Reporter) GetHealth(leaseID mv1.LeaseID) (*LeaseHealth, bool)

GetHealth returns the cached health for a lease

func (*Reporter) Start

func (r *Reporter) Start(ctx context.Context) error

Start starts the health reporter

func (*Reporter) Stop

func (r *Reporter) Stop()

Stop stops the health reporter

Jump to

Keyboard shortcuts

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