-
-
Notifications
You must be signed in to change notification settings - Fork 363
feat(ITcpSocketFactory): redesign GetOrCreate method #6282
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
Reviewer's GuideThis PR redesigns the GetOrCreate method to accept a factory function for endpoint creation, updates the default factory implementation and unit tests accordingly, and removes a deprecated extension file. Class diagram for redesigned ITcpSocketFactory interface and DefaultTcpSocketFactory implementationclassDiagram
class ITcpSocketFactory {
+ITcpSocketClient GetOrCreate(string name, Func<string, IPEndPoint> valueFactory)
+void Remove(string name)
+void Dispose()
}
class DefaultTcpSocketFactory {
+ITcpSocketClient GetOrCreate(string name, Func<string, IPEndPoint> valueFactory)
+void Remove(string name)
+void Dispose()
-ConcurrentDictionary<string, ITcpSocketClient> _pool
-IServiceProvider provider
}
ITcpSocketFactory <|.. DefaultTcpSocketFactory
class ITcpSocketClient
class DefaultTcpSocketClient
ITcpSocketClient <|.. DefaultTcpSocketClient
DefaultTcpSocketFactory --> ITcpSocketClient : manages
DefaultTcpSocketFactory --> DefaultTcpSocketClient : creates
class Func~string, IPEndPoint~
class IPEndPoint
DefaultTcpSocketFactory ..> Func~string, IPEndPoint~ : uses
DefaultTcpSocketClient ..> IPEndPoint : uses
Class diagram for removed ITcpSocketFactoryExtensionsclassDiagram
class ITcpSocketFactoryExtensions {
<<removed>>
}
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @ArgoZhang - I've reviewed your changes - here's some feedback:
- Consider renaming the
valueFactoryparameter to something likeendPointFactoryto more clearly convey that it produces anIPEndPoint. - Add null checks for both
nameandvalueFactoryinGetOrCreateto fail fast when either argument is null. - Since this replaces the old
GetOrCreate(name, IPEndPoint)overload, consider providing a deprecated overload or migration guide to prevent breaking existing callers.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider renaming the `valueFactory` parameter to something like `endPointFactory` to more clearly convey that it produces an `IPEndPoint`.
- Add null checks for both `name` and `valueFactory` in `GetOrCreate` to fail fast when either argument is null.
- Since this replaces the old `GetOrCreate(name, IPEndPoint)` overload, consider providing a deprecated overload or migration guide to prevent breaking existing callers.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6282 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 713 712 -1
Lines 31400 31397 -3
Branches 4437 4437
=========================================
- Hits 31400 31397 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6281
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Redesign the ITcpSocketFactory.GetOrCreate method to use a factory delegate for endpoint creation and propagate this change through the default implementation and tests, while removing the obsolete extension.
Enhancements:
Tests: