mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
Revert json ops (#2814)
* Revert "port more ops to JSON (#2809)" This reverts commit137f33733d
. * Revert "port ops to JSON: compiler, errors, fetch, files (#2804)" This reverts commit79f82cf10e
. * Revert "Port rest of os ops to JSON (#2802)" This reverts commit5b2baa5c99
.
This commit is contained in:
parent
bdc0a13261
commit
2235dd795d
45 changed files with 1968 additions and 1045 deletions
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync } from "./dispatch_json";
|
||||
import { assert } from "./util";
|
||||
import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
|
||||
|
||||
export interface Metrics {
|
||||
opsDispatched: number;
|
||||
|
@ -10,6 +10,27 @@ export interface Metrics {
|
|||
bytesReceived: number;
|
||||
}
|
||||
|
||||
function req(): [flatbuffers.Builder, msg.Any, flatbuffers.Offset] {
|
||||
const builder = flatbuffers.createBuilder();
|
||||
const inner = msg.Metrics.createMetrics(builder);
|
||||
return [builder, msg.Any.Metrics, inner];
|
||||
}
|
||||
|
||||
function res(baseRes: null | msg.Base): Metrics {
|
||||
assert(baseRes !== null);
|
||||
assert(msg.Any.MetricsRes === baseRes!.innerType());
|
||||
const res = new msg.MetricsRes();
|
||||
assert(baseRes!.inner(res) !== null);
|
||||
|
||||
return {
|
||||
opsDispatched: res.opsDispatched().toFloat64(),
|
||||
opsCompleted: res.opsCompleted().toFloat64(),
|
||||
bytesSentControl: res.bytesSentControl().toFloat64(),
|
||||
bytesSentData: res.bytesSentData().toFloat64(),
|
||||
bytesReceived: res.bytesReceived().toFloat64()
|
||||
};
|
||||
}
|
||||
|
||||
/** Receive metrics from the privileged side of Deno.
|
||||
*
|
||||
* > console.table(Deno.metrics())
|
||||
|
@ -24,5 +45,5 @@ export interface Metrics {
|
|||
* └──────────────────┴────────┘
|
||||
*/
|
||||
export function metrics(): Metrics {
|
||||
return sendSync(dispatch.OP_METRICS);
|
||||
return res(sendSync(...req()));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue