diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-04-28 18:41:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-28 18:41:50 +0200 |
commit | 0260b488fbba9a43c64641428d3603b8761067a4 (patch) | |
tree | 66ce487f9241a3b91942dd048c7e43cb192bf9e8 /runtime/ops/runtime.rs | |
parent | b28f9445aae85dbf86033300cfcb55e404529a23 (diff) |
core: introduce extensions (#9800)
Extensions allow declarative extensions to "JsRuntime" (ops, state, JS or middleware).
This allows for:
- `op_crates` to be plug-and-play & self-contained, reducing complexity leaked to consumers
- op middleware (like metrics_op) to be opt-in and for new middleware (unstable, tracing,...)
- `MainWorker` and `WebWorker` to be composable, allowing users to extend workers with their ops whilst benefiting from the other infrastructure (inspector, etc...)
In short extensions improve deno's modularity, reducing complexity and leaky abstractions for embedders and the internal codebase.
Diffstat (limited to 'runtime/ops/runtime.rs')
-rw-r--r-- | runtime/ops/runtime.rs | 32 |
1 files changed, 0 insertions, 32 deletions
diff --git a/runtime/ops/runtime.rs b/runtime/ops/runtime.rs index a02bf4548..7d84fadff 100644 --- a/runtime/ops/runtime.rs +++ b/runtime/ops/runtime.rs @@ -1,13 +1,8 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -use crate::metrics::OpMetrics; -use crate::metrics::RuntimeMetrics; -use crate::ops::UnstableChecker; use crate::permissions::Permissions; use deno_core::error::AnyError; use deno_core::error::Context; -use deno_core::serde_json::json; -use deno_core::serde_json::Value; use deno_core::ModuleSpecifier; use deno_core::OpState; use deno_core::ZeroCopyBuf; @@ -19,7 +14,6 @@ pub fn init(rt: &mut deno_core::JsRuntime, main_module: ModuleSpecifier) { state.put::<ModuleSpecifier>(main_module); } super::reg_sync(rt, "op_main_module", op_main_module); - super::reg_sync(rt, "op_metrics", op_metrics); } fn op_main_module( @@ -41,32 +35,6 @@ fn op_main_module( Ok(main) } -#[derive(serde::Serialize)] -struct MetricsReturn { - combined: OpMetrics, - ops: Value, -} - -#[allow(clippy::unnecessary_wraps)] -fn op_metrics( - state: &mut OpState, - _args: (), - _zero_copy: Option<ZeroCopyBuf>, -) -> Result<MetricsReturn, AnyError> { - let m = state.borrow::<RuntimeMetrics>(); - let combined = m.combined_metrics(); - let unstable_checker = state.borrow::<UnstableChecker>(); - let maybe_ops = if unstable_checker.unstable { - Some(&m.ops) - } else { - None - }; - Ok(MetricsReturn { - combined, - ops: json!(maybe_ops), - }) -} - pub fn ppid() -> i64 { #[cfg(windows)] { |