Skip to content

refactor: the replay loop gets its next event and sends one event in their own methods - #405

Merged
HardMax71 merged 1 commit into
mainfrom
refactor/replay-dispatch-complexity
Oct 19, 2026
Merged

HardMax71 merged 1 commit into
mainfrom
refactor/replay-dispatch-complexity

Conversation

@HardMax71

@HardMax71 HardMax71 commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

Follow-up to #403: SonarCloud failed it on python:S3776. Wrapping the old dispatch body in a loop put _dispatch_events at cognitive complexity 21 against the allowed 15. Sonar isn't the required check, so #403 merged anyway, and main now carries the finding.

Changes

_next_event returns the session's next event and loads the next batch once the loaded one runs out. _dispatch_event sends one event and returns how long to wait before the next one; a failure without skip_errors ends the session as before. The loop in _dispatch_events only joins the two. Behaviour is unchanged.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • CI/CD or tooling changes

Test Plan

  • Backend unit tests pass (cd backend && uv run pytest tests/unit)
  • Frontend unit tests pass (cd frontend && npm run test)
  • Backend E2E tests pass (docker compose exec -T backend sh -c 'uv sync --group test --no-dev --frozen --no-install-project --no-build && pytest tests/e2e')
  • Frontend E2E tests pass (cd frontend && npm run test:e2e)
  • API spec and client regenerated if routes or schemas changed (./deploy.sh openapi, then ./deploy.sh types), never edited by hand
  • Manual testing performed

Validation: unit 572 passed, including #403's full-speed replay test. complexipy now scores the methods 3 and 7.

Checklist

  • My code follows the project's style guidelines
  • I have run pre-commit run --all-files and all checks pass
  • I have added tests that prove my fix/feature works
  • I have updated documentation if needed
  • My changes don't introduce new warnings

Summary by cubic

The replay dispatch loop now pulls events via _next_event and sends each one through _dispatch_event, each method returning control to the loop. This brings _dispatch_events under SonarCloud's cognitive-complexity limit (python:S3776) with no behavior changes.

Written for commit de805a5. Summary will update on new commits.

View guided diff Turn on auto-fix

…their own methods

SonarCloud failed #403 on python:S3776: wrapping the old dispatch body in a loop put _dispatch_events at cognitive complexity 21 against the allowed 15. _next_event loads the next batch when the loaded one runs out, and _dispatch_event sends one event and returns the wait before the next; the loop only joins them. Behaviour is the same.
@HardMax71
HardMax71 enabled auto-merge (squash) October 19, 2026 00:10
@coderabbitai

coderabbitai Bot commented Oct 19, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1456c049-6555-4776-b886-d331fd6558f4
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the area: events Kafka consumers and middlewares, producer, idempotency, DLQ, replay label Oct 19, 2026
@sonarqubecloud

Copy link
Copy Markdown

@codecov-commenter

codecov-commenter commented Oct 19, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 76.47059% with 8 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ackend/app/services/event_replay/replay_service.py 76.47% 8 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Flag Coverage Δ
backend-e2e 82.97% <73.52%> (+0.03%) ⬆️
backend-unit 74.32% <76.47%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ackend/app/services/event_replay/replay_service.py 87.29% <76.47%> (+0.75%) ⬆️
Components Coverage Δ
Backend 92.22% <76.47%> (+0.02%) ⬆️
Frontend 92.60% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@HardMax71
HardMax71 merged commit ac34cf2 into main Oct 19, 2026
21 checks passed
@HardMax71
HardMax71 deleted the refactor/replay-dispatch-complexity branch October 19, 2026 00:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: events Kafka consumers and middlewares, producer, idempotency, DLQ, replay

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants