Split out reviewer service from refresh worker

What does this MR do and why?

Split out reviewer service from refresh worker

This MR implements the third step in splitting the MergeRequests::RefreshService by extracting reviewer-related functionality into a separate service and worker. This refactoring improves the separation of concerns and allows for better performance optimization of merge request refresh operations.

Key Changes:

  1. New MergeRequests::Refresh::ReviewerService: Extracts reviewer-related logic from the main refresh service, including:

    • Scheduling Duo Code Review for merge requests
    • Removing requested changes when appropriate
    • Handling reviewer state updates
    • Processing reviewer-related notifications
  2. New MergeRequests::Refresh::ReviewerWorker: A Sidekiq worker that processes reviewer operations asynchronously with:

    • Low urgency and CPU resource boundary
    • Idempotent execution with deduplication
    • Proper error handling for missing projects/users
    • Weight of 2 to handle the processing load
  3. Feature Flag Integration: Introduces split_refresh_worker_reviewer feature flag to gradually roll out the new architecture:

    • When enabled: Reviewer processing happens asynchronously via the new worker
    • When disabled: Falls back to the original synchronous behavior
  4. EE Extension: Maintains Enterprise Edition functionality with proper override for reviewer handling

Benefits:

  • Performance: Moves time-consuming reviewer operations to background processing
  • Scalability: Reduces blocking time in the main refresh flow
  • Maintainability: Better separation of concerns with focused, testable services
  • Gradual Rollout: Feature flag allows safe deployment and rollback if needed

Implementation Notes:

This approach uses direct worker enqueuing rather than events to allow independent feature flag control during the transition period. The worker will only execute if both project and user exist, providing robust error handling for edge cases.

The reviewer service handles all reviewer-related operations including Duo Code Review scheduling, requested changes removal, and reviewer state management.

Part of: #554081 (closed)

References

Screenshots or screen recordings

Before After

How to set up and validate locally

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading