Skip to content

Commit

Permalink
- add not(target_arch=wasm32) to all cfg(chunkify ) (#89)
Browse files Browse the repository at this point in the history
- move nkeys into not-wasm32 dependencies
- bump to 0.8.2

Signed-off-by: stevelr <[email protected]>
  • Loading branch information
stevelr authored Mar 1, 2022
1 parent 7e3cfd6 commit 2c9abde
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions rpc-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wasmbus-rpc"
version = "0.8.1"
version = "0.8.2"
authors = [ "wasmcloud Team" ]
license = "Apache-2.0"
description = "Runtime library for actors and capability providers"
Expand All @@ -27,7 +27,6 @@ base64 = "0.13"
cfg-if = "1.0"
log = "0.4"
minicbor = { version = "0.13", features = ["std", "partial-skip-support" ] }
nkeys = "0.2"
rmp-serde = { version = "0.15.4" }
serde_bytes = "0.11"
serde_json = "1.0"
Expand All @@ -49,6 +48,7 @@ tokio = { version = "1", features = ["full"]}
futures = "0.3"
nats-aflowt = "0.16.104"
nats = { version = "0.17", optional=true }
nkeys = "0.2"
once_cell = "1.8"
crossbeam = "0.8"
uuid = { version = "0.8", features=["v4", "serde"] }
Expand Down
2 changes: 1 addition & 1 deletion rpc-rs/src/actor_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#![cfg(target_arch = "wasm32")]

use crate::{
common::Message,
error::{RpcError, RpcResult},
Message,
};
use async_trait::async_trait;

Expand Down
2 changes: 1 addition & 1 deletion rpc-rs/src/chunkify.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(feature = "chunkify")]
#![cfg(all(feature = "chunkify", not(target_arch = "wasm32")))]

// You strike me as a message that has never been chunkified
// I'm sure I don't know what you mean, You forget yourself
Expand Down
2 changes: 1 addition & 1 deletion rpc-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub type CallResult = std::result::Result<Vec<u8>, Box<dyn std::error::Error + S
pub type HandlerResult<T> = std::result::Result<T, Box<dyn std::error::Error + Sync + Send>>;
pub type TomlMap = toml::value::Map<String, toml::value::Value>;

#[cfg(feature = "chunkify")]
#[cfg(all(feature = "chunkify", not(target_arch = "wasm32")))]
pub(crate) mod chunkify;
mod wasmbus_core;

Expand Down
8 changes: 4 additions & 4 deletions rpc-rs/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! common provider wasmbus support
//!
#[cfg(feature = "chunkify")]
#[cfg(all(feature = "chunkify", not(target_arch = "wasm32")))]
use crate::chunkify::chunkify_endpoint;
pub use crate::rpc_client::make_uuid;
use crate::{
Expand Down Expand Up @@ -114,7 +114,7 @@ impl HostBridge {
Self::new_client(NatsClientType::Async(nats), host_data)
}

#[cfg(feature = "chunkify")]
#[cfg(all(feature = "chunkify", not(target_arch = "wasm32")))]
pub(crate) fn new_sync_client(&self) -> RpcResult<nats::Connection> {
//let key = if self.host_data.is_test() {
// wascap::prelude::KeyPair::new_user()
Expand Down Expand Up @@ -442,7 +442,7 @@ impl HostBridge {
}

async fn dechunk_validate(&self, inv: &mut Invocation) -> RpcResult<()> {
#[cfg(feature = "chunkify")]
#[cfg(all(feature = "chunkify", not(target_arch = "wasm32")))]
if inv.content_length.is_some() && inv.content_length.unwrap() > inv.msg.len() as u64 {
let inv_id = inv.id.clone();
let lattice = self.rpc_client.lattice_prefix().to_string();
Expand Down Expand Up @@ -729,7 +729,7 @@ async fn publish_invocation_response(

let response = {
cfg_if! {
if #[cfg(feature="chunkify")] {
if #[cfg(all(feature = "chunkify", not(target_arch = "wasm32")))] {
let inv_id = response.invocation_id.clone();
if crate::chunkify::needs_chunking(response.msg.len()) {
let msg = response.msg;
Expand Down
2 changes: 1 addition & 1 deletion rpc-rs/src/provider_main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ where
let _ = shutdown_rx.await;

// close chunkifiers
#[cfg(feature = "chunkify")]
#[cfg(all(feature = "chunkify", not(target_arch = "wasm32")))]
crate::chunkify::shutdown();

// stop the logger thread
Expand Down
10 changes: 4 additions & 6 deletions rpc-rs/src/rpc_client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![cfg(not(target_arch = "wasm32"))]

#[cfg(feature = "chunkify")]
#[cfg(all(feature = "chunkify", not(target_arch = "wasm32")))]
use crate::chunkify::chunkify_endpoint;
use crate::{
common::Message,
Expand Down Expand Up @@ -258,7 +258,7 @@ impl RpcClient {
let len = message.arg.len();
let chunkify = {
cfg_if::cfg_if! {
if #[cfg(feature = "chunkify")] {
if #[cfg(all(feature = "chunkify", not(target_arch = "wasm32")))] {
crate::chunkify::needs_chunking(len)
} else {
false
Expand Down Expand Up @@ -287,7 +287,7 @@ impl RpcClient {
};
let nats_body = crate::common::serialize(&invocation)?;

#[cfg(feature = "chunkify")]
#[cfg(all(feature = "chunkify", not(target_arch = "wasm32")))]
if let Some(body) = body {
let inv_id = invocation.id.clone();
debug!("chunkifying inv {} size {}", &inv_id, len);
Expand Down Expand Up @@ -344,7 +344,7 @@ impl RpcClient {
match inv_response.error {
None => {
// was response chunked?
#[cfg(feature = "chunkify")]
#[cfg(all(feature = "chunkify", not(target_arch = "wasm32")))]
let msg = if inv_response.content_length.is_some()
&& inv_response.content_length.unwrap() > inv_response.msg.len() as u64
{
Expand Down Expand Up @@ -418,8 +418,6 @@ impl RpcClient {
// These two never get invoked
#[cfg(feature = "async_rewrite")]
NatsClientType::AsyncRewrite(_) => unimplemented!(),
//#[cfg(feature = "chunkify")]
//NatsClientType::Sync(_) => unimplemented!(),
}
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion rpc-rs/src/wasmbus_core.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated automatically using wasmcloud/weld-codegen 0.4.0
// This file is generated automatically using wasmcloud/weld-codegen 0.4.1

#[allow(unused_imports)]
use crate::{
Expand Down
2 changes: 1 addition & 1 deletion rpc-rs/src/wasmbus_model.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This file is generated automatically using wasmcloud/weld-codegen 0.4.0
// This file is generated automatically using wasmcloud/weld-codegen 0.4.1
#[allow(unused_imports)]
use crate::error::{RpcError, RpcResult};
#[allow(unused_imports)]
Expand Down

0 comments on commit 2c9abde

Please sign in to comment.