< 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@ca54e35c77799b76774b3805b6f075cdbc0c5fbe
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 93
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@8405dc23b786b9d436fba0d65fb80baa4171e1d0

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 Server
 8        The Kestrun host instance to which the middleware will be added. If not specified, the current host instance wil
 9    .PARAMETER Options
 10        An instance of CallbackDispatchOptions to configure callback dispatch behavior.
 11    .PARAMETER DefaultTimeout
 12        The default timeout in seconds for callback operations. Used when Options is not provided.
 13    .PARAMETER MaxAttempts
 14        The maximum number of attempts for callback operations. Used when Options is not provided.
 15    .PARAMETER BaseDelay
 16        The base delay in seconds between callback attempts. Used when Options is not provided.
 17    .PARAMETER MaxDelay
 18        The maximum delay in seconds between callback attempts. Used when Options is not provided.
 19    .PARAMETER PassThru
 20        If specified, the cmdlet returns the modified Kestrun host instance.
 21    .EXAMPLE
 22        PS> Add-KrAddCallbacksAutomation -DefaultTimeout 30 -MaxAttempts 5 -BaseDelay 2 -MaxDelay 60
 23        Adds callback automation middleware to the current Kestrun host with specified parameters and returns the modifi
 24    .EXAMPLE
 25        PS> $server = Get-KrServer
 26        PS> Add-KrAddCallbacksAutomation -Server $server -Options $customOptions
 27        Adds callback automation middleware to the specified Kestrun host using the provided options.
 28 .NOTES
 29        This cmdlet is part of the Kestrun PowerShell module.
 30 #>
 31function Add-KrAddCallbacksAutomation {
 32    [KestrunRuntimeApi('Definition')]
 33    [CmdletBinding(defaultParameterSetName = 'Items')]
 34    [OutputType([Kestrun.Hosting.KestrunHost])]
 35    param(
 36        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 37        [Kestrun.Hosting.KestrunHost]$Server,
 38
 39        [Parameter(Mandatory = $true, ParameterSetName = 'Options')]
 40        [Kestrun.Callback.CallbackDispatchOptions]$Options,
 41
 42        [Parameter(ParameterSetName = 'Items')]
 43        [ValidateRange(1, 600)]
 44        [int]$DefaultTimeout,
 45
 46        [Parameter(ParameterSetName = 'Items')]
 47        [ValidateRange(1, 99)]
 48        [int]$MaxAttempts,
 49
 50        [Parameter(ParameterSetName = 'Items')]
 51        [ValidateRange(1, 30)]
 52        [int]$BaseDelay,
 53
 54        [Parameter(ParameterSetName = 'Items')]
 55        [ValidateRange(1, 300)]
 56        [int]$MaxDelay,
 57
 58        [Parameter()]
 59        [switch]$PassThru
 60    )
 61    begin {
 62        # Ensure the server instance is resolved
 063        $Server = Resolve-KestrunServer -Server $Server
 64    }
 65    process {
 066        if ($PSCmdlet.ParameterSetName -eq 'Items') {
 67            # Create options from individual parameters
 068            $Options = [Kestrun.Callback.CallbackDispatchOptions]::new()
 69            # Set default values
 070            if ($PSBoundParameters.ContainsKey('DefaultTimeout')) {
 071                $Options.DefaultTimeout = [TimeSpan]::FromSeconds($DefaultTimeout)
 72            }
 073            if ($PSBoundParameters.ContainsKey('MaxAttempts')) {
 074                $Options.MaxAttempts = $MaxAttempts
 75            }
 076            if ($PSBoundParameters.ContainsKey('BaseDelay')) {
 077                $Options.BaseDelay = [TimeSpan]::FromSeconds($BaseDelay)
 78            }
 079            if ($PSBoundParameters.ContainsKey('MaxDelay')) {
 080                $Options.MaxDelay = [TimeSpan]::FromSeconds($MaxDelay)
 81            }
 82        }
 83
 84        # Add the callback automation middleware to the server
 085        $Server.AddCallbacksAutomation($Options) | Out-Null
 86
 087        if ($PassThru.IsPresent) {
 88            # if the PassThru switch is specified, return the modified server instance
 089            return $Server
 90        }
 91    }
 92}
 93

Methods/Properties

Add-KrAddCallbacksAutomation()