Repository navigation
Make recurring actions scoped instead of singleton - #12
Merged
Merged
Conversation
johnkors
commented
Sep 21, 2026
Contributor
- AddRecurrer registers T with AddScoped instead of AddSingleton
- CronBackgroundService is now generic (CronBackgroundService) and creates a fresh DI scope per cron tick, resolving T from it before calling Process
- lets a recurring action take scoped dependencies (e.g. MassTransit's IPublishEndpoint) directly in its constructor, instead of every action injecting IServiceScopeFactory and opening a scope by hand
- the BackgroundService itself is still a long-lived singleton, as before — only the action instance is now scoped per invocation
- IRecurringAction is no longer registered as an open multi-service (GetServices() no longer resolves anything); only the concrete T is registered now — source-breaking only for a consumer that was relying on that multi-registration, which nothing known does
AddRecurrer<T> now registers T with AddScoped instead of forcing every IRecurringAction into a DI singleton. CronBackgroundService<T> creates a fresh scope per cron tick and resolves T from it, so actions can take scoped dependencies (e.g. MassTransit's IPublishEndpoint) directly in their constructor instead of injecting IServiceScopeFactory and opening a scope by hand. IRecurringAction is no longer registered as an open multi-service (GetServices<IRecurringAction>() no longer resolves anything); only the concrete T is registered now.
johnkors
added a commit
that referenced
this pull request
Sep 21, 2026
+semver: major AddRecurrer<T>'s move from singleton to scoped registration (#12) breaks any consumer holding a reference to a recurring action expecting it to stay the same instance across ticks, or calling GetServices<IRecurringAction>() (no longer registered as an open multi-service - only the concrete T is). GitVersion's +semver: major convention (no explicit config override in this repo, so its default regex applies) picks this up for the next release.
johnkors
added a commit
that referenced
this pull request
Sep 21, 2026
…#13) * ci: use NuGet OIDC trusted publishing instead of a long-lived API key Same pattern as Slackbot.Net's Release.yml: NuGet/login exchanges GitHub's OIDC token for a short-lived NuGet API key at publish time, so NUGETORGAPIKEY no longer needs to be stored as a long-lived secret. * ci: consolidate Release/PreRelease into one workflow with a prerelease toggle Same shape as Slackbot.Net's Release.yml: a single workflow_dispatch input picks the version scheme, and the GitHub release step is skipped for prereleases - one workflow to run instead of two near-duplicates. * docs: tag the scoped-recurring-actions change as a breaking release +semver: major AddRecurrer<T>'s move from singleton to scoped registration (#12) breaks any consumer holding a reference to a recurring action expecting it to stay the same instance across ticks, or calling GetServices<IRecurringAction>() (no longer registered as an open multi-service - only the concrete T is). GitVersion's +semver: major convention (no explicit config override in this repo, so its default regex applies) picks this up for the next release.
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.