Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
chore(ctl)!: update ctl to 0.31.0
Browse files Browse the repository at this point in the history
Signed-off-by: Brooks Townsend <[email protected]>
  • Loading branch information
brooksmtownsend committed Oct 30, 2023
1 parent 1eda4ba commit d46a5fa
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 71 deletions.
17 changes: 4 additions & 13 deletions 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ wash-lib = { version = "0.12", path = "./crates/wash-lib" }
wasm-encoder = "0.33.2"
wasmbus-rpc = "0.15.0"
wasmcloud-component-adapters = "0.3.0"
wasmcloud-control-interface = "0.30"
wasmcloud-control-interface = "0.31"
wasmcloud-test-util = "0.10.0"
wasmparser = "0.115.0"
wat = "1.0.77"
Expand Down
10 changes: 5 additions & 5 deletions crates/wash-lib/src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::HashMap;

use anyhow::{bail, Context, Result};
use tokio::time::Duration;
use wasmcloud_control_interface::{kv::DirectKvStore, Client as CtlClient, CtlOperationAck};
use wasmcloud_control_interface::{Client as CtlClient, CtlOperationAck};

use crate::{
common::boxed_err_to_anyhow,
Expand All @@ -14,7 +14,7 @@ use crate::{

/// Arguments required when starting an actor
pub struct StartActorArgs<'a> {
pub ctl_client: &'a CtlClient<DirectKvStore>,
pub ctl_client: &'a CtlClient,
pub host_id: &'a str,
pub actor_ref: &'a str,
pub count: u16,
Expand Down Expand Up @@ -99,7 +99,7 @@ pub async fn start_actor(

/// Scale a Wasmcloud actor on a given host
pub async fn scale_actor(
client: &CtlClient<DirectKvStore>,
client: &CtlClient,
host_id: &str,
actor_ref: &str,
max_concurrent: Option<u16>,
Expand All @@ -119,7 +119,7 @@ pub async fn scale_actor(

/// Stop an actor
pub async fn stop_actor(
client: &CtlClient<DirectKvStore>,
client: &CtlClient,
host_id: &str,
actor_id: &str,
annotations: Option<HashMap<String, String>>,
Expand Down Expand Up @@ -162,7 +162,7 @@ pub async fn stop_actor(
}

pub async fn update_actor(
client: &CtlClient<DirectKvStore>,
client: &CtlClient,
host_id: &str,
actor_id: &str,
actor_ref: &str,
Expand Down
5 changes: 2 additions & 3 deletions crates/wash-lib/src/cli/capture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use futures::TryStreamExt;
use tokio::io::{stdin, stdout, AsyncReadExt, AsyncWriteExt};
use tokio::time::Instant;
use wasmbus_rpc::core::Invocation;
use wasmcloud_control_interface::kv::DirectKvStore;

use super::{CliConnectionOpts, CommandOutput};
use crate::config::WashConnectionOptions;
Expand Down Expand Up @@ -218,7 +217,7 @@ pub async fn disable(

pub async fn capture(
ctx: async_nats::jetstream::Context,
ctl_client: wasmcloud_control_interface::Client<DirectKvStore>,
ctl_client: wasmcloud_control_interface::Client,
lattice_id: &str,
) -> Result<CommandOutput> {
let stream = ctx.get_stream(stream_name(lattice_id)).await.map_err(|e| {
Expand Down Expand Up @@ -309,7 +308,7 @@ pub async fn capture(
}

async fn get_all_inventory(
ctl_client: &wasmcloud_control_interface::Client<DirectKvStore>,
ctl_client: &wasmcloud_control_interface::Client,
) -> anyhow::Result<Vec<wasmcloud_control_interface::HostInventory>> {
let futs = ctl_client
.get_hosts()
Expand Down
4 changes: 2 additions & 2 deletions crates/wash-lib/src/cli/dev.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;
use console::style;
use wasmcloud_control_interface::{kv::DirectKvStore, Client};
use wasmcloud_control_interface::Client;

use crate::{
actor::{start_actor, stop_actor, StartActorArgs},
Expand All @@ -17,7 +17,7 @@ pub async fn run_dev_loop(
actor_id: ModuleId,
actor_ref: &str,
host_id: ServerId,
ctl_client: &Client<DirectKvStore>,
ctl_client: &Client,
sign_cfg: Option<SignConfig>,
) -> Result<()> {
let built_artifact_path = build_project(project_cfg, sign_cfg)?.canonicalize()?;
Expand Down
2 changes: 2 additions & 0 deletions crates/wash-lib/src/cli/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ pub async fn delete_link(
.await?
.remove_link(actor_id, contract_id, link_name)
.await
.map(|_| ())
.map_err(boxed_err_to_anyhow)
.with_context(|| {
format!(
Expand Down Expand Up @@ -177,6 +178,7 @@ pub async fn create_link(
labels_vec_to_hashmap(link_values.clone())?,
)
.await
.map(|_| ())
.map_err(boxed_err_to_anyhow)
.with_context(|| {
format!(
Expand Down
4 changes: 1 addition & 3 deletions crates/wash-lib/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ pub enum FindIdError {
/// more than one matches, then an error will be returned indicating the options to choose from
pub async fn find_actor_id(
value: &str,
ctl_client: &wasmcloud_control_interface::Client<
wasmcloud_control_interface::kv::DirectKvStore,
>,
ctl_client: &wasmcloud_control_interface::Client,
) -> Result<(ModuleId, Option<String>), FindIdError> {
if let Ok(id) = ModuleId::from_str(value) {
return Ok((id, None));
Expand Down
28 changes: 4 additions & 24 deletions crates/wash-lib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ use std::{
path::PathBuf,
};

use anyhow::{anyhow, Context, Result};
use anyhow::{Context, Result};
use async_nats::Client;
use tokio::io::AsyncReadExt;
use wasmcloud_control_interface::{
kv::DirectKvStore, Client as CtlClient, ClientBuilder as CtlClientBuilder,
};
use wasmcloud_control_interface::{Client as CtlClient, ClientBuilder as CtlClientBuilder};

use crate::context::WashContext;

Expand Down Expand Up @@ -97,10 +95,7 @@ pub struct WashConnectionOptions {

impl WashConnectionOptions {
/// Create a control client from connection options
pub async fn into_ctl_client(
self,
auction_timeout_ms: Option<u64>,
) -> Result<CtlClient<DirectKvStore>> {
pub async fn into_ctl_client(self, auction_timeout_ms: Option<u64>) -> Result<CtlClient> {
let lattice_prefix = self.lattice_prefix.unwrap_or_else(|| {
self.ctx
.as_ref()
Expand Down Expand Up @@ -155,26 +150,11 @@ impl WashConnectionOptions {
.timeout(tokio::time::Duration::from_millis(self.timeout_ms))
.auction_timeout(tokio::time::Duration::from_millis(auction_timeout_ms));

let opts_js_domain = self.js_domain;
let ctx_js_domain = self.ctx.clone().and_then(|c| c.js_domain);
let js_domain = match (opts_js_domain, ctx_js_domain) {
(Some(opts_domain), _) => Some(opts_domain), // flag takes priority
(None, Some(ctx_domain)) => Some(ctx_domain),
_ => None,
};

if let Some(js_domain) = js_domain {
builder = builder.js_domain(js_domain);
}

if let Ok(topic_prefix) = std::env::var("WASMCLOUD_CTL_TOPIC_PREFIX") {
builder = builder.topic_prefix(topic_prefix);
}

let ctl_client = builder
.build()
.await
.map_err(|err| anyhow!("Failed to create control interface client: {err:?}"))?;
let ctl_client = builder.build();

Ok(ctl_client)
}
Expand Down
5 changes: 2 additions & 3 deletions crates/wash-lib/src/spier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use anyhow::Result;
use chrono::{DateTime, Local};
use futures::{Stream, StreamExt};
use wasmbus_rpc::core::Invocation;
use wasmcloud_control_interface::kv::DirectKvStore;

use crate::{
common::{find_actor_id, CLAIMS_NAME, CLAIMS_SUBJECT},
Expand Down Expand Up @@ -91,7 +90,7 @@ impl Spier {
/// be found or if there are connection issues
pub async fn new(
actor_id_or_name: &str,
ctl_client: &wasmcloud_control_interface::Client<DirectKvStore>,
ctl_client: &wasmcloud_control_interface::Client,
nats_client: &async_nats::Client,
) -> Result<Self> {
let (actor_id, friendly_name) = find_actor_id(actor_id_or_name, ctl_client).await?;
Expand Down Expand Up @@ -212,7 +211,7 @@ struct ProviderDetails {
/// Fetches all providers linked to the given actor, along with their link names
async fn get_linked_providers(
actor_id: &ModuleId,
ctl_client: &wasmcloud_control_interface::Client<DirectKvStore>,
ctl_client: &wasmcloud_control_interface::Client,
) -> Result<Vec<ProviderDetails>> {
let mut details = ctl_client
.query_links()
Expand Down
4 changes: 1 addition & 3 deletions src/down/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ async fn stop_hosts(
let client = wasmcloud_control_interface::ClientBuilder::new(nats_client)
.lattice_prefix(lattice_prefix)
.auction_timeout(std::time::Duration::from_secs(2))
.build()
.await
.map_err(|e| anyhow!(e))?;
.build();

let hosts = client.get_hosts().await.map_err(|e| anyhow!(e))?;

Expand Down
17 changes: 3 additions & 14 deletions src/up/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::{
Arc,
};

use anyhow::{anyhow, bail, Context, Result};
use anyhow::{bail, Context, Result};
use async_nats::Client;
use clap::Parser;
use serde_json::json;
Expand All @@ -31,7 +31,6 @@ use wash_lib::start::{
ensure_nats_server, ensure_wasmcloud, start_nats_server, start_wasmcloud_host, NatsConfig,
WADM_PID,
};
use wasmcloud_control_interface::kv::DirectKvStore;
use wasmcloud_control_interface::{Client as CtlClient, ClientBuilder as CtlClientBuilder};

use crate::appearance::spinner::Spinner;
Expand Down Expand Up @@ -243,10 +242,7 @@ pub(crate) struct WasmcloudOpts {
}

impl WasmcloudOpts {
pub async fn into_ctl_client(
self,
auction_timeout_ms: Option<u64>,
) -> Result<CtlClient<DirectKvStore>> {
pub async fn into_ctl_client(self, auction_timeout_ms: Option<u64>) -> Result<CtlClient> {
let lattice_prefix = self.lattice_prefix;
let ctl_host = self
.ctl_host
Expand All @@ -271,18 +267,11 @@ impl WasmcloudOpts {
))
.auction_timeout(tokio::time::Duration::from_millis(auction_timeout_ms));

if let Some(js_domain) = self.wasmcloud_js_domain {
builder = builder.js_domain(js_domain);
}

if let Ok(topic_prefix) = std::env::var("WASMCLOUD_CTL_TOPIC_PREFIX") {
builder = builder.topic_prefix(topic_prefix);
}

let ctl_client = builder
.build()
.await
.map_err(|err| anyhow!("Failed to create control interface client: {err:?}"))?;
let ctl_client = builder.build();

Ok(ctl_client)
}
Expand Down

0 comments on commit d46a5fa

Please sign in to comment.