Skip to content

Commit

Permalink
extract orderstatusprovider (#31)
Browse files Browse the repository at this point in the history
* extract orderstatusprovider

* Update PR.yaml (#32)

cleaning up disk space and removed orphaned resources, images and folders

* updated/removed verification steps
  • Loading branch information
bindsi authored Nov 8, 2023
1 parent 6964b0b commit 918a652
Show file tree
Hide file tree
Showing 26 changed files with 170 additions and 494 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/PR.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
# export of cargo path in each step is required because it is not when exported in bootstraph.sh script
- name: install cluster and workloads
run: |
docker exec devcontainer sh -c "export PATH="/root/.cargo/bin:$PATH" && cd ./workspace && make fmt && make"
docker exec devcontainer sh -c "export PATH="/root/.cargo/bin:$PATH" && cd ./workspace && make fmt && make"
99 changes: 43 additions & 56 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[workspace]
# If more Spin apps are added to the solution, they should be referenced here.
members = [
"apps/mqtt/orderprocessor/receiver",
"apps/mqtt/orderprocessor/statusprovider",
"apps/mqtt/orderprocessor",
"apps/mqtt/fulfilmentprocessor",
"apps/redis/orderprocessor/receiver",
"apps/redis/orderprocessor/statusprovider",
"apps/redis/orderprocessor",
"apps/redis/fulfilmentprocessor",
"crates/order-management"
"apps/shared/orderstatusprovider",
"crates/order-management",
]
resolver = "2"
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#! /bin/bash
K3DCLUSTERNAME := wasm-cluster
K3DSHIMIMAGENAME := ghcr.io/deislabs/containerd-wasm-shims/examples/k3d:v0.9.1
DOCKERDIR := ./wasm-shims/deployments/k3d
Expand Down Expand Up @@ -38,7 +39,8 @@ install_mosquitto:
@echo "Installing mosquito..."
helm upgrade --install mosquitto ./deployment/mosquitto --namespace mosquitto --create-namespace --wait

deploy_app: deploy_app_orderprocessor deploy_app_fulfilmentprocessor
deploy_app: deploy_app_orderprocessor deploy_app_fulfilmentprocessor deploy_app_orderstatusprovider
rm -r target

deploy_app_orderprocessor:
@echo "Deploying order processor app..."
Expand All @@ -48,6 +50,10 @@ deploy_app_fulfilmentprocessor:
@echo "Deploying fulfilment processor app..."
sh ./deployment/build-deploy-workload.sh fulfilmentprocessor $(K3DCLUSTERNAME) $(APPSDIR)

deploy_app_orderstatusprovider:
@echo "Deploying orderstatusprovider processor app..."
sh ./deployment/build-deploy-workload.sh orderstatusprovider $(K3DCLUSTERNAME) ./apps/shared

run_integrationtest:
@echo "Running integration test..."
RUST_BACKTRACE=full cargo test --manifest-path ./tests/Cargo.toml --package integrationtest --lib -- create_order_test --exact --nocapture
Expand All @@ -67,6 +73,7 @@ build_push_app_images:
sh ./deployment/build-push-workload-image.sh fulfilmentprocessor-mqtt ./apps/mqtt $(GITHUBORG) $(GITHUBREPO)
sh ./deployment/build-push-workload-image.sh orderprocessor-redis ./apps/redis $(GITHUBORG) $(GITHUBREPO)
sh ./deployment/build-push-workload-image.sh fulfilmentprocessor-redis ./apps/redis $(GITHUBORG) $(GITHUBREPO)
sh ./deployment/build-push-workload-image.sh orderstatusprovider ./apps/shared $(GITHUBORG) $(GITHUBREPO)

clean:
@echo "Cleaning up..."
Expand All @@ -76,8 +83,10 @@ clean:
rm -rf ./apps/mqtt/orderprocessor/.spin
rm -rf ./apps/mqtt/fulfilmentprocessor/target
rm -rf ./apps/mqtt/fulfilmentprocessor/.spin
rm -rf ./apps/redis/orderprocessor/target
rm -rf ./apps/redis/orderprocessor/.spin
rm -rf ./apps/redis/fulfilmentprocessor/target
rm -rf ./apps/redis/fulfilmentprocessor/.spin
rm -rf ./apps/redis/orderprocessor/target
rm -rf ./apps/redis/orderprocessor/.spin
rm -rf ./apps/shared/orderstatusprovider/target
rm -rf ./apps/shared/orderstatusprovider/.spin
rm -rf ./tests/target
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "receiver-mqtt"
name = "orderprocessor-mqtt"
authors = ["Suneet Nangia <[email protected]>"]
description = "Order receiver component in Spin application"
version = "0.1.0"
Expand All @@ -26,4 +26,4 @@ spin-sdk = { git = "https://github.com/suneetnangia/spin", branch = "feature/mqt
# Crate that generates Rust Wasm bindings from a WebAssembly interface.
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "cb871cfa1ee460b51eb1d144b175b9aab9c50aba" }
# Crate that contains shared order management entities.
order-management = { path = "../../../../crates/order-management" }
order-management = { path = "../../../crates/order-management" }
3 changes: 1 addition & 2 deletions apps/mqtt/orderprocessor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ COPY . .
FROM scratch
COPY --from=build /workspaces/wasm-orchestration-with-spin/apps/mqtt/orderprocessor/spin.toml .
# Copy wasm components which are required to run the application
COPY --from=build /workspaces/wasm-orchestration-with-spin/apps/mqtt/orderprocessor/target/wasm32-wasi/release/receiver_mqtt.wasm ./target/wasm32-wasi/release/receiver_mqtt.wasm
COPY --from=build /workspaces/wasm-orchestration-with-spin/apps/mqtt/orderprocessor/target/wasm32-wasi/release/statusprovider_mqtt.wasm ./target/wasm32-wasi/release/statusprovider_mqtt.wasm
COPY --from=build /workspaces/wasm-orchestration-with-spin/apps/mqtt/orderprocessor/target/wasm32-wasi/release/orderprocessor_mqtt.wasm ./target/wasm32-wasi/release/orderprocessor_mqtt.wasm
17 changes: 3 additions & 14 deletions apps/mqtt/orderprocessor/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,12 @@ trigger = { type = "http", base = "/order" }
version = "0.7.1"

[[component]]
id = "receiver"
source = "./target/wasm32-wasi/release/receiver_mqtt.wasm"
id = "orderprocessor"
source = "./target/wasm32-wasi/release/orderprocessor_mqtt.wasm"
# Ip address is statically configured in redis service yaml
environment = { REDIS_ADDRESS = "redis://10.43.236.144:6379", MQTT_ADDRESS = "mqtt://10.43.236.145:1883", MQTT_TOPIC = "neworders" }
allowed_http_hosts = []
[component.trigger]
route = "/"
[component.build]
command = "cargo build --target wasm32-wasi --release"

[[component]]
id = "statusprovider"
source = "./target/wasm32-wasi/release/statusprovider_mqtt.wasm"
# Ip address is statically configured in redis service yaml
environment = { REDIS_ADDRESS = "redis://10.43.236.144:6379" }
allowed_http_hosts = []
[component.trigger]
route = "/..."
[component.build]
command = "cargo build --target wasm32-wasi --release"
command = "cargo build --target wasm32-wasi --release"
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ fn handle_receiver(req: Request) -> Result<Response> {

fn generate_http_accept_response(order_id: u32) -> OrderAccepted {
let task = HttpAcceptTask {
href: format!("/order/{}", order_id),
href: format!("/orderstatus/{}", order_id),
id: order_id,
status: "created".to_string(),
};
Expand Down
25 changes: 0 additions & 25 deletions apps/mqtt/orderprocessor/statusprovider/Cargo.toml

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "receiver-redis"
name = "orderprocessor-redis"
authors = ["Suneet Nangia <[email protected]>"]
description = "Order receiver component in Spin application"
version = "0.1.0"
Expand All @@ -26,4 +26,4 @@ spin-sdk = { git = "https://github.com/fermyon/spin", tag = "v1.0.0" }
# Crate that generates Rust Wasm bindings from a WebAssembly interface.
wit-bindgen-rust = { git = "https://github.com/bytecodealliance/wit-bindgen", rev = "cb871cfa1ee460b51eb1d144b175b9aab9c50aba" }
# Crate that contains shared order management entities.
order-management = { path = "../../../../crates/order-management" }
order-management = { path = "../../../crates/order-management" }
3 changes: 1 addition & 2 deletions apps/redis/orderprocessor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ COPY . .
FROM scratch
COPY --from=build /workspaces/wasm-orchestration-with-spin/apps/redis/orderprocessor/spin.toml .
# Copy wasm components which are required to run the application
COPY --from=build /workspaces/wasm-orchestration-with-spin/apps/redis/orderprocessor/target/wasm32-wasi/release/receiver_redis.wasm ./target/wasm32-wasi/release/receiver_redis.wasm
COPY --from=build /workspaces/wasm-orchestration-with-spin/apps/redis/orderprocessor/target/wasm32-wasi/release/statusprovider_redis.wasm ./target/wasm32-wasi/release/statusprovider_redis.wasm
COPY --from=build /workspaces/wasm-orchestration-with-spin/apps/redis/orderprocessor/target/wasm32-wasi/release/orderprocessor_redis.wasm ./target/wasm32-wasi/release/orderprocessor_redis.wasm
17 changes: 3 additions & 14 deletions apps/redis/orderprocessor/spin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,12 @@ trigger = { type = "http", base = "/order" }
version = "0.7.1"

[[component]]
id = "receiver"
source = "./target/wasm32-wasi/release/receiver_redis.wasm"
id = "orderprocessor"
source = "./target/wasm32-wasi/release/orderprocessor_redis.wasm"
# Ip address is statically configured in redis service yaml
environment = { REDIS_ADDRESS = "redis://10.43.236.144:6379", REDIS_CHANNEL = "neworders" }
allowed_http_hosts = []
[component.trigger]
route = "/"
[component.build]
command = "cargo build --target wasm32-wasi --release"

[[component]]
id = "statusprovider"
source = "./target/wasm32-wasi/release/statusprovider_redis.wasm"
# Ip address is statically configured in redis service yaml
environment = { REDIS_ADDRESS = "redis://10.43.236.144:6379" }
allowed_http_hosts = []
[component.trigger]
route = "/..."
[component.build]
command = "cargo build --target wasm32-wasi --release"
command = "cargo build --target wasm32-wasi --release"
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn handle_receiver(req: Request) -> Result<Response> {

fn generate_http_accept_response(order_id: u32) -> OrderAccepted {
let task = HttpAcceptTask {
href: format!("/order/{}", order_id),
href: format!("/orderstatus/{}", order_id),
id: order_id,
status: "created".to_string(),
};
Expand Down
Loading

0 comments on commit 918a652

Please sign in to comment.