Closed hackerwins closed 1 month ago
The changes enhance the Yorkie backend by restructuring the housekeeping functionalities, optimizing the management of inactive clients, and improving dependency management. A new caching mechanism for webhooks has been introduced, along with refined testing capabilities. These updates collectively streamline the backend processes, provide better resource management, and facilitate the integration of scheduled tasks while ensuring code clarity and maintainability.
Files | Change Summary |
---|---|
go.mod |
Added dependencies for scheduling and UUID generation; updated testing libraries. |
server/backend/backend.go |
Enhanced Backend struct with caching; restructured initialization and added a Start method. |
server/backend/housekeeping/config.go |
Introduced ParseInterval method for better interval handling in configuration. |
server/backend/housekeeping/housekeeping.go |
Simplified Housekeeping struct; improved task scheduling without direct database dependencies. |
server/clients/housekeeping.go |
Added functions for deactivating inactive clients with logging for tracking. |
server/rpc/server_test.go |
Updated TestMain for improved backend configuration with UseDefaultProject . |
server/server.go |
Added RegisterHousekeepingTasks method to manage client deactivation tasks effectively. |
test/helper/helper.go |
Introduced global variable UseDefaultProject for enhanced project management flexibility. |
test/integration/housekeeping_test.go |
Renamed setup functions and adjusted logic for testing against the backend. |
test/sharding/server_test.go |
Updated TestMain to include UseDefaultProject in backend configuration during tests. |
sequenceDiagram
participant Client
participant Backend
participant Housekeeping
Client->>Backend: Initialize Backend
Backend->>Backend: Setup AuthWebhookCache
Backend->>Housekeeping: Start housekeeping tasks
Housekeeping->>Housekeeping: Schedule deactivation tasks
Housekeeping->>Client: Deactivate inactive clients
Note right of Client: Clients are deactivated based on criteria
Objective | Addressed | Explanation |
---|---|---|
Improve the structure of housekeeping tasks for better management (706) | ✅ | |
Prevent redundant housekeeping tasks in cluster mode (706) | ✅ | |
Introduce a clear way to run background routines (706) | ❌ | No implementation for managing routines. |
Enhance handling of inactive clients with logging (706) | ✅ |
🐇 In the burrow where tasks align,
New features hop, oh how they shine!
Housekeeping's dance, a rhythm so sweet,
Inactive clients, we bid retreat.
With caching and care, our code does bloom,
A rabbit’s joy in this coding room! 🍃✨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Attention: Patch coverage is 0%
with 91 lines
in your changes missing coverage. Please review.
Project coverage is 51.41%. Comparing base (
b468f8b
) to head (55bdb4d
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
What this PR does / why we need it:
This commit enhances Housekeeping to enable the addition of a variety of tasks. Previously, Housekeeping was limited to only Client Deactivation task.
In this update, the actual tasks are implemented in the service package(e.g.
clients
), whilehousekeeping
package is only responsible for scheduling tasks. It is for separation of concerns.Which issue(s) this PR fixes:
Fixes #706
Special notes for your reviewer:
The introduction of
gocron
has simplified the codebase ofhousekeeping
package. It may be worth considering introducing distributed system support ofgocron
later.Does this PR introduce a user-facing change?:
Additional documentation:
Checklist:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Documentation