From 02c95d367e94f55f525646c2759558f52a493c69 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Wed, 16 Feb 2022 17:32:29 +0100 Subject: [PATCH] chore: make new TCP conn methods unstable (#13686) --- cli/dts/lib.deno.unstable.d.ts | 15 +++++++++++++++ ext/net/lib.deno_net.d.ts | 4 ---- ext/net/ops.rs | 4 ++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index b8402cd9b3..708eafe6a6 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -1057,6 +1057,21 @@ declare namespace Deno { alpnProtocols?: string[]; } + export interface Conn { + /** + * **UNSTABLE**: new API, see https://github.com/denoland/deno/issues/13617. + * + * Enable/disable the use of Nagle's algorithm. Defaults to true. + */ + setNoDelay(nodelay?: boolean): void; + /** + * **UNSTABLE**: new API, see https://github.com/denoland/deno/issues/13617. + * + * Enable/disable keep-alive functionality. + */ + setKeepAlive(keepalive?: boolean): void; + } + export interface TlsHandshakeInfo { /** **UNSTABLE**: new API, yet to be vetted. * diff --git a/ext/net/lib.deno_net.d.ts b/ext/net/lib.deno_net.d.ts index 9ac274e946..048037d02a 100644 --- a/ext/net/lib.deno_net.d.ts +++ b/ext/net/lib.deno_net.d.ts @@ -50,10 +50,6 @@ declare namespace Deno { /** Shuts down (`shutdown(2)`) the write side of the connection. Most * callers should just use `close()`. */ closeWrite(): Promise; - /** Enable/disable the use of Nagle's algorithm. Defaults to true */ - setNoDelay(nodelay?: boolean): void; - /** Enable/disable keep-alive functionality */ - setKeepAlive(keepalive?: boolean): void; readonly readable: ReadableStream; readonly writable: WritableStream; diff --git a/ext/net/ops.rs b/ext/net/ops.rs index f64b79ba7c..d2a8d8433a 100644 --- a/ext/net/ops.rs +++ b/ext/net/ops.rs @@ -672,6 +672,7 @@ pub fn op_set_nodelay( rid: ResourceId, nodelay: bool, ) -> Result<(), AnyError> { + super::check_unstable(state, "Deno.Conn#setNoDelay"); let resource: Rc = state.resource_table.get::(rid)?; resource.set_nodelay(nodelay) @@ -682,6 +683,7 @@ pub fn op_set_keepalive( rid: ResourceId, keepalive: bool, ) -> Result<(), AnyError> { + super::check_unstable(state, "Deno.Conn#setKeepAlive"); let resource: Rc = state.resource_table.get::(rid)?; resource.set_keepalive(keepalive) @@ -739,6 +741,7 @@ fn rdata_to_return_record( #[cfg(test)] mod tests { use super::*; + use crate::UnstableChecker; use deno_core::Extension; use deno_core::JsRuntime; use deno_core::RuntimeOptions; @@ -894,6 +897,7 @@ mod tests { let my_ext = Extension::builder() .state(move |state| { state.put(TestPermission {}); + state.put(UnstableChecker { unstable: true }); Ok(()) }) .build();