mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Add gRPC TCP transport to the code-mode host (#37745)
## What changed - Accept `grpc://IP:PORT` endpoints through `--listen` and serve the existing code-mode gRPC service over TCP. - Print the bound HTTP endpoint to stdout so callers can discover the port when binding to port `0`. - Apply the protocol frame-size limits and disable Nagle's algorithm on accepted connections. ## Testing - Add an end-to-end test that starts the host on an ephemeral port, connects a gRPC client, and opens a session. - Verify accepted gRPC sockets have `TCP_NODELAY` enabled. GitOrigin-RevId: 51d6c21dff8cffb47068c0677ba10ff370385cec
This commit is contained in:
1 parent
50ef7395fa
commit
c0ad3ab014
7 files changed
+144
-3
No files matched your search
@@ -1,6 +1,7 @@
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use axum::serve::Listener;
|
||||
use futures::StreamExt;
|
||||
use pretty_assertions::assert_eq;
|
||||
use tokio::net::TcpStream;
|
||||
|
||||
@@ -9,6 +10,7 @@ use super::ListenTransport;
|
||||
use super::MAX_PENDING_BULK_CONNECTIONS;
|
||||
use super::bind_websocket_listener;
|
||||
use super::parse_listen_url;
|
||||
use crate::grpc_transport::bind_tcp_listener;
|
||||
|
||||
#[tokio::test]
|
||||
async fn websocket_listener_disables_nagle() {
|
||||
@@ -33,6 +35,31 @@ async fn websocket_listener_disables_nagle() {
|
||||
assert!(stream);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn grpc_listener_disables_nagle() {
|
||||
let bind_address = "127.0.0.1:0"
|
||||
.parse()
|
||||
.expect("gRPC test listener should have a valid bind address");
|
||||
let mut listener = bind_tcp_listener(bind_address)
|
||||
.await
|
||||
.expect("gRPC test listener should bind");
|
||||
let local_addr = listener
|
||||
.local_addr()
|
||||
.expect("gRPC test listener should have a local address");
|
||||
let _client = TcpStream::connect(local_addr)
|
||||
.await
|
||||
.expect("gRPC test client should connect");
|
||||
let nodelay = listener
|
||||
.next()
|
||||
.await
|
||||
.expect("gRPC test listener should accept a connection")
|
||||
.expect("gRPC test listener should return a valid socket")
|
||||
.nodelay()
|
||||
.expect("accepted gRPC socket should expose TCP_NODELAY");
|
||||
|
||||
assert!(nodelay);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bulk_connection_registration_cleans_up_when_dropped() {
|
||||
let registry = BulkConnectionRegistry::default();
|
||||
|
||||
Reference in new issue
Block a user