Skip to content

Commit

Permalink
Clean-up, and adds quick schedule/task process docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Badgerati committed Sep 14, 2024
1 parent 3e51068 commit 91ae295
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 13 deletions.
23 changes: 23 additions & 0 deletions docs/Tutorials/Schedules.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,29 @@ Get-PodeSchedule -Name Name1
Get-PodeSchedule -Name Name1, Name2
```

## Getting Schedule Processes

You can retrieve a list of processes triggered by Schedules via [`Get-PodeScheduleProcess`](../../Functions/Schedules/Get-PodeScheduleProcess) - this will return processes created either by a Schedule's natural time-based trigger, or via [`Invoke-PodeSchedule`](../../Functions/Schedules/Invoke-PodeSchedule).

You can either retrieve all processes, or filter them by Schedule Name, or Process ID/Status:

```powershell
# retrieves all schedule processes
Get-PodeScheduleProcess
# retrieves all schedule processes for the "ScheduleName" process
Get-PodeScheduleProcess -Name 'ScheduleName'
# retrieves the schedule process with ID "ScheduleId"
Get-PodeScheduleProcess -Id 'ScheduleId'
# retrieves all running schedule processes
Get-PodeScheduleProcess -State 'Running'
# retrieves all pending schedule processes for "ScheduleName"
Get-PodeScheduleProcess -Name 'ScheduleName' -State 'Running'
```

## Next Trigger Time

When you retrieve a Schedule using [`Get-PodeSchedule`](../../Functions/Schedules/Get-PodeSchedule), each Schedule object will already have its next trigger time as `NextTriggerTime`. However, if you want to get a trigger time further ino the future than this, then you can use the [`Get-PodeScheduleNextTrigger`](../../Functions/Schedules/Get-PodeScheduleNextTrigger) function.
Expand Down
35 changes: 29 additions & 6 deletions docs/Tutorials/Tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Add-PodeTask -Name 'Example' -ArgumentList @{ Name = 'Rick'; Environment = 'Mult
}
```

Tasks parameters **must** be bound in the param block in order to be used, but the values for the paramters can be set through the `-ArgumentList` hashtable parameter in either the Add-PodeTask definition or when invoking the task. The following snippet would populate the parameters to the task with the same values as the above example but the `-ArgumentList` parameter is populated during invocation. Note that Keys in the `-ArgumentList` hashtable parameter set during invocation override the same Keys set during task creation:
Tasks parameters **must** be bound in the param block in order to be used, but the values for the paramters can be set through the `-ArgumentList` hashtable parameter in either the Add-PodeTask definition or when invoking the task. The following snippet would populate the parameters to the task with the same values as the above example but the `-ArgumentList` parameter is populated during invocation. Note that Keys in the `-ArgumentList` hashtable parameter set during invocation override the same Keys set during task creation:

```powershell
Add-PodeTask -Name 'Example' -ScriptBlock {
Expand Down Expand Up @@ -184,15 +184,38 @@ Get-PodeTask -Name Example1
Get-PodeTask -Name Example1, Example2
```

## Getting Task Processes

You can retrieve a list of processes triggered by Tasks via [`Get-PodeTaskProcess`](../../Functions/Tasks/Get-PodeTaskProcess) - this will return processes created via [`Invoke-PodeTask`](../../Functions/Tasks/Invoke-PodeTask).

You can either retrieve all processes, or filter them by Task Name, or Process ID/Status:

```powershell
# retrieves all task processes
Get-PodeTaskProcess
# retrieves all task processes for the "TaskName" process
Get-PodeTaskProcess -Name 'TaskName'
# retrieves the task process with ID "TaskId"
Get-PodeTaskProcess -Id 'TaskId'
# retrieves all running task processes
Get-PodeTaskProcess -State 'Running'
# retrieves all pending task processes for "TaskName"
Get-PodeTaskProcess -Name 'TaskName' -State 'Running'
```

## Task Object

!!! warning
Be careful if you choose to edit these objects, as they will affect the server.

The following is the structure of the Task object internally, as well as the object that is returned from [`Get-PodeTask`](../../Functions/Tasks/Get-PodeTask):

| Name | Type | Description |
| ---- | ---- | ----------- |
| Name | string | The name of the Task |
| Script | scriptblock | The scriptblock of the Task |
| Arguments | hashtable | The arguments supplied from ArgumentList |
| Name | Type | Description |
| --------- | ----------- | ---------------------------------------- |
| Name | string | The name of the Task |
| Script | scriptblock | The scriptblock of the Task |
| Arguments | hashtable | The arguments supplied from ArgumentList |
2 changes: 1 addition & 1 deletion src/Locales/de/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
viewsFolderNameAlreadyExistsExceptionMessage = 'Der Name des Ansichtsordners existiert bereits: {0}'
noNameForWebSocketResetExceptionMessage = 'Kein Name für das Zurücksetzen des WebSocket angegeben.'
mergeDefaultAuthNotInListExceptionMessage = "Die MergeDefault-Authentifizierung '{0}' befindet sich nicht in der angegebenen Authentifizierungsliste."
descriptionRequiredExceptionMessage = 'Eine Beschreibung ist erforderlich.'
descriptionRequiredExceptionMessage = 'Eine Beschreibung ist erforderlich für Pfad:{0} Antwort:{1}'
pageNameShouldBeAlphaNumericExceptionMessage = 'Der Seitenname sollte einen gültigen alphanumerischen Wert haben: {0}'
defaultValueNotBooleanOrEnumExceptionMessage = 'Der Standardwert ist kein Boolean und gehört nicht zum Enum.'
openApiComponentSchemaDoesNotExistExceptionMessage = 'Das OpenApi-Komponentenschema {0} existiert nicht.'
Expand Down
5 changes: 0 additions & 5 deletions src/Private/Context.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,11 @@ function New-PodeRunspacePool {
# setup main runspace pool
$threadsCounts = @{
Default = 3
# Timer = 1
Log = 1
Schedule = 1
Misc = 1
}

# if (!(Test-PodeTimersExist)) {
# $threadsCounts.Timer = 0
# }

if (!(Test-PodeSchedulesExist)) {
$threadsCounts.Schedule = 0
}
Expand Down
2 changes: 1 addition & 1 deletion src/Private/Tasks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function Get-PodeTaskScriptBlock {
# build the script arguments
$TaskEvent = @{
Lockable = $PodeContext.Threading.Lockables.Global
Sender = $Task
Sender = $task
Timestamp = [DateTime]::UtcNow
Metadata = @{}
}
Expand Down

0 comments on commit 91ae295

Please sign in to comment.