Skip to content

Commit

Permalink
fix: explicitly use wasi on smartengine uses
Browse files Browse the repository at this point in the history
remove feature flag, wasi is always on if the engine is on
  • Loading branch information
digikata committed May 6, 2024
1 parent 00c01c5 commit 853f4fa
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 57 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,28 +165,28 @@ k8-diff = { version = "0.1.2" }
trybuild = { branch = "check_option", git = "https://github.com/infinyon/trybuild" }

# Internal fluvio dependencies
fluvio = { version = "0.22.0", path = "crates/fluvio" }
fluvio = { path = "crates/fluvio" }
fluvio-auth = { path = "crates/fluvio-auth" }
fluvio-channel = { path = "crates/fluvio-channel" }
fluvio-cli-common = { path = "crates/fluvio-cli-common"}
fluvio-compression = { version = "0.3", path = "crates/fluvio-compression" }
fluvio-compression = { path = "crates/fluvio-compression" }
fluvio-connector-package = { path = "crates/fluvio-connector-package/" }
fluvio-controlplane = { path = "crates/fluvio-controlplane" }
fluvio-controlplane-metadata = { version = "0.28.0", default-features = false, path = "crates/fluvio-controlplane-metadata" }
fluvio-extension-common = { path = "crates/fluvio-extension-common", default-features = false }
fluvio-hub-util = { path = "crates/fluvio-hub-util" }
fluvio-package-index = { version = "0.7.0", path = "crates/fluvio-package-index", default-features = false }
fluvio-protocol = { version = "0.10.12", path = "crates/fluvio-protocol" }
fluvio-sc-schema = { version = "0.24.0", path = "crates/fluvio-sc-schema", default-features = false }
fluvio-protocol = { path = "crates/fluvio-protocol" }
fluvio-sc-schema = { path = "crates/fluvio-sc-schema", default-features = false }
fluvio-service = { path = "crates/fluvio-service" }
fluvio-smartengine = { version = "0.7.0", path = "crates/fluvio-smartengine", default-features = false }
fluvio-smartmodule = { version = "0.7.0", path = "crates/fluvio-smartmodule", default-features = false }
fluvio-socket = { version = "0.14.3", path = "crates/fluvio-socket", default-features = false }
fluvio-spu-schema = { version = "0.14.5", path = "crates/fluvio-spu-schema", default-features = false }
fluvio-smartengine = { path = "crates/fluvio-smartengine", default-features = false }
fluvio-smartmodule = { path = "crates/fluvio-smartmodule", default-features = false }
fluvio-socket = { path = "crates/fluvio-socket", default-features = false }
fluvio-spu-schema = { path = "crates/fluvio-spu-schema", default-features = false }
fluvio-storage = { path = "crates/fluvio-storage" }
fluvio-stream-dispatcher = { version = "0.13.0", path = "crates/fluvio-stream-dispatcher" }
fluvio-stream-model = { version = "0.11.0", path = "crates/fluvio-stream-model", default-features = false }
fluvio-types = { version = "0.4.4", path = "crates/fluvio-types", default-features = false }
fluvio-stream-dispatcher = { path = "crates/fluvio-stream-dispatcher" }
fluvio-stream-model = { path = "crates/fluvio-stream-model", default-features = false }
fluvio-types = { path = "crates/fluvio-types", default-features = false }
fluvio-kv-storage = { path = "crates/fluvio-kv-storage", default-features = false }

# Used to make eyre faster on debug builds
Expand Down
5 changes: 2 additions & 3 deletions crates/fluvio-connector-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ description = "Fluvio Connector Common SDK"
[features]
default = []
derive = ["fluvio-connector-derive"]
wasi = ["fluvio-smartengine/wasi"]

[[test]]
name = "derive-test"
Expand All @@ -33,10 +32,10 @@ fluvio-future = { workspace = true, features = ["subscriber"] }
fluvio-connector-package = { workspace = true }
fluvio-connector-derive = { path = "../fluvio-connector-derive/", optional = true }
fluvio-sc-schema = { workspace = true }
fluvio-smartengine = { workspace = true , features = [ "transformation"] }
fluvio-smartengine = { workspace = true , features = [ "transformation", "engine"] }


[dev-dependencies]
trybuild = { version = "1.0" } # default workspace dep is forked and fails for this crate
trybuild = { version = "1.0" } # default workspace dep is forked and fails for this crate
serde = { workspace = true, features = ["derive"]}
fluvio = { workspace = true }
8 changes: 6 additions & 2 deletions crates/fluvio-connector-common/src/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@ pub async fn consumer_stream_from_config(
if let Some(smartmodules) = smartmodule_vec_from_config(config) {
builder.smartmodule(smartmodules);
}

let stream = fluvio.consumer_with_config(builder.build()?).await?;
tracing::info!("Building config");
let cfg = builder.build().map_err(|e| {
tracing::error!("Config build error: {e}");
e
})?;
let stream = fluvio.consumer_with_config(cfg).await?;

Ok((fluvio, stream))
}
5 changes: 2 additions & 3 deletions crates/fluvio-smartengine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ description = "The official Fluvio SmartEngine"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
engine = ["wasmtime"]
wasi = ["wasmtime-wasi", "engine"]
engine = ["wasmtime", "wasmtime-wasi"]
transformation = ["serde_json", "serde_yaml", "humantime-serde"]
default = ["engine", "wasi"]
default = ["engine"]


[dependencies]
Expand Down
23 changes: 0 additions & 23 deletions crates/fluvio-smartengine/src/engine/wasmtime/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ pub struct WasmState(Store<Context>);

