-
-
Notifications
You must be signed in to change notification settings - Fork 254
Enable Background Job Progress Report in bit Boilerplate based projects without SignalR (#11662) #11663
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
Conversation
WalkthroughChanges extend background job progress notification handling to support projects without SignalR by introducing a client-side message constant as an alternative channel, updating documentation for broader applicability, and conditionally including user session context in notifications based on SignalR configuration. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Common/JobProgress.razor.cs (1)
27-29: Consider updating the comment for accuracy.The comment on Line 28 states that the message is published from the server through SignalR. With this PR's changes, the message can also be published client-side when SignalR is disabled. Consider updating the comment to reflect both scenarios.
Apply this diff to clarify the comment:
var jobProgress = payload is JsonElement jsonDocument - ? jsonDocument.Deserialize(JsonSerializerOptions.GetTypeInfo<BackgroundJobProgressDto>())! /* Message gets published from server through SignalR */ + ? jsonDocument.Deserialize(JsonSerializerOptions.GetTypeInfo<BackgroundJobProgressDto>())! /* When SignalR is enabled, message gets published from server */ : (BackgroundJobProgressDto)payload;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting
📒 Files selected for processing (4)
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Common/JobProgress.razor.cs(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/ClientAppMessages.cs(2 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/RoleManagementController.cs(1 hunks)src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Services/SharedAppMessages.cs(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build and test
🔇 Additional comments (4)
src/Templates/Boilerplate/Bit.Boilerplate/src/Shared/Services/SharedAppMessages.cs (1)
83-83: LGTM! Documentation updated appropriately.The documentation change makes the description more general and applicable to various background job implementations, not just Hangfire-specific scenarios. This aligns well with the PR objective to support projects without SignalR.
src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Components/Common/JobProgress.razor.cs (1)
23-23: LGTM! Key architectural improvement for SignalR-optional support.The switch to
ClientAppMessages.BACKGROUND_JOB_PROGRESScorrectly enables the feature to work in both SignalR and non-SignalR scenarios. When SignalR is enabled,ClientAppMessagesinherits fromSharedAppMessages, so the constant remains the same. When SignalR is disabled,ClientAppMessagesdefines its own constant for client-side pub/sub.src/Templates/Boilerplate/Bit.Boilerplate/src/Client/Boilerplate.Client.Core/Services/ClientAppMessages.cs (1)
77-80: LGTM! Correctly placed constant for non-SignalR scenarios.The
BACKGROUND_JOB_PROGRESSconstant is correctly placed inside the#if (signalR != true)block. This design ensures:
- When SignalR is enabled:
ClientAppMessagesinherits the constant fromSharedAppMessages- When SignalR is disabled:
ClientAppMessagesdefines its own constant for client-side pub/subThe documentation is consistent with the updated
SharedAppMessagesversion, completing the architectural pattern for SignalR-optional support.src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.Api/Controllers/Identity/RoleManagementController.cs (1)
239-241: Conditional compilation and null-safety are properly implemented.The code correctly handles
RequesterUserSessionIdthrough multiple safety layers:
- Field is nullable (
Guid?) in the DTO, making it optional by design- Controller conditionally sets it only when SignalR is enabled (lines 239-241)
- Job runner explicitly checks for null before accessing it:
if (request.RequesterUserSessionId != null)(line 51 in PushNotificationJobRunner.cs)- Both the field and its usage are conditionally compiled, ensuring clean removal when SignalR is disabled
When SignalR is disabled, the field doesn't exist in the compiled code, and the job runner's session ID lookup block is also removed. No null reference exceptions will occur.
closes #11662
Summary by CodeRabbit