-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Service Lifetime Events #9792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Service Lifetime Events #9792
Conversation
|
@ReubenBond addressed the comments, PTAL! WDYT about this, I am unsure, but lean more towards (a)waiting indefinitely
|
|
@ledjon-behluli I think relying on them respecting the CT is ok (even if not defensive) |
|
@ReubenBond Added proper tests & removed the toy/test console app. We should consider not having the P.s: I do not have a strong opinion on the matter of |
|
Yes please! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a new service lifetime event system for Orleans, providing a cleaner API for observing and participating in client/silo lifecycle stages. The implementation adds IServiceLifetime with three stages (Started, Stopping, Stopped) that allow callbacks to be registered and executed at specific points in the service lifecycle.
Key changes:
- New
IServiceLifetimeandIServiceLifetimeStageinterfaces providing callback registration and cancellation token support ServiceLifetimeStageimplementation handling callback execution, error handling, and late registrations- Registration in both client and silo service containers with comprehensive test coverage
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Orleans.Core/Lifecycle/ServiceLifetimeStage.cs | Core implementation of lifecycle stages with callback management, error handling, and thread-safe registration |
| src/Orleans.Core/Lifecycle/ServiceLifetime.cs | Main service lifetime coordinator that wires up Started, Stopping, and Stopped stages to the underlying lifecycle observable |
| src/Orleans.Runtime/Hosting/DefaultSiloServices.cs | Registers ServiceLifetime for silo lifecycle with dependency injection (also reorganizes using statements alphabetically) |
| src/Orleans.Core/Core/DefaultClientServices.cs | Registers ServiceLifetime for client lifecycle with dependency injection |
| test/NonSilo.Tests/ServiceLifetimeTests.cs | Comprehensive test suite covering callback execution, cancellation, error handling, late registration, and concurrency scenarios |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

close #9771
Microsoft Reviewers: Open in CodeFlow