diff options
author | Luca Casonato <hello@lcas.dev> | 2022-02-16 17:32:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-16 17:32:29 +0100 |
commit | 02c95d367e94f55f525646c2759558f52a493c69 (patch) | |
tree | 900be0a3bdf8b0df767afae568606265d20d5a11 | |
parent | be9c2fe267083a2995043ddf6228946f1244ab57 (diff) |
chore: make new TCP conn methods unstable (#13686)
-rw-r--r-- | cli/dts/lib.deno.unstable.d.ts | 15 | ||||
-rw-r--r-- | ext/net/lib.deno_net.d.ts | 4 | ||||
-rw-r--r-- | 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 b8402cd9b..708eafe6a 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 9ac274e94..048037d02 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<void>; - /** 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<Uint8Array>; readonly writable: WritableStream<Uint8Array>; diff --git a/ext/net/ops.rs b/ext/net/ops.rs index f64b79ba7..d2a8d8433 100644 --- a/ext/net/ops.rs +++ b/ext/net/ops.rs @@ -672,6 +672,7 @@ pub fn op_set_nodelay<NP>( rid: ResourceId, nodelay: bool, ) -> Result<(), AnyError> { + super::check_unstable(state, "Deno.Conn#setNoDelay"); let resource: Rc<TcpStreamResource> = state.resource_table.get::<TcpStreamResource>(rid)?; resource.set_nodelay(nodelay) @@ -682,6 +683,7 @@ pub fn op_set_keepalive<NP>( rid: ResourceId, keepalive: bool, ) -> Result<(), AnyError> { + super::check_unstable(state, "Deno.Conn#setKeepAlive"); let resource: Rc<TcpStreamResource> = state.resource_table.get::<TcpStreamResource>(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(); |