mirror of
https://github.com/denoland/deno.git
synced 2025-02-01 20:25:12 -05:00
feat: stabilize Deno.loadavg() (#16412)
This commit is contained in:
parent
f242d98280
commit
606db35ccb
10 changed files with 26 additions and 31 deletions
|
@ -42,7 +42,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
|
||||||
"kill",
|
"kill",
|
||||||
"listen",
|
"listen",
|
||||||
"listenDatagram",
|
"listenDatagram",
|
||||||
"loadavg",
|
|
||||||
"dlopen",
|
"dlopen",
|
||||||
"osRelease",
|
"osRelease",
|
||||||
"ppid",
|
"ppid",
|
||||||
|
|
18
cli/dts/lib.deno.ns.d.ts
vendored
18
cli/dts/lib.deno.ns.d.ts
vendored
|
@ -314,6 +314,24 @@ declare namespace Deno {
|
||||||
*/
|
*/
|
||||||
export function hostname(): string;
|
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.
|
/** Reflects the `NO_COLOR` environment variable at program start.
|
||||||
*
|
*
|
||||||
* When the value is `true`, the Deno CLI will attempt to not send color codes
|
* When the value is `true`, the Deno CLI will attempt to not send color codes
|
||||||
|
|
21
cli/dts/lib.deno.unstable.d.ts
vendored
21
cli/dts/lib.deno.unstable.d.ts
vendored
|
@ -243,27 +243,6 @@ declare namespace Deno {
|
||||||
rows: number;
|
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.
|
/** **UNSTABLE**: New API, yet to be vetted.
|
||||||
*
|
*
|
||||||
* Returns the release version of the Operating System.
|
* Returns the release version of the Operating System.
|
||||||
|
|
2
cli/tests/testdata/run/unstable.js
vendored
2
cli/tests/testdata/run/unstable.js
vendored
|
@ -1 +1 @@
|
||||||
console.log(Deno.loadavg);
|
console.log(Deno.umask);
|
||||||
|
|
2
cli/tests/testdata/run/unstable.ts
vendored
2
cli/tests/testdata/run/unstable.ts
vendored
|
@ -1 +1 @@
|
||||||
console.log(Deno.loadavg);
|
console.log(Deno.umask);
|
||||||
|
|
6
cli/tests/testdata/run/unstable_disabled.out
vendored
6
cli/tests/testdata/run/unstable_disabled.out
vendored
|
@ -1,5 +1,5 @@
|
||||||
[WILDCARD]
|
[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?
|
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.loadavg);
|
console.log(Deno.umask);
|
||||||
~~~~~~~
|
~~~~~
|
||||||
at [WILDCARD]/unstable.ts:1:18
|
at [WILDCARD]/unstable.ts:1:18
|
||||||
|
|
2
cli/tests/testdata/run/unstable_enabled.out
vendored
2
cli/tests/testdata/run/unstable_enabled.out
vendored
|
@ -1 +1 @@
|
||||||
[Function: loadavg]
|
[Function: umask]
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
[Function: loadavg]
|
[Function: umask]
|
||||||
|
|
|
@ -89,6 +89,7 @@
|
||||||
seekSync: __bootstrap.files.seekSync,
|
seekSync: __bootstrap.files.seekSync,
|
||||||
connect: __bootstrap.net.connect,
|
connect: __bootstrap.net.connect,
|
||||||
listen: __bootstrap.net.listen,
|
listen: __bootstrap.net.listen,
|
||||||
|
loadavg: __bootstrap.os.loadavg,
|
||||||
connectTls: __bootstrap.tls.connectTls,
|
connectTls: __bootstrap.tls.connectTls,
|
||||||
listenTls: __bootstrap.tls.listenTls,
|
listenTls: __bootstrap.tls.listenTls,
|
||||||
startTls: __bootstrap.tls.startTls,
|
startTls: __bootstrap.tls.startTls,
|
||||||
|
@ -120,7 +121,6 @@
|
||||||
__bootstrap.denoNsUnstable = {
|
__bootstrap.denoNsUnstable = {
|
||||||
consoleSize: __bootstrap.tty.consoleSize,
|
consoleSize: __bootstrap.tty.consoleSize,
|
||||||
DiagnosticCategory: __bootstrap.diagnostics.DiagnosticCategory,
|
DiagnosticCategory: __bootstrap.diagnostics.DiagnosticCategory,
|
||||||
loadavg: __bootstrap.os.loadavg,
|
|
||||||
osRelease: __bootstrap.os.osRelease,
|
osRelease: __bootstrap.os.osRelease,
|
||||||
systemMemoryInfo: __bootstrap.os.systemMemoryInfo,
|
systemMemoryInfo: __bootstrap.os.systemMemoryInfo,
|
||||||
networkInterfaces: __bootstrap.os.networkInterfaces,
|
networkInterfaces: __bootstrap.os.networkInterfaces,
|
||||||
|
|
|
@ -160,7 +160,6 @@ fn op_exit(state: &mut OpState) {
|
||||||
|
|
||||||
#[op]
|
#[op]
|
||||||
fn op_loadavg(state: &mut OpState) -> Result<(f64, f64, f64), AnyError> {
|
fn op_loadavg(state: &mut OpState) -> Result<(f64, f64, f64), AnyError> {
|
||||||
super::check_unstable(state, "Deno.loadavg");
|
|
||||||
state
|
state
|
||||||
.borrow_mut::<Permissions>()
|
.borrow_mut::<Permissions>()
|
||||||
.sys
|
.sys
|
||||||
|
|
Loading…
Add table
Reference in a new issue