Skip to content

Commit

Permalink
update to async-nats with jetstream objectstore and new headers api (#…
Browse files Browse the repository at this point in the history
…120)

* update to async-nats with jetstream objectstore and new headers api

Signed-off-by: stevelr <steve@cosmonic.com>

* remove accidental '#'

Signed-off-by: stevelr <steve@cosmonic.com>

* update to async-nats 0.21.0

Signed-off-by: stevelr <steve@cosmonic.com>

* synk warning - bring tailwind up to date

Signed-off-by: stevelr <steve@cosmonic.com>

* (WIP) async-nats 0.21-0.22 changes

Signed-off-by: stevelr <steve@cosmonic.com>

* add json tags to go codegen; update dependencies; clippy; bump codegen to 0.5.1

Signed-off-by: stevelr <steve@cosmonic.com>

* misc clippy fixes

Signed-off-by: stevelr <steve@cosmonic.com>

* default config

Signed-off-by: stevelr <steve@cosmonic.com>

* bump to async-nats 0.22.0

Signed-off-by: stevelr <steve@cosmonic.com>

* cleanup prometheus conditional, remove unused function

Signed-off-by: stevelr <steve@cosmonic.com>

* use logging in tests instead of println

Signed-off-by: stevelr <steve@cosmonic.com>

* tinygo merge

Signed-off-by: stevelr <steve@cosmonic.com>

* pr feedback

Signed-off-by: stevelr <steve@cosmonic.com>

* rustfmt

Signed-off-by: stevelr <steve@cosmonic.com>

* update codegen mssrv to 1.60

Signed-off-by: stevelr <steve@cosmonic.com>

* misc cleanup; bump msrv to 1.64 due to async-nats requirement

Signed-off-by: stevelr <steve@cosmonic.com>

* bump macros msrv to 1.56.1

Signed-off-by: stevelr <steve@cosmonic.com>

* update changelog

Signed-off-by: stevelr <steve@cosmonic.com>

* change warning message to recommend upgrade to host v0.59.0

Signed-off-by: stevelr <steve@cosmonic.com>

* misc

Signed-off-by: stevelr <steve@cosmonic.com>

* bump to 0.6.0

Signed-off-by: stevelr <steve@cosmonic.com>

* pr feedback; fix span fields

Signed-off-by: stevelr <steve@cosmonic.com>

Signed-off-by: stevelr <steve@cosmonic.com>
  • Loading branch information
stevelr authored Nov 15, 2022
1 parent 5186be1 commit 6c766b2
Show file tree
Hide file tree
Showing 24 changed files with 281 additions and 316 deletions.
6 changes: 3 additions & 3 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "weld-codegen"
version = "0.5.0"
version = "0.6.0"
edition = "2021"
authors = [ "wasmcloud Team" ]
license = "Apache-2.0"
Expand All @@ -9,7 +9,7 @@ homepage = "https://github.com/wasmcloud/weld"
repository = "https://github.com/wasmcloud/weld"
documentation = "https://docs.rs/weld-codegen"
readme = "README.md"
rust-version = "1.57.0"
rust-version = "1.60.0"

[features]
default = [ "wasmbus" ]
Expand All @@ -26,7 +26,7 @@ atelier_json = "0.2"
atelier_smithy = "0.2"
bytes = "1.0"
cfg-if = "1.0"
clap = { version = "3.1", features = [ "derive" ] }
clap = { version = "4.0.22", features = [ "derive" ] }
directories = "4.0"
downloader = { version = "0.2", features = ["rustls-tls"], default-features = false }
handlebars = "4.0"
Expand Down
4 changes: 2 additions & 2 deletions codegen/bin/dump-smithy-model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use std::path::PathBuf;
use weld_codegen::{config::CodegenConfig, sources_to_model};

#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
#[command(author, version, about, long_about = None)]
struct Args {
/// codegen.toml file (default: "./codegen.toml")
#[clap(short, long)]
#[arg(short, long)]
config: Option<PathBuf>,
}

