< Summary - Kestrun — Combined Coverage

Information
Class: Public.Service.Add-KrScheduling
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Service/Add-KrScheduling.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
0%
Covered lines: 0
Uncovered lines: 8
Coverable lines: 8
Total lines: 58
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

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Service/Add-KrScheduling.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Adds scheduling support to the Kestrun server.
 4    .DESCRIPTION
 5        This cmdlet allows you to register a scheduling service with the Kestrun server.
 6        It can be used to manage scheduled tasks and jobs in the context of the Kestrun server.
 7    .PARAMETER Server
 8        The Kestrun server instance to which the scheduling service will be added.
 9    .PARAMETER MaxRunspaces
 10        The maximum number of runspaces to use for scheduling tasks. If not specified, defaults to 0 (unlimited).
 11    .PARAMETER PassThru
 12        If specified, the cmdlet will return the modified server instance after adding the scheduling service.
 13    .EXAMPLE
 14        $server | Add-KrScheduling -MaxRunspaces 5
 15        This example adds scheduling support to the server, with a maximum of 5 runspaces.
 16    .EXAMPLE
 17        $server | Add-KrScheduling
 18        This example adds scheduling support to the server without specifying a maximum number of runspaces.
 19    .NOTES
 20        This cmdlet is used to register a scheduling service with the Kestrun server, allowing you to manage scheduled t
 21#>
 22function Add-KrScheduling {
 23    [KestrunRuntimeApi('Definition')]
 24    [CmdletBinding()]
 25    [OutputType([Kestrun.Hosting.KestrunHost])]
 26    param(
 27        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 28        [Kestrun.Hosting.KestrunHost]$Server,
 29
 30        [Parameter()]
 31        [int]$MaxRunspaces,
 32
 33        [Parameter()]
 34        [switch]$PassThru
 35    )
 36    begin {
 37        # Ensure the server instance is resolved
 038        $Server = Resolve-KestrunServer -Server $Server
 039        if ($null -eq $Server) {
 040            throw 'Server is not initialized. Please ensure the server is configured before setting options.'
 41        }
 42    }
 43    process {
 044        if ($MaxRunspaces -eq 0) {
 45            # If MaxRunspaces is 0, use the default configuration
 046            $Server.AddScheduling() | Out-Null
 47        } else {
 048            $Server.AddScheduling($MaxRunspaces) | Out-Null
 49        }
 50
 051        if ($PassThru.IsPresent) {
 52            # if the PassThru switch is specified, return the server instance
 53            # Return the modified server instance
 054            return $Server
 55        }
 56    }
 57}
 58

Methods/Properties

Add-KrScheduling()