summaryrefslogtreecommitdiff
path: root/js/metrics.ts
diff options
context:
space:
mode:
authorBartek Iwańczuk <biwanczuk@gmail.com>2019-08-24 17:31:14 +0200
committerRyan Dahl <ry@tinyclouds.org>2019-08-24 08:31:14 -0700
commit137f33733d365026903d40e7cde6e34ac6c36dcf (patch)
treee8096e119c374b199cd498ccfa1ee0ef4e6ba950 /js/metrics.ts
parent79f82cf10ed1dbf91346994250d7311a4d74377a (diff)
port more ops to JSON (#2809)
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);
}