Expand Down
2 changes: 1 addition & 1 deletion codegen/bin/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() -> Result<()> {
}

fn load_config(path: &Path) -> Result<CodegenConfig> {
let cfile = std::fs::read_to_string(&path)
let cfile = std::fs::read_to_string(path)
.with_context(|| format!("reading config file at {}", &path.display()))?;
let folder = path.parent().unwrap().to_path_buf();
let folder = std::fs::canonicalize(folder)?;
Expand Down
16 changes: 10 additions & 6 deletions codegen/src/codegen_go.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use crate::{
gen::CodeGen,
model::{
get_operation, get_sorted_fields, get_trait, is_opt_namespace, value_to_json,
wasmcloud_core_namespace, wasmcloud_model_namespace, CommentKind, PackageName, Ty,
wasmcloud_actor_namespace, wasmcloud_core_namespace, wasmcloud_model_namespace,
CommentKind, PackageName, Ty,
},
render::Renderer,
writer::Writer,
Expand Down Expand Up @@ -83,6 +84,7 @@ impl fmt::Display for DecodeRef {
}
}

#[derive(Default)]
#[allow(dead_code)]
pub struct GoCodeGen<'model> {
/// if set, limits declaration output to this namespace only
Expand Down Expand Up @@ -345,13 +347,15 @@ impl<'model> CodeGen for GoCodeGen<'model> {
w,
r#"package {}
import (
{}
msgpack "github.com/wasmcloud/tinygo-msgpack" //nolint
cbor "github.com/wasmcloud/tinygo-cbor" //nolint
{}
)"#,
&self.package,
if ns != wasmcloud_model_namespace() && ns != wasmcloud_core_namespace() {
"\"github.com/wasmcloud/actor-tinygo\" //nolint"
if ns == wasmcloud_actor_namespace() {
"core \"github.com/wasmcloud/interfaces/core/tinygo\" //nolint"
} else if ns != wasmcloud_model_namespace() && ns != wasmcloud_core_namespace() {
"actor \"github.com/wasmcloud/actor-tinygo\" //nolint"
} else {
// avoid circular dependencies - core and model are part of the actor-tinygo package
""
Expand Down Expand Up @@ -784,9 +788,9 @@ impl<'model> GoCodeGen<'model> {
let (fields, _is_numbered) = get_sorted_fields(ident, strukt)?;
for member in fields.iter() {
self.apply_documentation_traits(w, member.id(), member.traits());
let (field_name, _ser_name) = self.get_field_name_and_ser_name(member)?;
let (field_name, ser_name) = self.get_field_name_and_ser_name(member)?;
let target = member.target();
let field_tags = "";
let field_tags = format!(r#"`json:"{}"`"#, ser_name);
writeln!(
w,
" {} {} {}",
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/codegen_py.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl<'model> CodeGen for PythonCodeGen<'model> {
}

fn source_formatter(&self, _: Vec<String>) -> Result<Box<dyn SourceFormatter>> {
Ok(Box::new(PythonSourceFormatter::default()))
Ok(Box::<PythonSourceFormatter>::default())
}

/// Perform any initialization required prior to code generation for a file
Expand Down
1 change: 1 addition & 0 deletions codegen/src/codegen_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct Declaration(u8, BytesMut);

type ShapeList<'model> = Vec<(&'model ShapeID, &'model AppliedTraits, &'model ShapeKind)>;

#[derive(Default)]
pub struct RustCodeGen<'model> {
/// if set, limits declaration output to this namespace only
pub(crate) namespace: Option<NamespaceID>,
Expand Down
5 changes: 3 additions & 2 deletions codegen/src/docgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::{

use atelier_core::model::Model;

use crate::format::NullFormatter;
use crate::{
config::{LanguageConfig, OutputFile, OutputLanguage},
error::Result,
Expand Down Expand Up @@ -74,7 +75,7 @@ impl CodeGen for DocGen {
.map(|id| id.to_string())
.collect::<BTreeSet<String>>();

std::fs::create_dir_all(&output_dir).map_err(|e| {
std::fs::create_dir_all(output_dir).map_err(|e| {
Error::Io(format!(
"creating directory {}: {}",
output_dir.display(),
Expand Down Expand Up @@ -126,6 +127,6 @@ impl CodeGen for DocGen {
name.into()
}
fn source_formatter(&self, _: Vec<String>) -> Result<Box<dyn SourceFormatter>> {
Ok(Box::new(crate::format::NullFormatter::default()))
Ok(Box::<NullFormatter>::default())
}
}
16 changes: 8 additions & 8 deletions codegen/src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ use atelier_core::model::{
HasIdentity as _, Identifier, Model,
};

use crate::docgen::DocGen;
use crate::{
codegen_go::GoCodeGen,
codegen_py::PythonCodeGen,
codegen_rust::RustCodeGen,
config::{CodegenConfig, LanguageConfig, OutputFile, OutputLanguage},
docgen::DocGen,
error::{Error, Result},
format::{NullFormatter, SourceFormatter},
model::{get_trait, serialization_trait, CommentKind, NumberedMember},
Expand Down Expand Up @@ -226,11 +226,11 @@ fn gen_for_language<'model>(
OutputLanguage::Python => Box::new(PythonCodeGen::new(model)),
OutputLanguage::TinyGo => Box::new(GoCodeGen::new(model, true)),
OutputLanguage::Go => Box::new(GoCodeGen::new(model, false)),
OutputLanguage::Html => Box::new(DocGen::default()),
OutputLanguage::Poly => Box::new(PolyGen::default()),
OutputLanguage::Html => Box::<DocGen>::default(),
OutputLanguage::Poly => Box::<PolyCodeGen>::default(),
_ => {
crate::error::print_warning(&format!("Target language {} not implemented", language));
Box::new(NoCodeGen::default())
Box::<NoCodeGen>::default()
}
}
}
Expand Down Expand Up @@ -494,8 +494,8 @@ fn ensure_files_exist(source_files: &[std::path::PathBuf]) -> Result<()> {
}

#[derive(Debug, Default)]
struct PolyGen {}
impl CodeGen for PolyGen {
struct PolyCodeGen {}
impl CodeGen for PolyCodeGen {
fn output_language(&self) -> OutputLanguage {
OutputLanguage::Poly
}
Expand All @@ -515,7 +515,7 @@ impl CodeGen for PolyGen {
}

fn source_formatter(&self, _: Vec<String>) -> Result<Box<dyn SourceFormatter>> {
Ok(Box::new(NullFormatter::default()))
Ok(Box::<NullFormatter>::default())
}
}

Expand Down Expand Up @@ -625,6 +625,6 @@ impl CodeGen for NoCodeGen {
}

fn source_formatter(&self, _: Vec<String>) -> Result<Box<dyn SourceFormatter>> {
Ok(Box::new(NullFormatter::default()))
Ok(Box::<NullFormatter>::default())
}
}
18 changes: 8 additions & 10 deletions codegen/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,16 +230,14 @@ fn urls_to_cached_files(urls: Vec<String>) -> Result<Vec<PathBuf>> {
Error::Other(format!("internal download error {}", e))
})?;
let cache_file = weld_cache.join(rel_path);
std::fs::create_dir_all(&cache_file.parent().unwrap()).map_err(
|e| {
Error::Io(format!(
"creating folder {}: {}",
&cache_file.parent().unwrap().display(),
e
))
},
)?;
std::fs::copy(&downloaded_file, &cache_file).map_err(|e| {
std::fs::create_dir_all(cache_file.parent().unwrap()).map_err(|e| {
Error::Io(format!(
"creating folder {}: {}",
&cache_file.parent().unwrap().display(),
e
))
})?;
std::fs::copy(downloaded_file, &cache_file).map_err(|e| {
Error::Other(format!(
"writing cache file {}: {}",
&cache_file.display(),
Expand Down
6 changes: 6 additions & 0 deletions codegen/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::{

const WASMCLOUD_MODEL_NAMESPACE: &str = "org.wasmcloud.model";
const WASMCLOUD_CORE_NAMESPACE: &str = "org.wasmcloud.core";
const WASMCLOUD_ACTOR_NAMESPACE: &str = "org.wasmcloud.actor";

const TRAIT_CODEGEN_RUST: &str = "codegenRust";
// If any of these are needed, they would have to be defined in core namespace
Expand All @@ -41,6 +42,8 @@ lazy_static! {
NamespaceID::new_unchecked(WASMCLOUD_MODEL_NAMESPACE);
static ref WASMCLOUD_CORE_NAMESPACE_ID: NamespaceID =
NamespaceID::new_unchecked(WASMCLOUD_CORE_NAMESPACE);
static ref WASMCLOUD_ACTOR_NAMESPACE_ID: NamespaceID =
NamespaceID::new_unchecked(WASMCLOUD_ACTOR_NAMESPACE);
static ref SERIALIZATION_TRAIT_ID: ShapeID = ShapeID::new(
NamespaceID::new_unchecked(WASMCLOUD_MODEL_NAMESPACE),
Identifier::from_str(TRAIT_SERIALIZATION).unwrap(),
Expand Down Expand Up @@ -81,6 +84,9 @@ pub fn wasmcloud_model_namespace() -> &'static NamespaceID {
pub fn wasmcloud_core_namespace() -> &'static NamespaceID {
&WASMCLOUD_CORE_NAMESPACE_ID
}
pub fn wasmcloud_actor_namespace() -> &'static NamespaceID {
&WASMCLOUD_ACTOR_NAMESPACE_ID
}

#[cfg(feature = "wasmbus")]
/// shape id of trait @wasmbus
Expand Down
8 changes: 4 additions & 4 deletions codegen/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ impl HelperDef for NamespaceHelper {
) -> Result<ScopedJson<'reg, 'rc>, RenderError> {
let namespace = arg_as_string(h, 0, "filter_namespace")?;
let namespace = NamespaceID::from_str(namespace)
.map_err(|e| RenderError::new(&format!("invalid namespace {}", e)))?;
.map_err(|e| RenderError::new(format!("invalid namespace {}", e)))?;
let obj = arg_as_obj(h, 1, "filter_namespace")?;

let shapes = obj
Expand Down Expand Up @@ -466,7 +466,7 @@ fn add_base_helpers(hb: &mut Handlebars) {
// get first arg as string
let id = arg_as_string(h, 0, "namespace")?;
let id = ShapeID::from_str(id).map_err(|e| {
RenderError::new(&format!("invalid shape id {} for namespace_name", e))
RenderError::new(format!("invalid shape id {} for namespace_name", e))
})?;
out.write(&id.namespace().to_string())?;
Ok(())
Expand Down Expand Up @@ -530,7 +530,7 @@ fn add_base_helpers(hb: &mut Handlebars) {
-> HelperResult {
let id = arg_as_string(h, 0, "shape_name")?;
let id = ShapeID::from_str(id).map_err(|e| {
RenderError::new(&format!("invalid shape id {} for shape_name", e))
RenderError::new(format!("invalid shape id {} for shape_name", e))
})?;
out.write(&id.shape_name().to_string())?;
Ok(())
Expand All @@ -552,7 +552,7 @@ fn add_base_helpers(hb: &mut Handlebars) {
-> HelperResult {
let id = arg_as_string(h, 0, "member_name")?;
let id = Identifier::from_str(id).map_err(|e| {
RenderError::new(&format!("invalid member id {} for member_name", e))
RenderError::new(format!("invalid member id {} for member_name", e))
})?;
out.write(&id.to_string())?;
Ok(())
Expand Down
1 change: 1 addition & 0 deletions macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ homepage = "https://github.com/wasmcloud/weld"
repository = "https://github.com/wasmcloud/weld"
documentation = "https://docs.rs/wasmcloud-weld-macros"
readme = "README.md"
rust-version = "1.56.1"

[lib]
proc-macro = true
Expand Down
8 changes: 8 additions & 0 deletions rpc-rs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# wasmbus-rpc Changelog

## 0.11.0-alpha.1

- upgrade to async-nats 0.22.0
- additional logging on reconnect
- add json tags to generated tinygo struct declarations
- bumped chunkify threshold to 900KiB \(900\*1024\) to match host threshold


## 0.10.0

- upgrade to async-nats 0.18.0
Expand Down
38 changes: 18 additions & 20 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.11.0"
version = "0.11.0-alpha.1"
authors = [ "wasmcloud Team" ]
license = "Apache-2.0"
description = "Runtime library for actors and capability providers"
Expand All @@ -10,7 +10,7 @@ documentation = "https://docs.rs/wasmbus-rpc"
readme = "README.md"
edition = "2021"
# MSRV
rust-version = "1.58.1"
rust-version = "1.64"

# don't push build.rs
exclude = [ "build.rs" ]
Expand All @@ -23,7 +23,6 @@ metrics = [ "prometheus" ]
otel = ["opentelemetry", "tracing-opentelemetry", "opentelemetry-otlp"]

[dependencies]
anyhow = "1.0.57"
async-trait = "0.1"
base64 = "0.13"
bytes = "1.1.0"
Expand All @@ -34,8 +33,7 @@ serde_bytes = "0.11"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
thiserror = "1.0"
time = "0.3.13"
tokio-timer = "0.2"
time = "0.3.16"
toml = "0.5"
tracing = { version = "0.1.34", features = ["log"] }
tracing-futures = "0.2"
Expand All @@ -48,28 +46,28 @@ num-bigint = { version = "0.4", optional = true }
bigdecimal = { version = "0.3", optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1", features = ["full"] }
async-nats = "0.22.0"
atty = "0.2"
data-encoding = "2.3"
futures = "0.3"
async-nats = "0.19.0"
nats = "0.23.0"
lazy_static = "1.4"
nkeys = "0.2"
once_cell = "1.8"
uuid = { version = "1.0", features = ["v4", "serde"] }
wascap = "0.8.0"
opentelemetry = { version = "0.18", features = ["rt-tokio"], optional = true }
opentelemetry-otlp = { version = "0.11", features = ["http-proto", "reqwest-client"], optional = true }
prometheus = { version = "0.13", optional = true }
sha2 = "0.10.2"
data-encoding = "2.3"
tokio = { version = "1", features = ["full"] }
tracing-opentelemetry = { version = "0.18", optional = true }
tracing-subscriber = { version = "0.3.7", features = ["env-filter", "json"] }
atty = "0.2"
opentelemetry = { version = "0.17", features = ["rt-tokio"], optional = true }
tracing-opentelemetry = { version = "0.17", optional = true }
lazy_static = "1.4"
opentelemetry-otlp = { version = "0.10", features = ["http-proto", "reqwest-client"], optional = true }

prometheus = { version = "0.13", optional = true }
uuid = { version = "1.0", features = ["v4", "serde"] }
wascap = "0.8.0"

[dev-dependencies]
anyhow = "1.0.66"
regex = "1"
clap = { version = "4.0.20", features = ["derive"] }
clap = { version = "4.0.22", features = ["derive"] }
test-log = { version = "0.2.10", default-features = false, features = ["trace"] }

[build-dependencies]
weld-codegen = { version = "0.5.0", path = "../codegen" }
weld-codegen = { version = "0.6.0", path = "../codegen" }
2 changes: 1 addition & 1 deletion rpc-rs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test::
docker stop wasmbus-rpc-test
else
test::
cargo test -- --nocapture
WASMBUS_RPC_TIMEOUT_MS=4000 cargo test -- --nocapture
cargo clippy --all-features --all-targets
rustfmt --edition 2021 --check src/*.rs
endif
Expand Down
Loading

0 comments on commit 6c766b2

Please sign in to comment.