1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-11 08:33:43 -05:00

feat: stabilize Deno.loadavg() (#16412)

This commit is contained in:
Colin Ihrig 2022-10-25 11:21:14 -04:00 committed by GitHub
parent f242d98280
commit 606db35ccb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 26 additions and 31 deletions

View file

@ -42,7 +42,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
"kill",
"listen",
"listenDatagram",
"loadavg",
"dlopen",
"osRelease",
"ppid",

View file

@ -314,6 +314,24 @@ declare namespace Deno {
*/
export function hostname(): string;
/**
* Returns an array containing the 1, 5, and 15 minute load averages. The
* load average is a measure of CPU and IO utilization of the last one, five,
* and 15 minute periods expressed as a fractional number. Zero means there
* is no load. On Windows, the three values are always the same and represent
* the current load, not the 1, 5 and 15 minute load averages.
*
* ```ts
* console.log(Deno.loadavg()); // e.g. [ 0.71, 0.44, 0.44 ]
* ```
*
* Requires `allow-sys` permission.
*
* @tags allow-sys
* @category Observability
*/
export function loadavg(): number[];
/** Reflects the `NO_COLOR` environment variable at program start.
*
* When the value is `true`, the Deno CLI will attempt to not send color codes

View file

@ -243,27 +243,6 @@ declare namespace Deno {
rows: number;
};
/** **UNSTABLE**: New API, yet to be vetted.
*
* Returns an array containing the 1, 5, and 15 minute load averages. The
* load average is a measure of CPU and IO utilization of the last one, five,
* and 15 minute periods expressed as a fractional number. Zero means there
* is no load. On Windows, the three values are always the same and represent
* the current load, not the 1, 5 and 15 minute load averages.
*
* ```ts
* console.log(Deno.loadavg()); // e.g. [ 0.71, 0.44, 0.44 ]
* ```
*
* Requires `allow-sys` permission.
* There are questions around which permission this needs. And maybe should be
* renamed (loadAverage?).
*
* @tags allow-sys
* @category Observability
*/
export function loadavg(): number[];
/** **UNSTABLE**: New API, yet to be vetted.
*
* Returns the release version of the Operating System.

View file

@ -1 +1 @@
console.log(Deno.loadavg);
console.log(Deno.umask);

View file

@ -1 +1 @@
console.log(Deno.loadavg);
console.log(Deno.umask);

View file

@ -1,5 +1,5 @@
[WILDCARD]
error: TS2339 [ERROR]: Property 'loadavg' does not exist on type 'typeof Deno'. 'Deno.loadavg' is an unstable API. Did you forget to run with the '--unstable' flag?
console.log(Deno.loadavg);
~~~~~~~
error: TS2339 [ERROR]: Property 'umask' does not exist on type 'typeof Deno'. 'Deno.umask' is an unstable API. Did you forget to run with the '--unstable' flag?
console.log(Deno.umask);
~~~~~
at [WILDCARD]/unstable.ts:1:18

View file

@ -1 +1 @@
[Function: loadavg]
[Function: umask]

View file

@ -1 +1 @@
[Function: loadavg]
[Function: umask]

View file

@ -89,6 +89,7 @@
seekSync: __bootstrap.files.seekSync,
connect: __bootstrap.net.connect,
listen: __bootstrap.net.listen,
loadavg: __bootstrap.os.loadavg,
connectTls: __bootstrap.tls.connectTls,
listenTls: __bootstrap.tls.listenTls,
startTls: __bootstrap.tls.startTls,
@ -120,7 +121,6 @@
__bootstrap.denoNsUnstable = {
consoleSize: __bootstrap.tty.consoleSize,
DiagnosticCategory: __bootstrap.diagnostics.DiagnosticCategory,
loadavg: __bootstrap.os.loadavg,
osRelease: __bootstrap.os.osRelease,
systemMemoryInfo: __bootstrap.os.systemMemoryInfo,
networkInterfaces: __bootstrap.os.networkInterfaces,

View file

@ -160,7 +160,6 @@ fn op_exit(state: &mut OpState) {
#[op]
fn op_loadavg(state: &mut OpState) -> Result<(f64, f64, f64), AnyError> {
super::check_unstable(state, "Deno.loadavg");
state
.borrow_mut::<Permissions>()
.sys