< Summary - Kestrun — Combined Coverage

Information
Class: Public.Middleware.Add-KrAddCallbacksAutomation
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Middleware/Add-KrAddCallbacksAutomation.ps1
Tag: Kestrun/Kestrun@6135d944f8787fb570e4dfbacac6e80312799a86
Line coverage
0%
Covered lines: 0
Uncovered lines: 12
Coverable lines: 12
Total lines: 73
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 01/02/2026 - 00:16:25 Line coverage: 0% (0/14) Total lines: 93 Tag: Kestrun/Kestrun@8405dc23b786b9d436fba0d65fb80baa4171e1d005/09/2026 - 21:51:36 Line coverage: 0% (0/12) Total lines: 73 Tag: Kestrun/Kestrun@6b24c7512a1bad61723a28d32446de0aa658293e

Coverage delta

Coverage delta 1 -1

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Middleware/Add-KrAddCallbacksAutomation.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Adds callback automation middleware to the Kestrun host.
 4    .DESCRIPTION
 5        This cmdlet adds middleware to the Kestrun host that enables automatic handling of callbacks using
 6        specified options or individual parameters for configuration.
 7    .PARAMETER Options
 8        An instance of CallbackDispatchOptions to configure callback dispatch behavior.
 9    .PARAMETER DefaultTimeout
 10        The default timeout in seconds for callback operations. Used when Options is not provided.
 11    .PARAMETER MaxAttempts
 12        The maximum number of attempts for callback operations. Used when Options is not provided.
 13    .PARAMETER BaseDelay
 14        The base delay in seconds between callback attempts. Used when Options is not provided.
 15    .PARAMETER MaxDelay
 16        The maximum delay in seconds between callback attempts. Used when Options is not provided.
 17    .EXAMPLE
 18        Add-KrAddCallbacksAutomation -DefaultTimeout 30 -MaxAttempts 5 -BaseDelay 2 -MaxDelay 60
 19        Adds callback automation middleware to the current Kestrun host with specified parameters and returns the modifi
 20    .EXAMPLE
 21        Add-KrAddCallbacksAutomation -Options $customOptions
 22        Adds callback automation middleware to the specified Kestrun host using the provided options.
 23    .NOTES
 24        This cmdlet is part of the Kestrun PowerShell module.
 25 #>
 26function Add-KrAddCallbacksAutomation {
 27    [KestrunRuntimeApi('Definition')]
 28    [CmdletBinding(defaultParameterSetName = 'Items')]
 29    param(
 30        [Parameter(Mandatory = $true, ParameterSetName = 'Options')]
 31        [Kestrun.Callback.CallbackDispatchOptions]$Options,
 32
 33        [Parameter(ParameterSetName = 'Items')]
 34        [ValidateRange(1, 600)]
 35        [int]$DefaultTimeout,
 36
 37        [Parameter(ParameterSetName = 'Items')]
 38        [ValidateRange(1, 99)]
 39        [int]$MaxAttempts,
 40
 41        [Parameter(ParameterSetName = 'Items')]
 42        [ValidateRange(1, 30)]
 43        [int]$BaseDelay,
 44
 45        [Parameter(ParameterSetName = 'Items')]
 46        [ValidateRange(1, 300)]
 47        [int]$MaxDelay
 48    )
 49    # Ensure the server instance is resolved
 050    $Server = Resolve-KestrunServer
 51
 052    if ($PSCmdlet.ParameterSetName -eq 'Items') {
 53        # Create options from individual parameters
 054        $Options = [Kestrun.Callback.CallbackDispatchOptions]::new()
 55        # Set default values
 056        if ($PSBoundParameters.ContainsKey('DefaultTimeout')) {
 057            $Options.DefaultTimeout = [TimeSpan]::FromSeconds($DefaultTimeout)
 58        }
 059        if ($PSBoundParameters.ContainsKey('MaxAttempts')) {
 060            $Options.MaxAttempts = $MaxAttempts
 61        }
 062        if ($PSBoundParameters.ContainsKey('BaseDelay')) {
 063            $Options.BaseDelay = [TimeSpan]::FromSeconds($BaseDelay)
 64        }
 065        if ($PSBoundParameters.ContainsKey('MaxDelay')) {
 066            $Options.MaxDelay = [TimeSpan]::FromSeconds($MaxDelay)
 67        }
 68    }
 69
 70    # Add the callback automation middleware to the server
 071    $Server.AddCallbacksAutomation($Options) | Out-Null
 72}
 73

Methods/Properties

Add-KrAddCallbacksAutomation()