pub struct Context {
limiter: StoreResourceLimiter,
#[cfg(feature = "wasi")]
wasi_ctx: wasmtime_wasi::WasiCtx,
}

Expand Down Expand Up @@ -54,28 +53,6 @@ impl WasmState {
}
}

#[cfg(not(feature = "wasi"))]
impl WasmState {
pub(crate) fn new(engine: &Engine, limiter: StoreResourceLimiter) -> Self {
let mut s = Self(Store::new(engine, Context { limiter }));
s.0.limiter(|inner| &mut inner.limiter);
s.top_up_fuel();
s
}

pub(crate) fn instantiate<Params, Args>(
&mut self,
module: &Module,
host_fn: impl IntoFunc<<Self as AsContext>::Data, Params, Args>,
) -> Result<Instance, Error> {
use wasmtime::Func;

let func = Func::wrap(&mut *self, host_fn);
Instance::new(self, module, &[func.into()])
}
}

#[cfg(feature = "wasi")]
impl WasmState {
pub(crate) fn new(engine: &Engine, limiter: StoreResourceLimiter) -> Self {
let wasi_ctx = wasmtime_wasi::WasiCtxBuilder::new()
Expand Down
2 changes: 1 addition & 1 deletion crates/fluvio-spu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fluvio-future = { workspace = true,features = [
"openssl_tls",
"zero_copy",
] }
fluvio-smartengine = { workspace = true, optional = true }
fluvio-smartengine = { workspace = true, optional = true, features = ["engine"] }
fluvio-smartmodule = { workspace = true}
fluvio-kv-storage = { workspace = true}

Expand Down
2 changes: 1 addition & 1 deletion crates/fluvio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fluvio"
version = "0.22.1"
version = "0.22.2"
edition = "2021"
license = "Apache-2.0"
authors = ["Fluvio Contributors <team@fluvio.io>"]
Expand Down
5 changes: 4 additions & 1 deletion crates/fluvio/src/consumer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,10 @@ where
let batch: Result<Batch, _> = raw_batch.try_into();
match batch {
Ok(batch) => Ok(batch),
Err(err) => Err(ErrorCode::Other(err.to_string())),
Err(err) => {
tracing::error!("{err:?}");
Err(ErrorCode::Other(err.to_string()))
}
}
});
let error = {
Expand Down
2 changes: 1 addition & 1 deletion crates/smartmodule-development-kit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fluvio = { path = "../fluvio", default-features = false }
fluvio-hub-util = { path = "../fluvio-hub-util" }
fluvio-protocol = { path = "../fluvio-protocol", features=["record","api"] }
fluvio-future = { workspace = true, features = ["subscriber"]}
fluvio-smartengine = { path = "../fluvio-smartengine", features = ["transformation", "wasi"] }
fluvio-smartengine = { path = "../fluvio-smartengine", features = ["transformation"] }
fluvio-extension-common = { path = "../fluvio-extension-common", features = ["target"] }
fluvio-controlplane-metadata = { path = "../fluvio-controlplane-metadata", features = ["smartmodule"] }
fluvio-sc-schema = { path = "../fluvio-sc-schema" }
Expand Down
14 changes: 7 additions & 7 deletions makefiles/check.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ check-udeps: install-udeps
cargo +nightly udeps --all-targets

install-deny:
cargo install --locked cargo-deny
cargo install --locked cargo-deny

check-crate-audit: install-deny
cargo deny check
Expand All @@ -39,8 +39,8 @@ run-all-unit-test: install_rustup_target
cargo test -p fluvio-storage $(BUILD_FLAGS)
cargo test -p fluvio-channel-cli $(BUILD_FLAGS)
cargo test -p fluvio-connector-derive $(BUILD_FLAGS)
cargo test -p fluvio-connector-common --all-features $(BUILD_FLAGS)
cargo test -p fluvio-connector-package $(BUILD_FLAGS)
cargo test -p fluvio-connector-common --all-features $(BUILD_FLAGS)
cargo test -p fluvio-connector-package $(BUILD_FLAGS)
cargo test -p fluvio-controlplane-metadata --features=smartmodule $(BUILD_FLAGS)
make test-all -C crates/fluvio-protocol

Expand All @@ -51,7 +51,7 @@ run-integration-test: build_smartmodules install_rustup_target

cargo test -p fluvio-smartengine -- --ignored --test-threads=1
rustup target add wasm32-wasi
cargo test --features wasi -p fluvio-smartengine -- --ignored --test-threads=1
cargo test -p fluvio-smartengine -- --ignored --test-threads=1

run-smartmodule-test: build_smartmodules
cargo test -p fluvio-smartengine -- --ignored --nocapture
Expand All @@ -60,12 +60,12 @@ run-k8-test: install_rustup_target k8-setup build_k8_image
cargo test --lib -p fluvio-sc -- --ignored --test-threads=1


run-all-doc-test: install_rustup_target
run-all-doc-test: install_rustup_target
cargo test --all-features --doc $(BUILD_FLAGS)

run-client-doc-test: install_rustup_target
run-client-doc-test: install_rustup_target
cargo test --all-features --doc -p fluvio-cli $(BUILD_FLAGS)
cargo test --all-features --doc -p fluvio-cluster $(BUILD_FLAGS)
cargo test --all-features --doc -p fluvio-cluster $(BUILD_FLAGS)
cargo test --all-features --doc -p fluvio $(BUILD_FLAGS)


Expand Down
4 changes: 2 additions & 2 deletions smartmodule/examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion smartmodule/examples/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
default: build

build:
rustup target add wasm32-unknown-unknown
rustup target add wasm32-wasi
cargo build --release

clean:
Expand Down

0 comments on commit 853f4fa

Please sign in to comment.