Skip to content

Conversation

@ledjon-behluli
Copy link
Contributor

@ledjon-behluli ledjon-behluli commented Nov 18, 2025

close #9771

Microsoft Reviewers: Open in CodeFlow

@ledjon-behluli
Copy link
Contributor Author

ledjon-behluli commented Nov 19, 2025

@ReubenBond addressed the comments, PTAL!

WDYT about this, I am unsure, but lean more towards (a)waiting indefinitely

image

@ReubenBond
Copy link
Member

@ledjon-behluli I think relying on them respecting the CT is ok (even if not defensive)

@ledjon-behluli ledjon-behluli marked this pull request as ready for review November 30, 2025 15:15
@ledjon-behluli
Copy link
Contributor Author

ledjon-behluli commented Nov 30, 2025

@ReubenBond Added proper tests & removed the toy/test console app. We should consider not having the TerminateOnError and control it within the component i.e. Starting events should terminate, and while stopping we log and swallow, but other than that this is now ready AFAIC.

P.s: I do not have a strong opinion on the matter of TerminateOnError being an internal thing, or left to the user.

@shacal
Copy link

shacal commented Dec 1, 2025

Yes please!

@ledjon-behluli ledjon-behluli changed the title Silo Lifecycle Events Service Lifetime Events Dec 14, 2025
@ReubenBond ReubenBond requested a review from Copilot December 14, 2025 22:06
Copy link
Contributor

Copilot AI left a 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 IServiceLifetime and IServiceLifetimeStage interfaces providing callback registration and cancellation token support
  • ServiceLifetimeStage implementation 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

ledjon-behluli and others added 4 commits December 14, 2025 23:17
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>
ledjon-behluli and others added 2 commits December 14, 2025 23:23
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add externally accessible lifecycle events for silos

3 participants