Skip to content

Conversation

@englishm-cloudflare
Copy link
Contributor

Reworks the interface between moq-relay-ietf and some kind of control plane to assist with relay to relay routing decisions.

This is part of what's needed to allow us to depend directly on open source moq-rs instead of our current internal fork.

@englishm englishm requested a review from Copilot November 2, 2025 17:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the relay implementation to use a generic ControlPlane trait abstraction, replacing the previously hardcoded Api client. This enables supporting different control plane implementations beyond just HTTP-based routing.

  • Introduced a ControlPlane trait with generic implementations for cross-relay routing
  • Replaced direct Api usage with the generic control plane pattern throughout the codebase
  • Created HttpControlPlane as the concrete HTTP-based implementation (equivalent to the old Api)

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
moq-relay-ietf/src/control_plane.rs Defines the new ControlPlane and ControlPlaneRefresher traits for control plane abstraction
moq-relay-ietf/src/control_plane_http.rs Implements HTTP-based control plane using the moq-api client
moq-relay-ietf/src/lib.rs Creates library structure with RelayServer wrapper and public exports
moq-relay-ietf/src/api.rs Removed - functionality migrated to control_plane_http.rs
moq-relay-ietf/src/session.rs Added generic ControlPlane parameter to Session struct
moq-relay-ietf/src/remote.rs Added generic ControlPlane parameter to remote-related structs
moq-relay-ietf/src/relay.rs Updated to use generic control plane and split node_url handling
moq-relay-ietf/src/producer.rs Added generic ControlPlane parameter to Producer
moq-relay-ietf/src/consumer.rs Updated to use control plane trait methods and added node_url field
moq-relay-ietf/src/main.rs Simplified to use new RelayServer API with HttpControlPlane
moq-relay-ietf/Cargo.toml Added library/binary configuration and async-trait dependency
Cargo.lock Updated with async-trait dependency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 30 to 32
// This is a stub implementation - in practice you'd need valid URLs
// The actual instance should be created via `new()` with proper config
panic!("HttpControlPlane requires API URL and node URL - use HttpControlPlane::new() instead")
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Default implementation for HttpControlPlane panics at runtime, which is problematic since ControlPlane trait requires Default. This creates a trait implementation that violates the principle of least surprise and will cause runtime panics. Consider either removing the Default requirement from the ControlPlane trait, or providing a safe default implementation (e.g., with placeholder URLs or an Option-wrapped state).

Suggested change
// This is a stub implementation - in practice you'd need valid URLs
// The actual instance should be created via `new()` with proper config
panic!("HttpControlPlane requires API URL and node URL - use HttpControlPlane::new() instead")
// Safe default using placeholder URLs
let api_url = Url::parse("http://localhost").unwrap();
let node_url = Url::parse("http://localhost").unwrap();
HttpControlPlane::new(api_url, node_url)

Copilot uses AI. Check for mistakes.
Comment on lines 109 to 111
tokio::spawn(async move {
web.run().await.expect("failed to run web server");
});
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The web server task is spawned without capturing its join handle, making it impossible to detect or propagate web server failures. If the web server panics or fails, the main relay will continue running without any indication of the failure. Consider either returning the join handle or logging the error instead of using expect.

Copilot uses AI. Check for mistakes.
};

relay.run().await
let server = RelayServer::new(config, control_plane, cli.node)?;
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cli.node is passed twice - once when creating control_plane (line 73-74) and again when creating the server. This duplication could lead to inconsistencies. Consider extracting the node URL from the control plane or restructuring to avoid passing it separately.

Suggested change
let server = RelayServer::new(config, control_plane, cli.node)?;
// Extract node URL from control_plane if present, otherwise use cli.node
let node_url = match &control_plane {
Some(cp) => cp.node_url().clone(),
None => cli.node.clone().expect("node URL must be provided"),
};
let server = RelayServer::new(config, control_plane, node_url)?;

Copilot uses AI. Check for mistakes.
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.

2 participants