From 49a1517896fc6e3caa167e34afeddf04413b7de7 Mon Sep 17 00:00:00 2001 From: paulobressan Date: Thu, 7 Sep 2023 16:46:53 -0300 Subject: [PATCH] chore: updated deno dependence --- Cargo.lock | 124 ++++++++-------------------------------- Cargo.toml | 2 - src/filters/deno/mod.rs | 15 +++-- src/filters/mod.rs | 28 ++++++--- 4 files changed, 52 insertions(+), 117 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 950eba42..716a0962 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1681,7 +1681,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6632cedee6cbc6ee121edf9e81985edc4547efa9d5dec5d9437ee47d6d2a6749" dependencies = [ "async-trait", - "deno_core 0.204.0", + "deno_core", "tokio", "uuid", ] @@ -1693,7 +1693,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "66ea6e93e9102cfe3bfff31e1e12e8f64fac80dfcd42ceaf0149cea9a933f3e9" dependencies = [ "async-trait", - "deno_core 0.204.0", + "deno_core", "rusqlite", "serde", "sha2", @@ -1706,7 +1706,7 @@ version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a1c32084b9ff8667d7d2176262739ce473e0341c7625325b48a2fbab0c903dc" dependencies = [ - "deno_core 0.204.0", + "deno_core", ] [[package]] @@ -1717,7 +1717,7 @@ checksum = "b4ddf51deb9a3bb60a4ab74784414b3f2f89de83a77d6d90a64c6447f7765d68" dependencies = [ "anyhow", "bytes", - "deno_ops 0.82.0", + "deno_ops", "deno_unsync", "futures", "indexmap 1.9.3", @@ -1728,39 +1728,12 @@ dependencies = [ "pin-project", "serde", "serde_json", - "serde_v8 0.115.0", + "serde_v8", "smallvec", "sourcemap", "tokio", "url", - "v8 0.74.3", -] - -[[package]] -name = "deno_core" -version = "0.208.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aab2b013707b6a1bb1e56404b72a4f68220d0fbe1184133b2b21386a8ffbc5d8" -dependencies = [ - "anyhow", - "bytes", - "deno_ops 0.86.0", - "deno_unsync", - "futures", - "indexmap 1.9.3", - "libc", - "log", - "once_cell", - "parking_lot", - "pin-project", - "serde", - "serde_json", - "serde_v8 0.119.0", - "smallvec", - "sourcemap", - "tokio", - "url", - "v8 0.75.1", + "v8", ] [[package]] @@ -1777,7 +1750,7 @@ dependencies = [ "const-oid", "ctr", "curve25519-dalek 2.1.3", - "deno_core 0.204.0", + "deno_core", "deno_web", "elliptic-curve 0.12.3", "num-traits", @@ -1807,7 +1780,7 @@ checksum = "067336cb3a415cce643007c8ace7872a19a517d6e1eccbf9e8cfff8d886fb31a" dependencies = [ "bytes", "data-url", - "deno_core 0.204.0", + "deno_core", "deno_tls", "dyn-clone", "http", @@ -1823,7 +1796,7 @@ version = "0.105.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8903b6b849ab9d6d24f0bffe21bce6f64205cab411daf9e73482fe4260e4feca" dependencies = [ - "deno_core 0.204.0", + "deno_core", "dlopen", "dynasmrt", "libffi", @@ -1842,7 +1815,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21bf05b1bc2c42e407a83e8724d4569006acaf97f2c43e04ae013541add84f05" dependencies = [ "async-trait", - "deno_core 0.204.0", + "deno_core", "deno_io", "filetime", "fs3", @@ -1867,7 +1840,7 @@ dependencies = [ "brotli", "bytes", "cache_control", - "deno_core 0.204.0", + "deno_core", "deno_net", "deno_websocket", "flate2", @@ -1898,7 +1871,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c09188978bdaea1ac7c413a75993df239f4e605641b2ac2a125f0e7216cdc8" dependencies = [ "async-trait", - "deno_core 0.204.0", + "deno_core", "filetime", "fs3", "once_cell", @@ -1916,7 +1889,7 @@ dependencies = [ "async-trait", "base64 0.13.1", "chrono", - "deno_core 0.204.0", + "deno_core", "deno_unsync", "hex", "log", @@ -1962,7 +1935,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dab18a468aa3b7053f1bfa075d989fc75f69bb7ebca72cca9e2125eec141a4dd" dependencies = [ - "deno_core 0.204.0", + "deno_core", "libloading", ] @@ -1972,7 +1945,7 @@ version = "0.110.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bea49a9aeca4e5f93e47223aee15297b580b1bea758c557a80b4717c2ee1502e" dependencies = [ - "deno_core 0.204.0", + "deno_core", "deno_tls", "enum-as-inner", "log", @@ -1994,7 +1967,7 @@ dependencies = [ "brotli", "cbc", "data-encoding", - "deno_core 0.204.0", + "deno_core", "deno_fetch", "deno_fs", "deno_media_type", @@ -2082,26 +2055,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "deno_ops" -version = "0.86.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b116802ace73e3dd910081652789c85aa21f057b9f5936255d786965816fb3b1" -dependencies = [ - "deno-proc-macro-rules", - "lazy-regex 2.5.0", - "once_cell", - "pmutil", - "proc-macro-crate", - "proc-macro2 1.0.66", - "quote 1.0.32", - "regex", - "strum 0.25.0", - "strum_macros 0.25.2", - "syn 2.0.27", - "thiserror", -] - [[package]] name = "deno_runtime" version = "0.126.0" @@ -2113,7 +2066,7 @@ dependencies = [ "deno_broadcast_channel", "deno_cache", "deno_console", - "deno_core 0.204.0", + "deno_core", "deno_crypto", "deno_fetch", "deno_ffi", @@ -2176,7 +2129,7 @@ version = "0.105.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b8d622d1a59b48192258274bf58a5a6f44d4a0497fc8c4396c1a37759385417" dependencies = [ - "deno_core 0.204.0", + "deno_core", "once_cell", "rustls 0.21.7", "rustls-native-certs", @@ -2201,7 +2154,7 @@ version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9915e0eecac8ed1177b99eca8a220abfdcd8f4e7c5b0d99443b6b81eb90472b" dependencies = [ - "deno_core 0.204.0", + "deno_core", "serde", "urlpattern", ] @@ -2215,7 +2168,7 @@ dependencies = [ "async-trait", "base64-simd", "bytes", - "deno_core 0.204.0", + "deno_core", "encoding_rs", "flate2", "futures", @@ -2231,7 +2184,7 @@ version = "0.118.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71b84c418b9748f166a004eba3a67b2a8f8c1b9661bbe509c7c31cc21d7c72f6" dependencies = [ - "deno_core 0.204.0", + "deno_core", ] [[package]] @@ -2241,7 +2194,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89753655b393b285fea4bfc4ecda5c0f53d431f26f05bbe2310e8cc3feb28156" dependencies = [ "bytes", - "deno_core 0.204.0", + "deno_core", "deno_net", "deno_tls", "fastwebsockets", @@ -2259,7 +2212,7 @@ version = "0.113.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03592d0706804268875215a0c6c7e03f9c14759c4796565864f95b46f1292a7d" dependencies = [ - "deno_core 0.204.0", + "deno_core", "deno_web", "rusqlite", "serde", @@ -4379,7 +4332,6 @@ dependencies = [ "clap", "config", "crossterm", - "deno_core 0.208.0", "deno_runtime", "elasticsearch", "env_logger", @@ -5817,23 +5769,7 @@ dependencies = [ "serde_bytes", "smallvec", "thiserror", - "v8 0.74.3", -] - -[[package]] -name = "serde_v8" -version = "0.119.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85efce3bb967c7cd2be8058f7b06047489e0b0888fc25db9e3aa7907370ae45c" -dependencies = [ - "bytes", - "derive_more", - "num-bigint", - "serde", - "serde_bytes", - "smallvec", - "thiserror", - "v8 0.75.1", + "v8", ] [[package]] @@ -7316,18 +7252,6 @@ dependencies = [ "which", ] -[[package]] -name = "v8" -version = "0.75.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a0e0cb10989bf856c2fdd1b6bed1bc6f96148230aa0c954634299125c1f64230" -dependencies = [ - "bitflags 1.3.2", - "fslock", - "once_cell", - "which", -] - [[package]] name = "valuable" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 00d0fd98..e71e54be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,6 @@ readme = "README.md" authors = ["Santiago Carmuega "] [features] -default = ["deno"] deno = ["deno_runtime"] sink-file-rotate = ["file-rotate"] sink-webhook = ["reqwest"] @@ -72,7 +71,6 @@ google-cloud-pubsub = { version = "0.16.0", optional = true } google-cloud-googleapis = { version = "0.10.0", optional = true } google-cloud-default = { version = "0.4.0", optional = true, features = ["pubsub"] } r2d2_redis = { version = "0.14.0", optional = true } -deno_core = { version = "0.208.0", optional = true } deno_runtime = { version = "0.126.0", optional = true } jsonwebtoken = { version = "8.3.0", optional = true } file-rotate = { version = "0.7.5", optional = true } diff --git a/src/filters/deno/mod.rs b/src/filters/deno/mod.rs index 26870b83..be6fd07c 100644 --- a/src/filters/deno/mod.rs +++ b/src/filters/deno/mod.rs @@ -1,7 +1,6 @@ //! A mapper with custom logic from using the Deno runtime -use deno_runtime::deno_core; -use deno_runtime::deno_core::{op, ModuleSpecifier, OpState}; +use deno_runtime::deno_core::{self, op2, ModuleSpecifier, OpState}; use deno_runtime::permissions::PermissionsContainer; use deno_runtime::worker::{MainWorker as DenoWorker, WorkerOptions}; use gasket::framework::*; @@ -17,18 +16,18 @@ pub type WrappedRuntime = DenoWorker; deno_core::extension!(deno_filter, ops = [op_pop_record, op_put_record]); -#[op] -fn op_pop_record(state: &mut OpState) -> Result { +#[op2] +#[serde] +pub fn op_pop_record(state: &mut OpState) -> Result { let r: Record = state.take(); let j = serde_json::Value::from(r); - Ok(j) } -#[op] -fn op_put_record( +#[op2] +pub fn op_put_record( state: &mut OpState, - value: serde_json::Value, + #[serde] value: serde_json::Value, ) -> Result<(), deno_core::error::AnyError> { match value { serde_json::Value::Null => (), diff --git a/src/filters/mod.rs b/src/filters/mod.rs index 065abfe1..16f6f80c 100644 --- a/src/filters/mod.rs +++ b/src/filters/mod.rs @@ -6,7 +6,6 @@ use serde::Deserialize; use crate::framework::*; -pub mod deno; pub mod dsl; pub mod json; pub mod legacy_v1; @@ -16,6 +15,9 @@ pub mod parse_cbor; pub mod split_block; pub mod wasm; +#[cfg(feature = "deno")] +pub mod deno; + pub enum Bootstrapper { Noop(noop::Stage), SplitBlock(split_block::Stage), @@ -23,9 +25,11 @@ pub enum Bootstrapper { Json(json::Stage), LegacyV1(legacy_v1::Stage), Wasm(wasm::Stage), - Deno(deno::Stage), ParseCbor(parse_cbor::Stage), MatchPattern(match_pattern::Stage), + + #[cfg(feature = "deno")] + Deno(deno::Stage), } impl StageBootstrapper for Bootstrapper { @@ -37,9 +41,11 @@ impl StageBootstrapper for Bootstrapper { Bootstrapper::Json(p) => p.input.connect(adapter), Bootstrapper::LegacyV1(p) => p.input.connect(adapter), Bootstrapper::Wasm(p) => p.input.connect(adapter), - Bootstrapper::Deno(p) => p.input.connect(adapter), Bootstrapper::ParseCbor(p) => p.input.connect(adapter), Bootstrapper::MatchPattern(p) => p.input.connect(adapter), + + #[cfg(feature = "deno")] + Bootstrapper::Deno(p) => p.input.connect(adapter), } } @@ -51,9 +57,11 @@ impl StageBootstrapper for Bootstrapper { Bootstrapper::Json(p) => p.output.connect(adapter), Bootstrapper::LegacyV1(p) => p.output.connect(adapter), Bootstrapper::Wasm(p) => p.output.connect(adapter), - Bootstrapper::Deno(p) => p.output.connect(adapter), Bootstrapper::ParseCbor(p) => p.output.connect(adapter), Bootstrapper::MatchPattern(p) => p.output.connect(adapter), + + #[cfg(feature = "deno")] + Bootstrapper::Deno(p) => p.output.connect(adapter), } } @@ -65,9 +73,11 @@ impl StageBootstrapper for Bootstrapper { Bootstrapper::Json(x) => gasket::runtime::spawn_stage(x, policy), Bootstrapper::LegacyV1(x) => gasket::runtime::spawn_stage(x, policy), Bootstrapper::Wasm(x) => gasket::runtime::spawn_stage(x, policy), - Bootstrapper::Deno(x) => gasket::runtime::spawn_stage(x, policy), Bootstrapper::ParseCbor(x) => gasket::runtime::spawn_stage(x, policy), Bootstrapper::MatchPattern(x) => gasket::runtime::spawn_stage(x, policy), + + #[cfg(feature = "deno")] + Bootstrapper::Deno(x) => gasket::runtime::spawn_stage(x, policy), } } } @@ -81,9 +91,11 @@ pub enum Config { Json(json::Config), LegacyV1(legacy_v1::Config), Wasm(wasm::Config), - Deno(deno::Config), ParseCbor(parse_cbor::Config), MatchPattern(match_pattern::Config), + + #[cfg(feature = "deno")] + Deno(deno::Config), } impl Config { @@ -95,9 +107,11 @@ impl Config { Config::Json(c) => Ok(Bootstrapper::Json(c.bootstrapper(ctx)?)), Config::LegacyV1(c) => Ok(Bootstrapper::LegacyV1(c.bootstrapper(ctx)?)), Config::Wasm(c) => Ok(Bootstrapper::Wasm(c.bootstrapper(ctx)?)), - Config::Deno(c) => Ok(Bootstrapper::Deno(c.bootstrapper(ctx)?)), Config::ParseCbor(c) => Ok(Bootstrapper::ParseCbor(c.bootstrapper(ctx)?)), Config::MatchPattern(c) => Ok(Bootstrapper::MatchPattern(c.bootstrapper(ctx)?)), + + #[cfg(feature = "deno")] + Config::Deno(c) => Ok(Bootstrapper::Deno(c.bootstrapper(ctx)?)), } } }