Schedule plugin background tasks with TickerQ - #276
Merged
Merged
Conversation
…heduler # Conflicts: # src/Schuly.API/Plugins/PluginHost.cs # src/Schuly.API/Program.cs # src/Schuly.Infrastructure/Migrations/SchulyDbContextModelSnapshot.cs # src/Schuly.Tests.Plugin/TestPlugin.cs # src/Schuly.Tests/PluginHotSwapTests.cs # src/Schuly.Tests/TestHelpers/PluginTestHarness.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PluginHost.RunTaskLoopplus the in-memoryPluginSchedulerRegistry) with TickerQ, persisted toSchulyDbContextthrough the EF Core operational store. Schedules, next-run times and run history now survive a restart, cron replaces drifting intervals, and failed runs retry per the plugin's declared policy.[TickerFunction]inside a plugin assembly loaded into a collectibleAssemblyLoadContextcould never be seen. The host instead owns a single[TickerFunction("RunPluginTask")]that carries{ plugin, task }and dispatches into the plugin's own DI scope by name. Plugins never reference TickerQ.IPluginBackgroundTaskis upserted as a cron ticker keyed"<plugin>/<task>", so a reload updates rather than duplicates and a task dropped by a plugin update stops firing; unload withdraws the plugin's tickers and drains in-flight runs before the plugin provider is disposed.RunOnStartupadds a one-shot time ticker.plugins-config/<AssemblyName>.ymlunderSchedules:<task>:{Cron,Retries,RunOnStartup}; an override that fails validation is ignored in favour of the plugin default rather than taking the task offline.GET /api/plugins/schedulerkeeps its response shape, now backed by TickerQ's persisted cron tickers and occurrences (last run, next run, last status, failure counts). The TickerQ dashboard is mounted at/tickerqin Development only.SchulyDbContextno longer lives for the process lifetime.AddTickerQcreates thetickerschema. Docs updated;PluginBackgroundTaskHostreferences indocs/architecture.mdwere stale and now describe the real runtime.Depends on schulydev/SchulyPluginAbstractions#144, which replaces
IPluginBackgroundTask.IntervalwithPluginSchedule. Version0.3.0is not published to nuget.org yet, so CI will fail to restoreSchuly.Plugin.Abstractions 0.3.*until that release is cut. It was verified locally against a0.3.0pack:dotnet buildclean with 0 warnings,dotnet test52/52 green.The
.gitignorechange is not incidental:/src/Schuly.API/plugins/matched the trackedsrc/Schuly.API/Plugins/sources on case-insensitive checkouts, so new files in the plugin runtime folder were silently ignored. The runtime drop folder is now matched by artifact extension instead.Follow-up, deliberately not in this PR: a host service that lets a plugin trigger a one-shot run of one of its own tasks ("sync this account now") would need a new cross-boundary interface in the abstractions package. The existing on-demand sync mechanism is unchanged here.
Closes #233