Skip to content

Commit

Permalink
rename Wasmedge -> WasmEdge
Browse files Browse the repository at this point in the history
  • Loading branch information
xxchan committed Apr 29, 2023
1 parent d0bb940 commit 7924834
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod test {
crate::engine::common::AggregateTransform<crate::engine::wasmtime::instance::WasmtimeFn>;
} else if #[cfg(feature = "wasmedge-engine")] {
type AggregateTransform =
crate::engine::common::AggregateTransform<crate::engine::wasmedge::instance::WasmedgeFn>;
crate::engine::common::AggregateTransform<crate::engine::wasmedge::instance::WasmEdgeFn>;
} else {
compile_error!("no engine specified");
}
Expand Down
12 changes: 6 additions & 6 deletions crates/fluvio-smartengine/src/engine/wasmedge/imp.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::instance::{WasmedgeContext, WasmedgeFn, WasmedgeInstance};
use super::instance::{WasmEdgeContext, WasmEdgeFn, WasmEdgeInstance};

use tracing::debug;
use wasmedge_sdk::{Executor, Module, Store};
Expand All @@ -9,8 +9,8 @@ use crate::metrics::SmartModuleChainMetrics;
use crate::engine::SmartModuleChainBuilder;
use crate::engine::common::create_transform;

type SmartModuleInit = crate::engine::common::SmartModuleInit<WasmedgeFn>;
type SmartModuleInstance = crate::engine::common::SmartModuleInstance<WasmedgeInstance, WasmedgeFn>;
type SmartModuleInit = crate::engine::common::SmartModuleInit<WasmEdgeFn>;
type SmartModuleInstance = crate::engine::common::SmartModuleInstance<WasmEdgeInstance, WasmEdgeFn>;

#[derive(Clone)]
pub struct SmartEngineImp();
Expand All @@ -28,14 +28,14 @@ pub fn initialize_imp(
) -> Result<SmartModuleChainInstanceImp> {
let executor = Executor::new(None, None).expect("Failed to create WasmEdge executor");
let mut store = Store::new().expect("Failed to create WasmEdge store");
let mut ctx = WasmedgeContext { engine: executor };
let mut ctx = WasmEdgeContext { engine: executor };

let mut instances = Vec::with_capacity(builder.smart_modules.len());
// let mut state = engine.new_state();
for (config, bytes) in builder.smart_modules {
let module = Module::from_bytes(None, bytes)?;
let version = config.version();
let mut instance = WasmedgeInstance::instantiate(
let mut instance = WasmEdgeInstance::instantiate(
&mut store,
&mut ctx.engine,
module,
Expand All @@ -59,7 +59,7 @@ pub fn initialize_imp(

/// SmartModule Chain Instance that can be executed
pub struct SmartModuleChainInstanceImp {
ctx: WasmedgeContext,
ctx: WasmEdgeContext,
instances: Vec<SmartModuleInstance>,
}

Expand Down
18 changes: 9 additions & 9 deletions crates/fluvio-smartengine/src/engine/wasmedge/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@ use crate::engine::wasmedge::memory::{RecordsCallBack, RecordsMemory};
use crate::engine::common::{WasmFn, WasmInstance};
use crate::engine::error::EngineError;

pub(crate) struct WasmedgeInstance {
pub(crate) struct WasmEdgeInstance {
instance: wasmedge_sdk::Instance,
records_cb: Arc<RecordsCallBack>,
params: SmartModuleExtraParams,
version: i16,
}

pub(crate) struct WasmedgeContext {
pub(crate) struct WasmEdgeContext {
pub engine: Executor,
}

pub type WasmedgeFn = Func;
pub type WasmEdgeFn = Func;

impl WasmInstance for WasmedgeInstance {
type Context = WasmedgeContext;
impl WasmInstance for WasmEdgeInstance {
type Context = WasmEdgeContext;

type Func = WasmedgeFn;
type Func = WasmEdgeFn;

fn get_fn(&self, name: &str, _ctx: &mut Self::Context) -> Result<Option<Self::Func>> {
match self.instance.func(name) {
Expand Down Expand Up @@ -76,8 +76,8 @@ impl WasmInstance for WasmedgeInstance {
}
}

impl WasmFn for WasmedgeFn {
type Context = WasmedgeContext;
impl WasmFn for WasmEdgeFn {
type Context = WasmEdgeContext;

fn call(&self, ptr: i32, len: i32, version: i32, ctx: &mut Self::Context) -> Result<i32> {
let res = self.call(
Expand All @@ -92,7 +92,7 @@ impl WasmFn for WasmedgeFn {
}
}

impl WasmedgeInstance {
impl WasmEdgeInstance {
/// instantiate new module instance that contain context
pub(crate) fn instantiate(
store: &mut Store,
Expand Down

0 comments on commit 7924834

Please sign in to comment.