summaryrefslogtreecommitdiff
path: root/js/metrics.ts
diff options
context:
space:
mode:
authorBartek Iwańczuk <biwanczuk@gmail.com>2019-08-26 14:50:21 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-08-26 08:50:21 -0400
commit520f9631e09aa720fd8c03513ee8ea967f5ed4b2 (patch)
treefc3d1bd5182452ca1865a5c2631355e0895af94c /js/metrics.ts
parent017f88ee99b0fe40221e6af92e0b6a976fbaf2ad (diff)
bring back json ops (#2815)
Diffstat (limited to 'js/metrics.ts')
-rw-r--r--js/metrics.ts27
1 files changed, 3 insertions, 24 deletions
diff --git a/js/metrics.ts b/js/metrics.ts
index e93e9528c..48e3102e5 100644
--- a/js/metrics.ts
+++ b/js/metrics.ts
@@ -1,6 +1,6 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import { assert } from "./util";
-import { sendSync, msg, flatbuffers } from "./dispatch_flatbuffers";
+import * as dispatch from "./dispatch";
+import { sendSync } from "./dispatch_json";
export interface Metrics {
opsDispatched: number;
@@ -10,27 +10,6 @@ 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())
@@ -45,5 +24,5 @@ function res(baseRes: null | msg.Base): Metrics {
* └──────────────────┴────────┘
*/
export function metrics(): Metrics {
- return res(sendSync(...req()));
+ return sendSync(dispatch.OP_METRICS);
}