< Summary - Kestrun — Combined Coverage

Information
Class: Public.Health.New-KrProbeResult
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Health/New-KrProbeResult.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 9
Coverable lines: 9
Total lines: 56
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 10/13/2025 - 16:52:37 Line coverage: 0% (0/9) Total lines: 56 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Health/New-KrProbeResult.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Creates a new Kestrun health ProbeResult object.
 4.DESCRIPTION
 5    Simplifies constructing a [Kestrun.Health.ProbeResult] from PowerShell without using the
 6    raw static ::new() syntax. Accepts status, description, and an optional hashtable of data
 7    which is converted to a strongly typed Dictionary[string, object]. Returns the created
 8    ProbeResult for piping back to Add-KrHealthProbe script blocks or custom logic.
 9.PARAMETER Status
 10    Health status. Accepts Healthy, Degraded, or Unhealthy (case-insensitive).
 11.PARAMETER Description
 12    Short human readable description for diagnostics.
 13.PARAMETER Data
 14    Optional hashtable of additional metrics/values (serialized into response JSON).
 15.EXAMPLE
 16    New-KrProbeResult -Status Healthy -Description 'Cache OK'
 17.EXAMPLE
 18    New-KrProbeResult Degraded 'Latency high' -Data @{ p95 = 180; threshold = 150 }
 19.NOTES
 20    Intended for use inside -ScriptBlock probes: `return New-KrProbeResult Healthy 'Ready'`.
 21#>
 22function New-KrProbeResult {
 23    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 24    [KestrunRuntimeApi('Runtime')]
 25    [CmdletBinding(PositionalBinding = $true)]
 26    [OutputType([Kestrun.Health.ProbeResult])]
 27    param(
 28        [Parameter(Mandatory, Position = 0)]
 29        [ValidateSet('Healthy', 'Degraded', 'Unhealthy')]
 30        [string]$Status,
 31
 32        [Parameter(Mandatory, Position = 1)]
 33        [string]$Description,
 34
 35        [Parameter(Position = 2)]
 36        [hashtable]$Data
 37    )
 38
 39    # Map string to enum
 040    $enumStatus = [Kestrun.Health.ProbeStatus]::$Status
 41
 042    $dict = $null
 043    if ($PSBoundParameters.ContainsKey('Data') -and $Data) {
 44
 45
 046        $dict = [System.Collections.Generic.Dictionary[string, object]]::new()
 047        foreach ($k in $Data.Keys) {
 048            if ([string]::IsNullOrWhiteSpace([string]$k)) { continue }
 049            $nv = _NormalizeValueToDictionary -Value $Data[$k] -Depth 0
 050            if ($null -ne $nv) { $dict[$k] = $nv }
 51        }
 52    }
 53
 54    # Create and return the ProbeResult
 055    return [Kestrun.Health.ProbeResult]::new($enumStatus, $Description, $dict)
 56}

Methods/Properties

New-KrProbeResult()