Skip to content

Commit

Permalink
chore(deps): update for control-interface v2.0.0
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
  • Loading branch information
vados-cosmonic authored and brooksmtownsend committed Sep 30, 2024
1 parent fbf06f6 commit 1d085ca
Show file tree
Hide file tree
Showing 17 changed files with 735 additions and 708 deletions.
608 changes: 328 additions & 280 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ wadm-types = { workspace = true }

[workspace.dependencies]
anyhow = "1"
async-nats = "0.33"
async-nats = "0.36"
async-trait = "0.1"
base64 = "0.22.1"
bytes = "1"
Expand Down Expand Up @@ -86,7 +86,7 @@ uuid = "1"
wadm = { version = "0.15.0", path = "./crates/wadm" }
wadm-client = { version = "0.4.0", path = "./crates/wadm-client" }
wadm-types = { version = "0.4.0", path = "./crates/wadm-types" }
wasmcloud-control-interface = "1.0.0"
wasmcloud-control-interface = { version = "2.0.0" }
wasmcloud-secrets-types = "0.2.0"
wit-bindgen-wrpc = { version = "0.3.7", default-features = false }

Expand Down
8 changes: 4 additions & 4 deletions crates/wadm/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
};

use serde::{Deserialize, Serialize};
use wasmcloud_control_interface::InterfaceLinkDefinition;
use wasmcloud_control_interface::Link;

