Skip to content

Commit

Permalink
Fixes for the previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vigoo committed Jan 6, 2025
1 parent ab90ae5 commit 4c92f38
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
14 changes: 10 additions & 4 deletions golem-cli/src/command/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ impl<
} => {
let project_id = projects.resolve_id_or_default(project_ref).await?;

let ctx = ApplicationComponentContext::new(
let mut ctx = ApplicationComponentContext::new(
app,
build_profile.map(|profile| profile.into()),
&component_name.0,
Expand Down Expand Up @@ -401,7 +401,7 @@ impl<

let project_id = projects.resolve_id_or_default_opt(project_ref).await?;

let ctx = ApplicationComponentContext::new(
let mut ctx = ApplicationComponentContext::new(
app,
build_profile.map(|profile| profile.into()),
&component_name,
Expand Down Expand Up @@ -576,15 +576,21 @@ impl ApplicationComponentContext {
})
}

fn dynamic_linking(&self) -> Option<DynamicLinking> {
fn dynamic_linking(&mut self) -> Option<DynamicLinking> {
let mapping = Vec::new();

let wasm_rpc_deps = self
.app_ctx
.application
.component_wasm_rpc_dependencies(&self.name);
.component_wasm_rpc_dependencies(&self.name)
.clone();

for wasm_rpc_dep in wasm_rpc_deps {
let ifaces = self
.app_ctx
.component_stub_interfaces(&wasm_rpc_dep)
.unwrap(); // TODO
println!("{:?}", ifaces);
// let target_props = self
// .app_ctx
// .application
Expand Down
17 changes: 10 additions & 7 deletions golem-common/src/model/component_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,30 @@ impl ComponentMetadata {
}
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Encode, Decode)]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Encode, Decode)]
#[cfg_attr(feature = "poem", derive(poem_openapi::Union))]
#[cfg_attr(feature = "poem", oai(discriminator_name = "type", one_of = true))]
#[serde(tag = "type")]
pub enum DynamicLinkedInstance {
WasmRpc(DynamicLinkedWasmRpc),
}

#[derive(
Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize, Encode, Decode,
)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Encode, Decode)]
#[cfg_attr(feature = "poem", derive(poem_openapi::Object))]
#[cfg_attr(feature = "poem", oai(rename_all = "camelCase"))]
#[serde(rename_all = "camelCase")]
pub struct DynamicLinkedWasmRpc {
pub target_interface_name: String,
/// Maps resource names within the dynamic linked interface to target interfaces
pub target_interface_name: HashMap<String, String>,
}

impl DynamicLinkedWasmRpc {
pub fn target_site(&self) -> Result<ParsedFunctionSite, String> {
ParsedFunctionSite::parse(&self.target_interface_name)
pub fn target_site(&self, stub_resource: &str) -> Result<ParsedFunctionSite, String> {
let target_interface = self
.target_interface_name
.get(stub_resource)
.ok_or("Resource not found in dynamic linked interface")?;
ParsedFunctionSite::parse(&target_interface)
}
}

Expand Down
17 changes: 10 additions & 7 deletions wasm-rpc-stubgen/src/commands/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub enum ApplicationSourceMode {
Explicit(Vec<PathBuf>),
}

#[derive(Debug)]
pub struct ComponentStubInterfaces {
stub_interface_name: String,
exported_interfaces: Vec<String>,
Expand Down Expand Up @@ -325,14 +326,15 @@ impl<CPE: ComponentPropertiesExtensions> ApplicationContext<CPE> {
version: stub_def.source_package_name.version.clone(),
};

Ok(ComponentStubInterfaces {
let result = ComponentStubInterfaces {
stub_interface_name: stub_package_name.interface_id(&stub_def.target_interface_name()),
exported_interfaces: vec![stub_def
exported_interfaces: stub_def
.stub_imported_interfaces()
.iter()
.flat_map(|interface| interface.owner_interface.clone())
.collect()],
})
.filter_map(|interface| interface.owner_interface.clone())
.collect(),
};
Ok(result)
}

fn common_wit_deps(&self) -> anyhow::Result<&WitDepsResolver> {
Expand Down Expand Up @@ -1293,8 +1295,9 @@ async fn build_stub<CPE: ComponentPropertiesExtensions>(
);
fs::create_dir_all(&target_root)?;

let result =
commands::generate::build(&stub_def, &stub_wasm, &stub_wit, ctx.config.offline).await;
let offline = ctx.config.offline;
let stub_def = ctx.component_stub_def(component_name)?;
let result = commands::generate::build(&stub_def, &stub_wasm, &stub_wit, offline).await;
match result {
Ok(()) => {
task_result_marker.success()?;
Expand Down

0 comments on commit 4c92f38

Please sign in to comment.