Skip to content

Commit

Permalink
replace nats-aflowt with async-nats (#98)
Browse files Browse the repository at this point in the history
* replace nats-aflowt with async-nats

Signed-off-by: Steve <[email protected]>

* enable request with timeout

Signed-off-by: Steve <[email protected]>

* 'make test' runs against local docker instance

Signed-off-by: Steve <[email protected]>

* test against docker nats server

Signed-off-by: Steve <[email protected]>

* add 'gen' makefile target

Signed-off-by: Steve <[email protected]>

* use makefile tests in workflows

Signed-off-by: Steve <[email protected]>

* rust-check makefile target

Signed-off-by: Steve <[email protected]>

* rust-check makefile target

Signed-off-by: Steve <[email protected]>

* use macro for common subscriber code

Signed-off-by: Steve <[email protected]>

* add namespace header to generated files; update dependencies; bump weld-codegen to 0.4.4

Signed-off-by: stevelr <[email protected]>

* WIP: async-nats support, upgrade dependencies

Signed-off-by: stevelr <[email protected]>

* merge rpc timeout fix from main

Signed-off-by: stevelr <[email protected]>

* add golang code generator, some minor refactoring

Signed-off-by: stevelr <[email protected]>

* comment-out debug logging

Signed-off-by: stevelr <[email protected]>

* combine writes for better readability. fix casename of struct fields

Signed-off-by: stevelr <[email protected]>

* fix field case

Signed-off-by: stevelr <[email protected]>

* complete first impl tinygo codegen

Signed-off-by: stevelr <[email protected]>

* sync with async-nats

Signed-off-by: stevelr <[email protected]>

* add rustfmt config

Signed-off-by: stevelr <[email protected]>

* use current wasmbus-core/model smithy

Signed-off-by: stevelr <[email protected]>

* fix rustfmt in rust stable

Signed-off-by: stevelr <[email protected]>

* fix rustfmt in rust stable

Signed-off-by: stevelr <[email protected]>

* fix rustfmt in rust stable

Signed-off-by: stevelr <[email protected]>

* refactor subscribe_rpc into rpc_client, partial tracing support

Signed-off-by: stevelr <[email protected]>

* refactor subscribe_rpc into rpc_client, partial tracing support
(still WIP: checkpoint before merging otel)

Signed-off-by: stevelr <[email protected]>

* remove anats

Signed-off-by: stevelr <[email protected]>

* avoid warning on key field in HostBridge

Signed-off-by: stevelr <[email protected]>

* Upgraded async-nats to 0.15.0.
Exported functions for initializing tracing with or without otel.

Signed-off-by: stevelr <[email protected]>

* add some cli examples

Signed-off-by: stevelr <[email protected]>

* uncomment cbor include

Signed-off-by: stevelr <[email protected]>

* wasm32 fix: don't reference tracing in provider library

Signed-off-by: stevelr <[email protected]>

* add logging for connection events

Signed-off-by: stevelr <[email protected]>

* change structured_logging_enabled to structured_logging

Signed-off-by: stevelr <[email protected]>

* remove unused code

Signed-off-by: stevelr <[email protected]>

* make comment about provider_main more verbose

Signed-off-by: stevelr <[email protected]>

* bump version to 0.9.0-alpha.1.1; default features does _not_ include otel

Signed-off-by: stevelr <[email protected]>

* add comment about otel tracing

Signed-off-by: stevelr <[email protected]>

* fix copy/paste error

Signed-off-by: stevelr <[email protected]>

* remove dead code; tidy up imports; log count when exiting listener

Signed-off-by: stevelr <[email protected]>

* add tokio-spawn around provider dispatch

Signed-off-by: stevelr <[email protected]>

* made spawn surround the entire rpc handler

Signed-off-by: stevelr <[email protected]>

* Helping Steve finish up some things

Signed-off-by: Taylor Thomas <[email protected]>

Co-authored-by: Taylor Thomas <[email protected]>
  • Loading branch information
stevelr and thomastaylor312 authored Jul 6, 2022
1 parent 6621944 commit 53b906f
Show file tree
Hide file tree
Showing 31 changed files with 1,411 additions and 1,165 deletions.
53 changes: 26 additions & 27 deletions .github/workflows/codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: CODEGEN

on:
push:
branches: [ main ]
branches: [main]
paths:
- "codegen/**"
- "codegen/**"
tags:
- 'weld-codegen-v*'
- "weld-codegen-v*"
pull_request:
branches: [ main ]
branches: [main]
paths:
- "codegen/**"
- "codegen/**"

env:
CARGO_TERM_COLOR: always
Expand All @@ -20,34 +20,33 @@ jobs:
rust_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: update_rust
run: |
rustup toolchain install nightly
rustup update stable nightly
rustup component add --toolchain nightly rustfmt clippy
rustup default nightly
- name: run_all_tests_clippy_fmt
run: |
cd ${{ env.working-directory }}
cargo clippy --all-targets --all-features
rustfmt --check src/*.rs
- uses: actions/checkout@v2
- name: Update rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: run_all_tests_clippy_fmt
run: |
cd ${{ env.working-directory }}
make test
make rust-check
github_release:
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
needs: rust_test
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: true
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: true

crates_release:
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
Expand Down
48 changes: 27 additions & 21 deletions .github/workflows/macros.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,51 @@ name: MACROS

on:
push:
branches: [ main ]
branches: [main]
paths:
- "macros/**"
- "macros/**"
tags:
- 'wasmbus-macros-v*'
- "wasmbus-macros-v*"
pull_request:
branches: [ main ]
branches: [main]
paths:
- "macros/**"
- "macros/**"

env:
CARGO_TERM_COLOR: always
working-directory: ./macros

jobs:
rust_check:
rust_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- id: rust-check-action
uses: wasmcloud/common-actions/rust-check@main
with:
- uses: actions/checkout@v2
- name: Update rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: run_all_tests_clippy_fmt
working-directory: ${{ env.working-directory }}
run: |
make test
make rust-check
github_release:
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
needs: rust_check
needs: rust_test
runs-on: ubuntu-latest
steps:
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: true
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: true

crates_release:
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/wasmbus-rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: update_rust
run: |
rustup update
- name: Update rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
- name: run_all_tests_clippy_fmt
run: |
cd ${{ env.working-directory }}
make test
working-directory: ${{ env.working-directory }}
run: make test

github_release:
if: startswith(github.ref, 'refs/tags/') # Only run on tag push
Expand Down
2 changes: 0 additions & 2 deletions Cargo.toml

This file was deleted.

35 changes: 18 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
# weld top-level Makefile
# wasmcloud/weld top-level Makefile
#
# Makefiles in this repository assume you have GNU Make (version 4.x)
# If you're on mac, `brew install make`
# and ensure `/usr/local/opt/make/libexec/gnubin` is in your PATH before /usr/bin

subdirs = codegen macros rpc-rs

MODEL_OUTPUT := codegen/src/wasmbus_model.rs rpc-rs/src/wasmbus_model.rs
#MODEL_SRC := examples/interface/wasmbus-core/wasmcloud-model.smithy \
# examples/interface/wasmbus-core/codegen.toml
#WELD := target/debug/weld

all: build

build clean:
cargo $@
all build release clean test update lint validate rust-check::
for dir in $(subdirs); do \
$(MAKE) -C $$dir $@ ; \
done

test:
# run clippy on all features and tests, and fail on warnings
cargo clippy --all-targets --all-features -- -D warnings
cargo test

release:
cargo build --release
test::
$(MAKE) check-model

check-model: $(MODEL_OUTPUT)
@diff $(MODEL_OUTPUT) || (echo ERROR: Model files differ && exit 1)

WELD_SRC := bin/Cargo.toml bin/src/*.rs codegen/Cargo.toml codegen/templates/*.toml \
codegen/templates/*.hbs codegen/templates/rust/*.hbs
target/debug/weld: $(WELD_SRC)
cargo build --package weld-bin
gen:
$(MAKE) -C codegen release
(cd codegen && target/release/codegen)
(cd rpc-rs && ../codegen/target/release/codegen)

#WELD_SRC := bin/Cargo.toml bin/src/*.rs codegen/Cargo.toml codegen/templates/*.toml \
# codegen/templates/*.hbs codegen/templates/rust/*.hbs
#target/debug/weld: $(WELD_SRC)
# cargo build --package weld-bin

.PHONY: all build release clean test check-model
.NOTPARALLEL:
2 changes: 1 addition & 1 deletion codegen/src/codegen_rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl<'model> CodeGen for RustCodeGen<'model> {
r#"
#[allow(unused_imports)]
use {}::{{
//cbor::*,
cbor::*,
common::{{
Context, deserialize, Message, MessageFormat, message_format,
MessageDispatch, SendOpts, serialize, Transport,
Expand Down
18 changes: 18 additions & 0 deletions macros/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# weld/macros/Makefile

all: build

build clean update:
cargo $@

release:
cargo build --release

test::
cargo test --all-features --all-targets -- --nocapture

rust-check::
cargo clippy --all-features --all-targets
rustfmt --edition 2021 --check src/*.rs

.PHONY: all build release clean lint validate test update rust-check
4 changes: 1 addition & 3 deletions macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ impl syn::parse::Parse for ReceiverDef {
fn parse(input: syn::parse::ParseStream) -> ParseResult<Self> {
let derive_input: syn::DeriveInput = input.parse()?;
let attrs_span = derive_input.span();
let syn::DeriveInput {
attrs, ident, data, ..
} = derive_input;
let syn::DeriveInput { attrs, ident, data, .. } = derive_input;
let ident_span = ident.span();
let fields = match data {
syn::Data::Struct(data) => data.fields,
Expand Down
37 changes: 36 additions & 1 deletion rpc-rs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
# wasmbus-rpc Changelog

## BREAKING CHANGES from 0.8.x to 0.9.0

- provider_main has a new parameter: friendly_name, which is displayed on OTEL tracing dashboards.
Instead of `provider_main(MyAwesomeProvider::default())`, use:
`provider_main(MyAwesomeProvider::default(), Some("My Awesome Provider".to_string()))`

- nats-aflowt is replaced with async-nats!
- removed 'wasmbus_rpc::anats'
- anats::ServerAddress renamed to async_nats::ServerAddr
- anats::Subscription is not public, replaced with async_nats::Subscriber
- anats::Subscription.close() replaced with async_nats::Subscriber.unsubscribe()
- anats::Options renamed to async_nats::ConnectOptions
- anats::Connection is no longer public. Use async_nats::Client instead.
- anats::Message.data renamed to async_nats::Message.payload
- HostBridge::new() changes
- first parameter is async_nats::Client instead of anats::Connection
- RpcClient::new() changes
- new() parameter takes async_nats Client instead of anats::Client
- lattice prefix removed from constructor, added in to some of the method parameters
- got rid of enum NatsClientType, replaced with async_nats::Client
- removed feature "chunkify" (it is always enabled for non-wasm32 targets)

- RpcError does not implement Serialize, Deserialize, or PartialEq
(unless/until we can find a good reason to support these)


## non-breaking changes
- new feature flag "otel" enables OpenTelemetry tracing spans
- set environment variable `OTEL_TRACES_EXPORTER` to "otlp"
- set environment variable `OTEL_EXPORTER_OTLP_ENDPOINT` to the desired collector. Defaults to "http://127.0.0.1:55681/v1/traces"
- ("/v1/traces" will always be appended to this setting if it doesn't already end with "/v1/traces")
- dependencies (minicbor, uuid, and others)
- replaced ring with sha2 for sha256


## 0.7.0

### Breaking changes (since 0.6.x)

- Some of the crate exported symbols have moved to sub-modules. The intent is to resolve some linking problems
- Some of the crate's exported symbols have moved to submodules. The intent is to resolve some linking problems
resulting from multiple inconsistent references to these symbols.
Most of these changes will require only a recompile, for Actors and Providers
that import `wasmbus_rpc::actor::prelude::*` or `wasmbus_rpc::provider::prelude::*`, respectively.
Expand Down
32 changes: 17 additions & 15 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.5"
version = "0.9.0-alpha.1.1"
authors = [ "wasmcloud Team" ]
license = "Apache-2.0"
description = "Runtime library for actors and capability providers"
Expand All @@ -14,20 +14,20 @@ edition = "2021"
exclude = [ "build.rs" ]

[features]
default = [ "chunkify" ]
default = [ ]
BigInteger = [ "num-bigint" ]
BigDecimal = [ "bigdecimal" ]
# non-working feature - used for internal testing of async-rewrite branch of nats-io/nats.rs
#async_rewrite = [ "nats-experimental" ]
chunkify = [ "nats" ]
otel = ["opentelemetry", "tracing-opentelemetry", "nats", "opentelemetry-otlp"]
prometheus = [ "dep:prometheus" ]
otel = ["opentelemetry", "tracing-opentelemetry", "opentelemetry-otlp"]

[dependencies]
anyhow = "1.0.57"
async-trait = "0.1"
base64 = "0.13"
bytes = "1.1.0"
cfg-if = "1.0"
minicbor = { version = "0.13", features = ["std", "partial-skip-support"] }
rmp-serde = { version = "0.15.4" }
minicbor = { version = "0.17.1", features = ["std"] }
rmp-serde = "1.1.0"
serde_bytes = "0.11"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
Expand All @@ -40,21 +40,21 @@ tracing-futures = "0.2"
wasmbus-macros = { path = "../macros", version = "0.1.8" }
minicbor-ser = "0.1.2"

#BigInteger support
# BigInteger support
num-bigint = { version = "0.4", optional = true }
#BigDecimal support
# BigDecimal support
bigdecimal = { version = "0.3", optional = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1", features = ["full"] }
futures = "0.3"
nats-aflowt = "0.16.104"
nats = { version = "0.20", optional = true }
async-nats = "0.15.0"
nats = "0.20.1"
nkeys = "0.2"
once_cell = "1.8"
uuid = { version = "0.8", features = ["v4", "serde"] }
uuid = { version = "1.0", features = ["v4", "serde"] }
wascap = "0.8.0"
ring = "0.16"
sha2 = "0.10.2"
data-encoding = "2.3"
tracing-subscriber = { version = "0.3.7", features = ["env-filter", "json"] }
atty = "0.2"
Expand All @@ -63,9 +63,11 @@ 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 }

[dev-dependencies]
regex = "1"
env_logger = "0.9.0"
clap = { version = "3.2.5", features = ["derive"] }

[build-dependencies]
weld-codegen = { version = "0.4.3", path = "../codegen" }
Loading

0 comments on commit 53b906f

Please sign in to comment.