use crate::{
events::{ComponentScaleFailed, ComponentScaled, Event, ProviderStartFailed, ProviderStarted},
Expand Down Expand Up @@ -235,9 +235,9 @@ pub struct PutLink {
pub model_name: String,
}

impl From<PutLink> for InterfaceLinkDefinition {
fn from(value: PutLink) -> InterfaceLinkDefinition {
InterfaceLinkDefinition {
impl From<PutLink> for Link {
fn from(value: PutLink) -> Link {
Link {
source_id: value.source_id,
target: value.target,
name: value.name,
Expand Down
6 changes: 2 additions & 4 deletions crates/wadm/src/events/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ use std::{
use cloudevents::{AttributesReader, Data, Event as CloudEvent, EventBuilder, EventBuilderV10};
use serde::{Deserialize, Serialize};
use thiserror::Error;
use wasmcloud_control_interface::{
ComponentDescription, InterfaceLinkDefinition, ProviderDescription,
};
use wasmcloud_control_interface::{ComponentDescription, Link, ProviderDescription};

use wadm_types::Manifest;

Expand Down Expand Up @@ -424,7 +422,7 @@ event_impl!(
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq)]
pub struct LinkdefSet {
#[serde(flatten)]
pub linkdef: InterfaceLinkDefinition,
pub linkdef: Link,
}

event_impl!(LinkdefSet, "com.wasmcloud.lattice.linkdef_set");
Expand Down
27 changes: 13 additions & 14 deletions crates/wadm/src/scaler/daemonscaler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,10 @@ mod test {
sync::Arc,
};

use anyhow::Result;
use anyhow::{anyhow, Result};
use chrono::Utc;
use wadm_types::{api::StatusType, Spread, SpreadScalerProperty};
use wasmcloud_control_interface::{HostInventory, InterfaceLinkDefinition};
use wasmcloud_control_interface::{HostInventory, Link};

use crate::{
commands::Command,
Expand Down Expand Up @@ -794,20 +794,19 @@ mod test {
// Inserting for heartbeat handling later
lattice_source.inventory.write().await.insert(
host_id_three.to_string(),
HostInventory {
components: vec![],
friendly_name: "hey".to_string(),
labels: HashMap::from_iter([
HostInventory::builder()
.friendly_name("hey".into())
.labels(BTreeMap::from_iter([
("cloud".to_string(), "purgatory".to_string()),
("location".to_string(), "edge".to_string()),
("region".to_string(), "us-brooks-1".to_string()),
]),
providers: vec![],
host_id: host_id_three.to_string(),
version: "1.0.0".to_string(),
uptime_human: "what is time really anyway maaaan".to_string(),
uptime_seconds: 42,
},
]))
.host_id(host_id_three.into())
.version("1.0.0".into())
.uptime_human("what is time really anyway maaaan".into())
.uptime_seconds(42)
.build()
.map_err(|e| anyhow!("failed to build host inventory: {e}"))?,
);
let command_publisher = CommandPublisher::new(NoopPublisher, "doesntmatter");
let status_publisher = StatusPublisher::new(NoopPublisher, None, "doesntmatter");
Expand Down Expand Up @@ -957,7 +956,7 @@ mod test {
.is_empty());
assert!(blobby_daemonscaler
.handle_event(&Event::LinkdefSet(LinkdefSet {
linkdef: InterfaceLinkDefinition::default()
linkdef: Link::default()
}))
.await?
.is_empty());
Expand Down
21 changes: 12 additions & 9 deletions crates/wadm/src/scaler/spreadscaler/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,15 @@ where
(
true,
// TODO(#88): reverse compare too
// Ensure all named configs are the same
linkdef.source_config.iter().all(|config_name| {
self.config.source_config.iter().any(|c| c == config_name)
}) || linkdef.target_config.iter().all(|config_name| {
self.config.target_config.iter().any(|c| c == config_name)
}),
// Ensure all supplied configs (both source and target) are the same
linkdef
.source_config
.iter()
.eq(self.config.source_config.iter())
&& linkdef
.target_config
.iter()
.eq(self.config.target_config.iter()),
)
})
.unwrap_or((false, false));
Expand Down Expand Up @@ -275,7 +278,7 @@ mod test {
vec,
};

use wasmcloud_control_interface::InterfaceLinkDefinition;
use wasmcloud_control_interface::Link;

use chrono::Utc;

Expand Down Expand Up @@ -427,7 +430,7 @@ mod test {
let provider_ref = "provider_ref".to_string();
let provider_id = "provider".to_string();

let linkdef = InterfaceLinkDefinition {
let linkdef = Link {
source_id: component_id.to_string(),
target: provider_id.to_string(),
wit_namespace: "namespace".to_string(),
Expand Down Expand Up @@ -580,7 +583,7 @@ mod test {

let commands = link_scaler
.handle_event(&Event::LinkdefSet(LinkdefSet {
linkdef: InterfaceLinkDefinition {
linkdef: Link {
// NOTE: contract, link, and provider id matches but the component is different
source_id: "nm0001772".to_string(),
target: "VASDASD".to_string(),
Expand Down
4 changes: 2 additions & 2 deletions crates/wadm/src/scaler/spreadscaler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ mod test {
use anyhow::Result;
use chrono::Utc;
use wadm_types::{Spread, SpreadScalerProperty};
use wasmcloud_control_interface::InterfaceLinkDefinition;
use wasmcloud_control_interface::Link;

use crate::{
commands::Command,
Expand Down Expand Up @@ -1499,7 +1499,7 @@ mod test {
.is_empty());
assert!(blobby_spreadscaler
.handle_event(&Event::LinkdefSet(LinkdefSet {
linkdef: InterfaceLinkDefinition::default()
linkdef: Link::default()
}))
.await?
.is_empty());
Expand Down
6 changes: 3 additions & 3 deletions crates/wadm/src/storage/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;

use tokio::sync::RwLock;
use tracing::debug;
use wasmcloud_control_interface::InterfaceLinkDefinition;
use wasmcloud_control_interface::Link;
use wasmcloud_secrets_types::SecretConfig;

use crate::storage::{Component, Host, Provider, ReadStore, StateKind};
Expand All @@ -28,7 +28,7 @@ pub struct SnapshotStore<S, L> {
lattice_source: L,
lattice_id: String,
stored_state: Arc<RwLock<InMemoryData>>,
links: Arc<RwLock<Vec<InterfaceLinkDefinition>>>,
links: Arc<RwLock<Vec<Link>>>,
}

impl<S, L> Clone for SnapshotStore<S, L>
Expand Down Expand Up @@ -165,7 +165,7 @@ where
S: Send + Sync,
L: Send + Sync,
{
async fn get_links(&self) -> anyhow::Result<Vec<InterfaceLinkDefinition>> {
async fn get_links(&self) -> anyhow::Result<Vec<Link>> {
Ok(self.links.read().await.clone())
}
}
Expand Down
8 changes: 4 additions & 4 deletions crates/wadm/src/storage/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ impl From<HostHeartbeat> for Host {
.into_iter()
.map(|component| {
(
component.id, // SAFETY: Unlikely to not fit into a usize, but fallback just in case
component.max_instances.try_into().unwrap_or(usize::MAX),
component.id().into(), // SAFETY: Unlikely to not fit into a usize, but fallback just in case
component.max_instances().try_into().unwrap_or(usize::MAX),
)
})
.collect();
Expand Down Expand Up @@ -326,9 +326,9 @@ impl From<&HostHeartbeat> for Host {
.iter()
.map(|component| {
(
component.id.to_owned(),
component.id().to_owned(),
// SAFETY: Unlikely to not fit into a usize, but fallback just in case
component.max_instances.try_into().unwrap_or(usize::MAX),
component.max_instances().try_into().unwrap_or(usize::MAX),
)
})
.collect();
Expand Down
6 changes: 3 additions & 3 deletions crates/wadm/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{collections::HashMap, sync::Arc};

use serde::{de::DeserializeOwned, Serialize};
use tokio::sync::RwLock;
use wasmcloud_control_interface::{HostInventory, InterfaceLinkDefinition};
use wasmcloud_control_interface::{HostInventory, Link};
use wasmcloud_secrets_types::SecretConfig;

use crate::publisher::Publisher;
Expand Down Expand Up @@ -111,7 +111,7 @@ impl crate::storage::Store for TestStore {
pub struct TestLatticeSource {
pub claims: HashMap<String, Claims>,
pub inventory: Arc<RwLock<HashMap<String, HostInventory>>>,
pub links: Vec<InterfaceLinkDefinition>,
pub links: Vec<Link>,
pub config: HashMap<String, HashMap<String, String>>,
}

Expand All @@ -131,7 +131,7 @@ impl InventorySource for TestLatticeSource {

#[async_trait::async_trait]
impl LinkSource for TestLatticeSource {
async fn get_links(&self) -> anyhow::Result<Vec<InterfaceLinkDefinition>> {
async fn get_links(&self) -> anyhow::Result<Vec<Link>> {
Ok(self.links.clone())
}
}
Expand Down
6 changes: 4 additions & 2 deletions crates/wadm/src/workers/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ impl Worker for CommandWorker {
.map_err(|e| anyhow::anyhow!("{e:?}"));

match res {
Ok(ack) if !ack.success => {
Ok(ack) if !ack.succeeded() => {
message.nack().await;
Err(WorkError::Other(anyhow::anyhow!("{}", ack.message).into()))
Err(WorkError::Other(
anyhow::anyhow!("{}", ack.message()).into(),
))
}
Ok(_) => message.ack().await.map_err(WorkError::from),
Err(e) => {
Expand Down
Loading

0 comments on commit 1d085ca

Please sign in to comment.