Skip to content

feat: add Kafka error events to Livepeer cloud mode#935

Draft
emranemran wants to merge 1 commit intomainfrom
feat/livepeer-kafka-events
Draft

feat: add Kafka error events to Livepeer cloud mode#935
emranemran wants to merge 1 commit intomainfrom
feat/livepeer-kafka-events

Conversation

@emranemran
Copy link
Copy Markdown
Contributor

@emranemran emranemran commented Apr 14, 2026

Summary

  • Add _publish_cloud_error() helper to LivepeerConnection matching CloudConnectionManager._publish_cloud_error() signature and event shape
  • Publish cloud_connection_failed events on connect() and connect_background() failures
  • Publish cloud_disconnect_error events on disconnect() timeout or exception
  • Uses the same error_type values and metadata: {"app_id": ...} shape as cloud relay mode — no Kafka consumer changes needed
  • Frame-level events (stream_started, stream_stopped, playback_ready, session_created, heartbeats) already fire via shared code in frame_processor.py and webrtc.py

Test plan

Verify events fire without Kafka (no-op path)

  • Start Scope with SCOPE_CLOUD_MODE=livepeer (no Kafka env vars)
  • Trigger a connection failure: curl -X POST http://localhost:8000/api/v1/cloud/connect -H 'Content-Type: application/json' -d '{"user_id": "test"}'
  • Confirm no crash — publish_event() no-ops gracefully

Verify events publish to Kafka

  • Start Scope with KAFKA_BOOTSTRAP_SERVERS=<broker> KAFKA_TOPIC=scope-events SCOPE_CLOUD_MODE=livepeer
  • Trigger connection failure (no orchestrator configured)
  • Consume from scope-events topic and verify cloud_connection_failed event appears with same schema as relay mode
  • Connect successfully, kill orchestrator, then disconnect — verify cloud_disconnect_error event

Regression: shared events still fire

  • With full Livepeer stack, connect and stream
  • Verify session_created, stream_started, playback_ready, stream_heartbeat, stream_stopped, session_closed events still fire

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 37a9d9a7-cd2e-4966-8e86-8b0d9c08eb45

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/livepeer-kafka-events

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 and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 14, 2026

🚀 fal.ai Preview Deployment

App ID daydream/scope-pr-935--preview
WebSocket wss://fal.run/daydream/scope-pr-935--preview/ws
Commit 11046ff

Livepeer Runner

App ID daydream/scope-livepeer-pr-935--preview
WebSocket wss://fal.run/daydream/scope-livepeer-pr-935--preview/ws
Auth private

Testing Livepeer Mode

SCOPE_CLOUD_MODE=livepeer SCOPE_CLOUD_APP_ID="daydream/scope-livepeer-pr-935--preview/ws" uv run daydream-scope

@emranemran emranemran force-pushed the feat/livepeer-kafka-events branch from 59e61c1 to 34ab3fa Compare April 14, 2026 16:21
Publish connection error events to Kafka in LivepeerConnection,
matching the existing CloudConnectionManager behavior. Uses the same
error_type values (cloud_connection_failed, cloud_disconnect_error)
and metadata shape (app_id) so Kafka consumers require no changes.

Signed-off-by: emranemran <emran@livepeer.org>
Signed-off-by: emranemran <emran.mah@gmail.com>
@emranemran emranemran force-pushed the feat/livepeer-kafka-events branch from 34ab3fa to 11046ff Compare April 15, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant