mock

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: BSD-3-Clause Imports: 7 Imported by: 0

README

Mock Provider

The Mock Provider extends the platform-health server to support internal testing.

Configuration

The Mock Provider is configured through the platform-health server's configuration file. Each instance is defined with its name as the YAML key under components.

  • type (required): Must be mock.
  • spec: Provider-specific configuration:
    • health (default: HEALTHY): The health state of the Mock service.
    • sleep (default: 1ns): The delay in returning Mock service status.

Examples

Basic Mock Check
components:
  test-service:
    type: mock
    spec:
      health: HEALTHY
      sleep: 100ms

Documentation

Index

Constants

View Source
const ProviderType = "mock"

Variables

This section is empty.

Functions

This section is empty.

Types

type Component added in v0.6.0

type Component struct {
	provider.Base
	provider.BaseWithChecks

	Health ph.Status     `mapstructure:"health" default:"HEALTHY"`
	Sleep  time.Duration `mapstructure:"sleep" default:"1ns"`
}

func Healthy added in v0.6.0

func Healthy(name string, opts ...Option) *Component

Healthy creates a healthy mock with the given name and options.

func New added in v0.7.0

func New(name string, opts ...Option) *Component

New creates a mock component with the given name and options. Defaults to HEALTHY status if not specified via WithHealth.

func Unhealthy added in v0.6.0

func Unhealthy(name string, opts ...Option) *Component

Unhealthy creates an unhealthy mock with the given name and options.

func (*Component) GetCheckConfig added in v0.6.0

func (c *Component) GetCheckConfig() *checks.CEL

func (*Component) GetCheckContext added in v0.6.0

func (c *Component) GetCheckContext(ctx context.Context) (map[string]any, error)

func (*Component) GetHealth added in v0.6.0

func (c *Component) GetHealth(ctx context.Context) *ph.HealthCheckResponse

func (*Component) GetType added in v0.6.0

func (c *Component) GetType() string

func (*Component) SetChecks added in v0.7.0

func (c *Component) SetChecks(exprs []checks.Expression) error

SetChecks sets and compiles CEL expressions.

func (*Component) Setup added in v0.6.0

func (c *Component) Setup() error

type Option added in v0.7.0

type Option func(*Component)

Option configures a mock Component.

func WithAlways added in v0.8.0

func WithAlways(always bool) Option

WithAlways marks the mock to always execute even after fail-fast.

func WithHealth added in v0.7.0

func WithHealth(s ph.Status) Option

WithHealth sets the health status for the mock.

func WithOrder added in v0.8.0

func WithOrder(order int) Option

WithOrder sets the execution order for the mock.

func WithSleep added in v0.7.0

func WithSleep(d time.Duration) Option

WithSleep sets the sleep duration for the mock.

Jump to

Keyboard shortcuts

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