[srp-server] introduce LeaseTracker base class for Host and Service - #12628
Conversation
…ice` This commit extracts the common lease tracking variables (`mLease`, `mKeyLease`, `mTtl`, and `mUpdateTime`) and their associated methods from the `Srp::Server::Host` and `Srp::Server::Service` classes into a new shared base class, `LeaseTracker`. By having both `Host` and `Service` inherit from `LeaseTracker`, we eliminate duplicated logic for calculating expiration times, handling lease info, and processing TTL updates. This refactoring simplifies the SRP server codebase and ensures consistent lease management behavior across both entities.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the SRP server's lease management by introducing a dedicated Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the SRP server code by extracting common lease tracking logic from Srp::Server::Host and Srp::Server::Service into a new base class LeaseTracker. This change successfully reduces code duplication and improves maintainability. The implementation is clean, follows the project's coding style, and correctly preserves or improves the existing logic. I have reviewed the changes and found no issues.
Note: Security Review did not run due to the size of the PR.
Library files
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12628 +/- ##
==========================================
+ Coverage 73.71% 75.61% +1.90%
==========================================
Files 697 695 -2
Lines 94709 94656 -53
==========================================
+ Hits 69812 71576 +1764
+ Misses 24897 23080 -1817
🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a LeaseTracker base class for Srp::Server::Host and Srp::Server::Service to consolidate common lease management logic. The refactoring successfully extracts duplicated code for handling lease times, TTLs, and expiration calculations, leading to a cleaner and more maintainable SRP server implementation. The changes are well-executed, adhering to the project's coding style and improving encapsulation by using getters and setters instead of direct member access. A subtle but important correctness improvement is also included, ensuring that deleted services correctly have their lease set to zero during updates. Overall, this is a high-quality contribution that improves the codebase.
Note: Security Review did not run due to the size of the PR.
This commit extracts the common lease tracking variables (
mLease,mKeyLease,mTtl, andmUpdateTime) and their associated methods from theSrp::Server::HostandSrp::Server::Serviceclasses into a new shared base class,LeaseTracker.By having both
HostandServiceinherit fromLeaseTracker, we eliminate duplicated logic for calculating expiration times, handling lease info, and processing TTL updates. This refactoring simplifies the SRP server codebase and ensures consistent lease management behavior across both entities.