diff --git a/.cargo/config b/.cargo/config index 1d6d3f82..34416d5a 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,5 +1,5 @@ [env] -DEFAULT_CHARIOTT_URL = "http://0.0.0.0:4243" +DEFAULT_INTENT_BROKER_URL = "http://0.0.0.0:4243" [target.'cfg(all())'] rustflags = ["-D", "warnings"] diff --git a/.github/workflows/containerize.yaml b/.github/workflows/containerize.yaml index 1a3bbb35..b195c703 100644 --- a/.github/workflows/containerize.yaml +++ b/.github/workflows/containerize.yaml @@ -1,6 +1,6 @@ name: Containerize and Push to Container Registry -# Containerizes and pushes a build of the Chariott to a container registry. +# Containerizes and pushes a build of Chariott Intent Brokering to a container registry. # # To use this in your own clone of this repo, you need to configure three Github Action secrets: # 1. CONTAINER_REGISTRY_ENDPOINT: The DNS endpoint of your container registry (eg. sdv.azurecr.io) diff --git a/.github/workflows/e2e-ci.yml b/.github/workflows/e2e-ci.yml index 92144811..1fabd772 100644 --- a/.github/workflows/e2e-ci.yml +++ b/.github/workflows/e2e-ci.yml @@ -24,7 +24,7 @@ concurrency: env: CARGO_TERM_COLOR: always - CHARIOTT_REGISTRY_TTL_SECS: 7 + INTENT_BROKERING_REGISTRY_TTL_SECS: 7 jobs: e2e: @@ -46,13 +46,13 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Build Chariott Container + - name: Build Intent Brokering service Container uses: docker/build-push-action@v3 with: context: . file: ./Dockerfile.intent_brokering load: true - tags: chariott:1 + tags: intent_brokering:1 - name: Build KV-App Container uses: docker/build-push-action@v3 @@ -63,12 +63,12 @@ jobs: load: true tags: kv-app:1 - - name: Start Chariott + - name: Start Intent Brokering run: | - docker run -d --name chariott --network host \ + docker run -d --name intent_brokering --network host \ -e RUST_LOG=debug \ - -e CHARIOTT_REGISTRY_TTL_SECS \ - chariott:1 + -e INTENT_BROKERING_REGISTRY_TTL_SECS \ + intent_brokering:1 - name: Start KV-App run: | @@ -78,17 +78,17 @@ jobs: run: | cargo test --test "*e2e" - - name: Print Chariott log output + - name: Print Intent Brokering log output if: ${{ always() }} run: | - docker logs chariott > chariott.log - docker logs chariott + docker logs intent_brokering > intent_brokering.log + docker logs intent_brokering - - name: Archive Chariott log output + - name: Archive Intent Brokering log output uses: actions/upload-artifact@v1 with: - name: Chariott E2E log - path: chariott.log + name: Intent Brokering E2E log + path: intent_brokering.log - name: Print KV App log output if: ${{ always() }} diff --git a/.github/workflows/lt-ci.yml b/.github/workflows/lt-ci.yml index 80b92560..2f17f722 100644 --- a/.github/workflows/lt-ci.yml +++ b/.github/workflows/lt-ci.yml @@ -53,21 +53,21 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Build chariott container + - name: Build intent brokering container uses: docker/build-push-action@v3 with: context: . file: Dockerfile.intent_brokering load: true - tags: chariott:1 + tags: intent_brokering:1 - - name: Build valgrind enabled chariott container + - name: Build valgrind enabled intent brokering container uses: docker/build-push-action@v3 with: context: . file: ./Dockerfile.intent_brokering.valgrind load: true - tags: val-chariott:1 + tags: intent_brokering.valgrind:1 - name: Build lt-provider-app container uses: docker/build-push-action@v3 @@ -78,9 +78,9 @@ jobs: load: true tags: lt-provider-app:1 - - name: Start chariott and lt-provider-app + - name: Start intent_brokering and lt-provider-app run: | - docker run --init --detach --name chariott --network host chariott:1 + docker run --init --detach --name intent_brokering --network host intent_brokering:1 docker run --init --detach --name lt-provider-app --network host lt-provider-app:1 - name: Run load tests @@ -92,9 +92,9 @@ jobs: - name: Stop containers run: | docker kill --signal=SIGINT lt-provider-app - docker kill --signal=SIGINT chariott + docker kill --signal=SIGINT intent_brokering docker stop lt-provider-app - docker stop chariott + docker stop intent_brokering - name: Print performance numbers run: | @@ -107,21 +107,21 @@ jobs: - name: Print log output if: ${{ always() }} run: | - docker logs chariott + docker logs intent_brokering docker logs lt-provider-app for f in lt-output/*.log; do echo -e "Printing output of file $f:\n" cat "$f"; done - - name: Start chariott and lt-provider-app + - name: Start intent_brokering and lt-provider-app run: | docker rm lt-provider-app - docker rm chariott + docker rm intent_brokering mkdir -p valgrind-output sudo chown -R 10001:10001 valgrind-output sudo chmod -R 777 valgrind-output - docker run --init --detach --name val-chariott --network host --volume $(pwd)/valgrind-output:/output val-chariott:1 + docker run --init --detach --name intent_brokering.valgrind --network host --volume $(pwd)/valgrind-output:/output intent_brokering.valgrind:1 docker run --init --detach --name lt-provider-app --network host lt-provider-app:1 - name: Run Memory Profiling using load tests @@ -134,9 +134,9 @@ jobs: - name: Stop containers run: | docker kill --signal=SIGINT lt-provider-app - docker kill --signal=SIGINT val-chariott + docker kill --signal=SIGINT intent_brokering.valgrind docker stop lt-provider-app - docker stop val-chariott + docker stop intent_brokering.valgrind - name: Create valgrind benchmark report run: | @@ -167,7 +167,7 @@ jobs: uses: benchmark-action/github-action-benchmark@v1 if: ${{ github.event_name != 'workflow_dispatch' }} with: - name: Chariott Benchmark + name: Intent Brokering Benchmark tool: 'customSmallerIsBetter' output-file-path: lt-output/all.json github-token: ${{ secrets.GITHUB_TOKEN }} @@ -181,7 +181,7 @@ jobs: - name: Print log output if: ${{ always() }} run: | - docker logs val-chariott + docker logs intent_brokering.valgrind docker logs lt-provider-app for f in lt-output/*.log; do echo -e "Printing output of file $f:\n" diff --git a/Cargo.lock b/Cargo.lock index fcb82535..07bd8496 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -504,60 +504,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chariott" -version = "0.1.0" -dependencies = [ - "anyhow", - "async-recursion", - "async-trait", - "chariott-common", - "chariott-proto", - "examples-common", - "futures", - "prost", - "prost-types", - "test-case", - "tokio", - "tokio-stream", - "tokio-util", - "tonic", - "tonic-build", - "tonic-reflection", - "tracing", - "tracing-subscriber", - "url", - "uuid", -] - -[[package]] -name = "chariott-common" -version = "0.1.0" -dependencies = [ - "async-trait", - "chariott-proto", - "ess", - "regex", - "serde", - "tempfile", - "tokio", - "tokio-stream", - "tokio-util", - "tonic", - "tracing", - "uuid", -] - -[[package]] -name = "chariott-proto" -version = "0.1.0" -dependencies = [ - "prost", - "prost-types", - "tonic", - "tonic-build", -] - [[package]] name = "chrono" version = "0.4.33" @@ -639,10 +585,10 @@ version = "0.1.0" dependencies = [ "async-trait", "base64", - "chariott-common", - "chariott-proto", "examples-common", "futures", + "intent_brokering_common", + "intent_brokering_proto", "lazy_static", "reqwest", "serde", @@ -875,10 +821,10 @@ dependencies = [ "anyhow", "async-stream", "async-trait", - "chariott-common", - "chariott-proto", "examples-common", "futures", + "intent_brokering_common", + "intent_brokering_proto", "prost", "prost-types", "serde", @@ -944,9 +890,9 @@ dependencies = [ name = "ess" version = "0.1.0" dependencies = [ - "chariott-common", "criterion", "futures", + "intent_brokering_common", "tokio", "tokio-stream", "tokio-util", @@ -986,10 +932,10 @@ version = "0.1.0" dependencies = [ "async-trait", "bytes", - "chariott-common", - "chariott-proto", "ess", "futures", + "intent_brokering_common", + "intent_brokering_proto", "keyvalue", "prost", "prost-types", @@ -1560,15 +1506,69 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "intent_brokering" +version = "0.1.0" +dependencies = [ + "anyhow", + "async-recursion", + "async-trait", + "examples-common", + "futures", + "intent_brokering_common", + "intent_brokering_proto", + "prost", + "prost-types", + "test-case", + "tokio", + "tokio-stream", + "tokio-util", + "tonic", + "tonic-build", + "tonic-reflection", + "tracing", + "tracing-subscriber", + "url", + "uuid", +] + +[[package]] +name = "intent_brokering_common" +version = "0.1.0" +dependencies = [ + "async-trait", + "ess", + "intent_brokering_proto", + "regex", + "serde", + "tempfile", + "tokio", + "tokio-stream", + "tokio-util", + "tonic", + "tracing", + "uuid", +] + +[[package]] +name = "intent_brokering_proto" +version = "0.1.0" +dependencies = [ + "prost", + "prost-types", + "tonic", + "tonic-build", +] + [[package]] name = "invoke-command" version = "0.1.0" dependencies = [ "async-trait", - "chariott-common", - "chariott-proto", "ess", "examples-common", + "intent_brokering_common", + "intent_brokering_proto", "keyvalue", "serde", "serde_json", @@ -1669,10 +1669,10 @@ name = "kv-app" version = "0.1.0" dependencies = [ "async-trait", - "chariott-common", - "chariott-proto", "ess", "examples-common", + "intent_brokering_common", + "intent_brokering_proto", "keyvalue", "tokio", "tokio-stream", @@ -1745,10 +1745,10 @@ name = "local-object-detection-app" version = "0.1.0" dependencies = [ "async-trait", - "chariott-common", - "chariott-proto", "examples-common", "image", + "intent_brokering_common", + "intent_brokering_proto", "lazy_static", "ndarray", "serde", @@ -1787,10 +1787,10 @@ name = "lt-consumer-app" version = "0.1.0" dependencies = [ "bollard", - "chariott-common", "examples-common", "futures", "futures-util", + "intent_brokering_common", "metrics-util", "serde", "serde_json", @@ -1803,9 +1803,9 @@ dependencies = [ name = "lt-provider-app" version = "0.1.0" dependencies = [ - "chariott-common", - "chariott-proto", "examples-common", + "intent_brokering_common", + "intent_brokering_proto", "rand", "rand_distr", "tokio", @@ -1908,12 +1908,12 @@ dependencies = [ "anyhow", "async-std", "async-trait", - "chariott-common", - "chariott-proto", "env_logger", "ess", "examples-common", "futures", + "intent_brokering_common", + "intent_brokering_proto", "keyvalue", "lazy_static", "regex", @@ -2898,10 +2898,10 @@ name = "simple-provider" version = "0.1.0" dependencies = [ "async-trait", - "chariott-common", - "chariott-proto", "ess", "examples-common", + "intent_brokering_common", + "intent_brokering_proto", "keyvalue", "serde", "serde_json", @@ -2922,11 +2922,11 @@ dependencies = [ "async-std", "async-stream", "async-trait", - "chariott-common", - "chariott-proto", "ess", "examples-common", "futures", + "intent_brokering_common", + "intent_brokering_proto", "keyvalue", "lazy_static", "regex", diff --git a/Cargo.toml b/Cargo.toml index 74e0d81b..c037b7f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,8 +28,8 @@ members = [ [workspace.dependencies] anyhow = "1.0" async-trait = "0.1" -chariott-common = { path = "./intent_brokering/common/" } -chariott-proto = { path = "./intent_brokering/proto.rs/" } +intent_brokering_common = { path = "./intent_brokering/common/" } +intent_brokering_proto = { path = "./intent_brokering/proto.rs/" } futures = { version = "0.3" } lazy_static = "1.4.0" parking_lot = "0.12.1" diff --git a/Dockerfile.intent_brokering b/Dockerfile.intent_brokering index f46e0bd3..5a930ec8 100644 --- a/Dockerfile.intent_brokering +++ b/Dockerfile.intent_brokering @@ -5,10 +5,11 @@ ARG RUST_VERSION=1.70 FROM docker.io/library/rust:${RUST_VERSION} AS builder -# Dockerfile for building Eclipse Chariott runtime container +# Dockerfile for building Eclipse Chariott Intent Brokering runtime container # -# This Dockerfile utilizes a two step build process. It builds Chariott with -# statically linked dependencies (using musl) for a x86_64 architecture. +# This Dockerfile utilizes a two step build process. It builds the Intent Brokering +# service with statically linked dependencies (using musl) for a x86_64 +# architecture. # Chariott user id ARG CHARIOTT_UID=10001 @@ -16,7 +17,7 @@ ARG CHARIOTT_UID=10001 RUN apt update && apt upgrade -y RUN apt install -y cmake protobuf-compiler -# unprivileged identity to run Chariott as +# unprivileged identity to run Chariott Intent Brokering service as RUN adduser \ --disabled-password \ --gecos "" \ @@ -32,7 +33,7 @@ COPY ./ . RUN rustup target add x86_64-unknown-linux-musl -RUN cargo build --release --target=x86_64-unknown-linux-musl -p chariott +RUN cargo build --release --target=x86_64-unknown-linux-musl -p intent_brokering #################################################################################################### ## Final image @@ -46,9 +47,9 @@ COPY --from=builder /etc/group /etc/group WORKDIR /sdv # Copy our build -COPY --from=builder /sdv/target/x86_64-unknown-linux-musl/release/chariott /sdv/chariott +COPY --from=builder /sdv/target/x86_64-unknown-linux-musl/release/intent_brokering /sdv/intent_brokering # Use the unprivileged chariott user during execution. USER chariott:chariott -CMD ["./chariott"] +CMD ["./intent_brokering"] diff --git a/Dockerfile.intent_brokering.arm64 b/Dockerfile.intent_brokering.arm64 index a5158f48..c8ca88ee 100644 --- a/Dockerfile.intent_brokering.arm64 +++ b/Dockerfile.intent_brokering.arm64 @@ -5,12 +5,12 @@ ARG RUST_VERSION=1.70 FROM docker.io/library/rust:${RUST_VERSION} AS builder -# Dockerfile for building Eclipse Chariott container for ARM64 with -# cross-compilation. +# Dockerfile for building Eclipse Chariott Intent Brokering service container +# for ARM64 with cross-compilation. # # This Dockerfile utilizes a two step build process. It builds the with -# statically linked dependencies (using musl vs. glibc to accomplish this) for a -# specific architecture such that we can utilize a scratch container without +# statically linked dependencies (using musl vs. glibc to accomplish this) for +# a specific architecture such that we can utilize a scratch container without # further dependencies for our final container, minimizing container size. # Chariott user id @@ -19,7 +19,7 @@ ARG CHARIOTT_UID=10001 RUN apt update && apt upgrade -y RUN apt install -y cmake protobuf-compiler gcc-aarch64-linux-gnu -# unprivileged identity to run Chariott as +# unprivileged identity to run Chariott Intent Brokering service as RUN adduser \ --disabled-password \ --gecos "" \ @@ -35,7 +35,7 @@ COPY ./ . RUN rustup target add aarch64-unknown-linux-musl -RUN cargo build --release --target=aarch64-unknown-linux-musl -p chariott +RUN cargo build --release --target=aarch64-unknown-linux-musl -p intent_brokering #############################################################x####################################### ## Final image @@ -49,9 +49,9 @@ COPY --from=builder /etc/group /etc/group WORKDIR /sdv # Copy our build -COPY --from=builder /sdv/target/aarch64-unknown-linux-musl/release/chariott /sdv/chariott +COPY --from=builder /sdv/target/aarch64-unknown-linux-musl/release/intent_brokering /sdv/intent_brokering # Use the unprivileged Chariott user during execution. USER chariott::chariott -CMD ["./chariott"] +CMD ["./intent_brokering"] diff --git a/Dockerfile.intent_brokering.valgrind b/Dockerfile.intent_brokering.valgrind index f19dbe72..154bd9b5 100644 --- a/Dockerfile.intent_brokering.valgrind +++ b/Dockerfile.intent_brokering.valgrind @@ -5,12 +5,14 @@ ARG RUST_VERSION=1.70 FROM docker.io/library/rust:${RUST_VERSION} AS builder -# Dockerfile for building Eclipse Chariott container +# Dockerfile for building Eclipse Chariott Intent Brokering service container +# with valgrind # -# This Dockerfile utilizes a two step build process. It builds Chariott with -# statically linked dependencies (using musl vs. glibc to accomplish this) for a -# specific architecture such that we can utilize a scratch container without -# further dependencies for our final container, minimizing container size. +# This Dockerfile utilizes a two step build process. It builds Chariott Intent +# Brokering with statically linked dependencies (using musl vs. glibc to +# accomplish this) for a specific architecture such that we can utilize a +# scratch container without further dependencies for our final container, +# minimizing container size. # Chariott user id ARG CHARIOTT_UID=10001 @@ -18,7 +20,7 @@ ARG CHARIOTT_UID=10001 RUN apt update && apt upgrade -y RUN apt install -y cmake protobuf-compiler wget -# unprivileged identity to run Chariott as +# unprivileged identity to run Chariott Intent Brokering service as RUN adduser \ --disabled-password \ --gecos "" \ @@ -32,7 +34,7 @@ WORKDIR /sdv COPY ./ . -RUN cargo build --release -p chariott +RUN cargo build --release -p intent_brokering #############################################################x####################################### ## Final image @@ -59,7 +61,7 @@ COPY --from=builder /etc/group /etc/group WORKDIR /sdv # Copy our build -COPY --from=builder /sdv/target/release/chariott /sdv/chariott +COPY --from=builder /sdv/target/release/intent_brokering /sdv/intent_brokering # Give chariott user ownership of the /sdv directory RUN chown -R chariott:chariott /sdv @@ -67,4 +69,4 @@ RUN chown -R chariott:chariott /sdv # Use the unprivileged chariott user during execution. USER chariott::chariott -CMD ["valgrind", "--tool=memcheck", "--xml=yes", "--xml-file=/output/out.xml", "./chariott"] +CMD ["valgrind", "--tool=memcheck", "--xml=yes", "--xml-file=/output/out.xml", "./intent_brokering"] diff --git a/build-all-containers.sh b/build-all-containers.sh index cf1350cd..481b081a 100755 --- a/build-all-containers.sh +++ b/build-all-containers.sh @@ -18,10 +18,10 @@ if [ -z "$IMAGE_TAG" ]; then fi # Build base image for all example applications -docker build --tag "chariott:base" --file ./intent_brokering/examples/applications/Dockerfile.base . +docker build --tag "intent_brokering_examples:base" --file ./intent_brokering/examples/applications/Dockerfile.base . -# Build Chariott -docker build --tag "$(concat_image_registry chariott:"$IMAGE_TAG")" --file ./intent_brokering/examples/applications/Dockerfile.generic --build-arg APP_NAME=chariott . +# Build Intent Brokering service +docker build --tag "$(concat_image_registry intent_brokering:"$IMAGE_TAG")" --file ./intent_brokering/examples/applications/Dockerfile.generic --build-arg APP_NAME=intent_brokering . # Build Examples docker build --tag "$(concat_image_registry cloud-object-detection-app:"$IMAGE_TAG")" --file ./intent_brokering/examples/applications/Dockerfile.cloud-object-detection --build-arg APP_NAME=cloud-object-detection-app . diff --git a/build.rs b/build.rs index 621cf7de..a33b97a4 100644 --- a/build.rs +++ b/build.rs @@ -16,8 +16,8 @@ fn main() -> Result<(), Box> { .file_descriptor_set_path(out_dir.join("descriptor.bin")) .compile( &[ - "./proto/chariott/runtime/v1/runtime.proto", - "./proto/chariott/provider/v1/provider.proto", + "./proto/intent_brokering/runtime/v1/runtime.proto", + "./proto/intent_brokering/provider/v1/provider.proto", ], &["./proto/"], )?; diff --git a/docs/adr/0020-integration-and-e2e-testing.md b/docs/adr/0020-integration-and-e2e-testing.md index cde5a70d..4aca0d21 100644 --- a/docs/adr/0020-integration-and-e2e-testing.md +++ b/docs/adr/0020-integration-and-e2e-testing.md @@ -28,7 +28,7 @@ well as from the CI. Integration tests will be invoking the Chariott runtime server code directly, without using the [upstream gRPC -layer](../../intent_brokering/proto/chariott/runtime/v1/runtime.proto). We will not mock out any parts +layer](../../intent_brokering/proto/intent_brokering/runtime/v1/runtime.proto). We will not mock out any parts from the Chariott runtime when integration testing, hence we will need to set up a provider that is exposing a gRPC endpoint in order to handle intent fulfillments. diff --git a/docs/design/intent_brokering_design.md b/docs/design/intent_brokering_design.md index 001cc5ed..f88a7019 100644 --- a/docs/design/intent_brokering_design.md +++ b/docs/design/intent_brokering_design.md @@ -1,64 +1,64 @@ -# Design Specification for Project Eclipse Chariott +# Design Specification for Project Eclipse Chariott Intent Brokering - [Introduction](#introduction) - [Architecture](#architecture) -- [Chariott Sequence Diagram](#chariott-sequence-diagram) +- [Intent Brokering Sequence Diagram](#intent-brokering-sequence-diagram) ## Introduction -Project Eclipse Chariott delivers a metadata-driven application programming model. Today, Chariott serves two main purposes. First, it offers service discovery of "provider" applications advertising their functionality. These providers register their capabilities with Chariott. Second, Chariott provides the brokering of intent requests from any application towards the offering providers. Chariott was founded on [Capability Oriented Architecture](https://www.linkedin.com/pulse/brief-introduction-capability-oriented-architecture-coa-haishi-bai/) (COA). Since Chariott provides a common [gRPC](https://grpc.io/) interface for interacting with applications, it can be used with any language supporting gRPC. For more details on the gRPC interfaces, please see the [proto folder](../../intent_brokering/proto/chariott/). +Project Eclipse Chariott delivers a metadata-driven application programming model. Today, the Intent Brokering service serves two main purposes. First, it offers service discovery of "provider" applications advertising their functionality. These providers register their capabilities with the Intent Broker. Second, the Intent Broker provides the brokering of intent requests from any application towards the offering providers. This was founded on [Capability Oriented Architecture](https://www.linkedin.com/pulse/brief-introduction-capability-oriented-architecture-coa-haishi-bai/) (COA). Since the service provides a common [gRPC](https://grpc.io/) interface for interacting with applications, it can be used with any language supporting gRPC. For more details on the gRPC interfaces, please see the [proto folder](../../intent_brokering/proto/). ## Architecture -Chariott itself has two main architectural components. +The Intent Brokering service itself has two main architectural components. - Service Registry - Intent Broker The service registry is used for service discovery. It maintains a mapping of namespace to a list of services that are currently registered with that namespace and the metadata needed to communicate with that service. -The Intent Broker maintains a mapping of namespace and intent with the connection for the provider that can fulfill that intent request. It is used for brokering through Chariott. +The Intent Broker maintains a mapping of namespace and intent with the connection for the provider that can fulfill that intent request. It is used for brokering of intents. -Applications which interact with Chariott represent two additional architectural concepts. +Applications which interact with the Intent Brokering Service represent two additional architectural concepts. - Applications -- represent any software component -- Chariott Providers -- represent a software component which registers itself and its capabilities with Chariott +- Intent Providers -- represent a software component which registers itself and its capabilities with the Intent Brokering service -The phrase "consuming application" can be used to describe an application which uses Chariott to interact with another application, either through service discovery or intent brokering. It is important to note that any software component can use Chariott's service registry or intent broker to interact with another software component, including providers. In other words, an application can be both a provider and a "consuming application". +The phrase "consuming application" can be used to describe an application which uses the Intent Brokering service to interact with another application, either through service discovery or intent brokering. It is important to note that any software component can use the service registry or intent broker to interact with another software component, including providers. In other words, an application can be both a provider and a "consuming application". -Below is the component diagram for Chariott. +Below is the component diagram. ![Component Diagram](diagrams/chariott_component.svg) -## Chariott Sequence Diagram +## Intent Brokering Sequence Diagram -**Note:** Communication into and out of Chariott goes through the Chariott Server, a gRPC interface. Here, that is represented by the grey box. +**Note:** Communication into and out of Intent Brokering goes through the Intent Brokering Server, a gRPC interface. Here, that is represented by the grey box. ![Sequence Diagram](diagrams/chariott_sequence.svg) 1. Consuming application sends a Fulfill request to Discover the ‘sdv.sample.namespace’ -2. No provider has been registered for ‘sdv.sample.namepsace’ so Chariott returns an Error saying no provider found. -3. The AnnounceRequest is sent to Chariott. This step is optional, but it will tell the provider if they have already been registered. +2. No provider has been registered for ‘sdv.sample.namepsace’ so the service returns an Error saying no provider found. +3. The AnnounceRequest is sent to the Intent Broker. This step is optional, but it will tell the provider if they have already been registered. 4. A result of “ANNOUNCED” means that a provider with this namespace is not currently in the registry. -5. A RegisterRequest adds the provider to the Chariott registry. It sends its service information and the intents it can fulfill. -6. When this change is triggered, on_change will get called to add the intent bindings for this provider to the intent broker. +5. A RegisterRequest adds the provider to the Intent registry. It sends its service information and the intents it can fulfill. +6. When this change is triggered, on_change will get called to add the intent bindings for this provider to the Intent Broker. 7. A RegisterResponse is sent back to the provider 8. Provider starts a loop of AnnounceRequests so it does not get pruned -9. As long as the AnnounceResponse is NOT_CHANGED, the provider is still present in the registry. If at any point it receives an “ANNOUNCED” response, it should re-register itself with Chariott. +9. As long as the AnnounceResponse is NOT_CHANGED, the provider is still present in the registry. If at any point it receives an “ANNOUNCED” response, it should re-register itself with the Intent registry. 10. Consuming application sends a Fulfill request to Discover the ‘sdv.sample.namespace’ 11. Intent Broker sends a Fulfill request to its intent binding for ‘sdv.sample.namespace’ Discover 12. Consuming application returns a fulfillment response with a list of services for that namespace including the url, protocol, and schemaReference file (i.e. proto file name) for how to directly communicate with the provider -13. The intent broker returns this fulfillment response to the consuming application -14. Consuming application directly calls API_A on the provider (which it found in the schema file). This is an example of direct application communication after using Chariott for Service Discovery. +13. The Intent Broker returns this fulfillment response to the consuming application +14. Consuming application directly calls API_A on the provider (which it found in the schema file). This is an example of direct application communication after using the service for Service Discovery. 15. Provider sends its response to the consuming application directly for API_A 16. Consuming application sends a Fulfill request to Inspect information about ‘sdv.sample.namespace’ 17. Intent Broker sends a Fulfill request to its intent binding for ‘sdv.sample.namespace’ Inspect 18. Provider sends a FulfillResponse with the properties of the provider. -19. The intent broker returns this fulfillment response to the consuming application +19. The Intent Broker returns this fulfillment response to the consuming application 20. Consuming application sends a Fulfill Request to Invoke command1 on the ‘sdv.sample.namespace’ 21. Intent Broker sends a Fulfill request to its intent binding for ‘sdv.sample.namespace’ 22. Provider sends a FulfillResponse -23. The intent broker returns this fulfillment response to the consuming application -24. At this point, the provider exits. When this happens, it will no longer be pushing its continuous announce heartbeat to Chariott. After a configured amount of time, Chariott will prune this service from the registry and on_change will get called to remove the intent bindings for this provider to the intent broker. +23. The Intent Broker returns this fulfillment response to the consuming application +24. At this point, the provider exits. When this happens, it will no longer be pushing its continuous announce heartbeat to the Intent Brokering service. After a configured amount of time, the service will be pruned from the registry and on_change will get called to remove the intent bindings for this provider to the Intent Broker. 25. Consuming application sends a Fulfill request to Discover the ‘sdv.sample.namespace’ 26. Since the provider has been removed from the registry, it will return an Error saying no provider found. diff --git a/docs/memory-profiling.md b/docs/memory-profiling.md index d8ac9640..d510b75d 100644 --- a/docs/memory-profiling.md +++ b/docs/memory-profiling.md @@ -23,18 +23,18 @@ In case you want to build from source you can follow this [documentation](https: ## Scenario -In order to have a consistent feedback loop for Chariott and valgrind, we'll use the -load test benchmarking available in Chariott. +In order to have a consistent feedback loop for Intent Brokering and valgrind, we'll use the +load test benchmarking available in Intent Brokering. ## Running memcheck -Memcheck is the default valgrind tool for memory profiling. The usage for Chariott +Memcheck is the default valgrind tool for memory profiling. The usage for Intent Brokering together with the e2e tests is as follows: -In a dedicated terminal, run valgrind with Chariott +In a dedicated terminal, run valgrind with Intent Brokering ```bash -valgrind ./target/debug/chariott +valgrind ./target/debug/intent_brokering ``` In another terminal, run the e2e tests @@ -69,13 +69,13 @@ the end of the output. It looks like this: ## Running massif The other tool to use is **massif**. It writes its output to a file, which can be -visualized with the `ms_print` tool. The usage for Chariott together with the e2e +visualized with the `ms_print` tool. The usage for Intent Brokering together with the e2e tests is as follows: -In a dedicated terminal, run massif with Chariott +In a dedicated terminal, run massif with Intent Brokering ```bash -valgrind --tool=massif ./target/debug/chariott +valgrind --tool=massif ./target/debug/intent_brokering ``` In another terminal, run the e2e tests @@ -98,7 +98,7 @@ The output of `ms_print` looks like this (just a part of it): ```bash -------------------------------------------------------------------------------- -Command: ./target/debug/chariott +Command: ./target/debug/intent_brokering Massif arguments: (none) ms_print arguments: massif.out.7704 -------------------------------------------------------------------------------- diff --git a/intent_brokering/Cargo.toml b/intent_brokering/Cargo.toml index 73a27fff..cea91cd8 100644 --- a/intent_brokering/Cargo.toml +++ b/intent_brokering/Cargo.toml @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT [package] -name = "chariott" +name = "intent_brokering" version = "0.1.0" edition = "2021" license = "MIT" @@ -11,8 +11,8 @@ license = "MIT" [dependencies] async-recursion = "1.0" async-trait = { workspace = true } -chariott-common = { workspace = true } -chariott-proto = { workspace = true } +intent_brokering_common = { workspace = true } +intent_brokering_proto = { workspace = true } prost = { workspace = true } prost-types = { workspace = true } tokio = { workspace = true, features = ["rt-multi-thread", "time"] } diff --git a/intent_brokering/README.md b/intent_brokering/README.md index f64061ba..88099559 100644 --- a/intent_brokering/README.md +++ b/intent_brokering/README.md @@ -11,8 +11,8 @@ - [Without Dev Container](#without-dev-container) - [Install Dependencies](#install-dependencies) - [Build all binaries and run tests natively](#build-all-binaries-and-run-tests-natively) - - [Build and run Chariott only](#build-and-run-chariott-only) -- [How to run the examples and interact with Chariott](#how-to-run-the-examples-and-interact-with-chariott) + - [Build and run Intent Brokering only](#build-and-run-intent-brokering-only) +- [How to run the examples and interact with Intent Brokering](#how-to-run-the-examples-and-interact-with-intent-brokering) - [How to run the dog mode demo](#how-to-run-the-dog-mode-demo) - [Trademarks](#trademarks) @@ -21,18 +21,18 @@ | Term | Description | | --- | --- | | Application | An application is defined as any software component. | -| Provider | A provider is also an application that in addition registers its capabilities with Chariott's service registry for other applications to consume. | -| Consuming Application | A consuming application is a client application that interacts with Chariott to look up capability providers and interact with them through Chariott or directly. | ->Note: "provider" or "consuming application" are just roles for an application. Specifically, an application can be both a Chariott "provider" and "consuming application". +| Provider | A provider is also an application that in addition registers its capabilities with the Intent Brokering service's registry for other applications to consume. | +| Consuming Application | A consuming application is a client application that interacts with the Intent Broker to look up capability providers and interact with them through the Intent Broker or directly. | +>Note: "provider" or "consuming application" are just roles for an application. Specifically, an application can be both an Intent "provider" and "consuming application". ## Concept of Intents -Intents are the main way to interact with Chariott. Once a provider registers -an intent with Chariott, other applications can use that intent to interact with +Intents are the main way to interact with the Intent Broker. Once a provider registers +an intent with the Intent Broker, other applications can use that intent to interact with the provider. The intent is a gRPC method that is defined in the provider's -protobuf definition. That definition is only used by Chariott itself. +protobuf definition. That definition is only used by the Intent Broker itself. -Chariott also provides a gRPC interface for applications to interact with +The Intent Broker also provides a gRPC interface for applications to interact with providers and delegates the calls based on the intent to the provider transparently. Therefore, clients don't need to know the location and details of the provider as long as their intent is fulfilled. @@ -41,7 +41,7 @@ Here is a list of the current supported intents: | Intent | Description | | --- | --- | -| Discover | Retrieve native interfaces of providers. This comes in handy if you need specific interaction with a provider that you know is available in the system and you don't want to use Chariott to interact with it. This is also used for retrieving the streaming endpoints of a provider. | +| Discover | Retrieve native interfaces of providers. This comes in handy if you need specific interaction with a provider that you know is available in the system and you don't want to use the Intent Broker to interact with it. This is also used for retrieving the streaming endpoints of a provider. | | Inspect | Support inspection of functionality, properties and events using a simple query syntax. | | Invoke | Invoke a method on a provider. | | Subscribe | Subscribe to events of a provider. Note that this does not open the streaming channel, this is done through the native streaming endpoint of the provider. | @@ -51,7 +51,7 @@ Here is a list of the current supported intents: More information can be found in the protobuf definitions in `./proto`. There is a separate document that describes the example applications and -scenarios that are supported by Chariott. It can be found +scenarios that are supported by the Intent Broker. It can be found [here](./examples/applications/README.md). ## Requirements @@ -98,8 +98,8 @@ variable to the new target folder. The following sequence works in the devcontai ```shell vscode ➜ /workspaces/chariott (main) $ sudo mkdir ../target vscode ➜ /workspaces/chariott (main) $ sudo chown vscode:vscode ../target -vscode ➜ /workspaces/chariott (main) $ CARGO_TARGET_DIR=../target cargo build -p chariott -vscode ➜ /workspaces/chariott (main) $ CARGO_TARGET_DIR=../target cargo run -p chariott +vscode ➜ /workspaces/chariott (main) $ CARGO_TARGET_DIR=../target cargo build -p intent_brokering +vscode ➜ /workspaces/chariott (main) $ CARGO_TARGET_DIR=../target cargo run -p intent_brokering ``` #### Using Podman instead of Docker @@ -134,7 +134,7 @@ with the following additions: #### Install Dependencies As stated above, the `devcontainer.json` and the Dockerfile -`.devcontainer/Dockerfile` contain a list of the plugins/tools we use for Chariott. +`.devcontainer/Dockerfile` contain a list of the plugins/tools we use for the Intent Brokering service. Below we have listed the steps to get started, but refer to those files if there are any discrepancies. This guide uses `apt` as the package manager in the examples. You may need to substitute your own @@ -189,17 +189,17 @@ cargo build --workspace cargo test --workspace ``` -#### Build and run Chariott only +#### Build and run Intent Brokering only ```bash -cargo run -p chariott +cargo run -p intent_brokering ``` -## How to run the examples and interact with Chariott +## How to run the examples and interact with Intent Brokering Refer to individual example applications' documentation for additional setup or dependencies that may be required. -As Chariott's out of the box communication protocol is gRPC, the interaction with the +As the Intent Brokering service's out of the box communication protocol is gRPC, the interaction with the examples is done through gRPC. To illustrate how to invoke the gRPC methods we use the [grpcurl](https://github.com/fullstorydev/grpcurl) command line tool with the example application **kv-app**. The **kv-app** is a key-value store that can be used to store diff --git a/intent_brokering/common/Cargo.toml b/intent_brokering/common/Cargo.toml index cb68bdf8..8c2b137d 100644 --- a/intent_brokering/common/Cargo.toml +++ b/intent_brokering/common/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "chariott-common" +name = "intent_brokering_common" version = "0.1.0" edition = "2021" license = "MIT" [dependencies] async-trait = { workspace = true } -chariott-proto = { workspace = true } +intent_brokering_proto = { workspace = true } ess = { path = "../ess" } regex = { workspace = true } serde = { workspace = true, features = ["derive"] } diff --git a/intent_brokering/common/src/lib.rs b/intent_brokering/common/src/lib.rs index bb914c65..9eb5e916 100644 --- a/intent_brokering/common/src/lib.rs +++ b/intent_brokering/common/src/lib.rs @@ -13,7 +13,7 @@ //! In order to get started, reference this library in your Cargo.toml //! //! ```toml -//! chariott_common = { path = "../common/" } +//! intent_brokering_common = { path = "../common/" } //! ``` //! diff --git a/intent_brokering/common/src/streaming_ess.rs b/intent_brokering/common/src/streaming_ess.rs index 7f284357..507f06a2 100644 --- a/intent_brokering/common/src/streaming_ess.rs +++ b/intent_brokering/common/src/streaming_ess.rs @@ -5,7 +5,7 @@ use std::{ops::Deref, sync::Arc, time::SystemTime}; use async_trait::async_trait; -use chariott_proto::{ +use intent_brokering_proto::{ common::ValueMessage, common::{SubscribeFulfillment, SubscribeIntent, ValueEnum}, streaming::{channel_service_server::ChannelService, Event, OpenRequest}, @@ -18,7 +18,7 @@ use uuid::Uuid; type EventSubSystem = ess::EventSubSystem, Box, T, Result>; /// [`StreamingEss`](StreamingEss) integrates the reusable -/// [`EventSubSystem`](ess::EventSubSystem) component with the Chariott gRPC +/// [`EventSubSystem`](ess::EventSubSystem) component with the Intent Broker gRPC /// streaming contract. Cloning [`StreamingEss`](StreamingEss) is cheap, it will /// not create a new instance but refer to the same underlying instance instead. #[derive(Clone)] @@ -99,7 +99,7 @@ impl Deref for StreamingEss { mod tests { use std::time::Duration; - use chariott_proto::{ + use intent_brokering_proto::{ common::{SubscribeIntent, ValueEnum, ValueMessage}, streaming::{channel_service_server::ChannelService, OpenRequest}, }; diff --git a/intent_brokering/ess/Cargo.toml b/intent_brokering/ess/Cargo.toml index 783af2d4..7bf01e43 100644 --- a/intent_brokering/ess/Cargo.toml +++ b/intent_brokering/ess/Cargo.toml @@ -11,7 +11,7 @@ tokio-util = { workspace = true } tracing = { workspace = true } [dev-dependencies] -chariott-common = { path = "../common/" } +intent_brokering_common = { path = "../common/" } criterion = { version = "0.5.1", features = ["async_tokio"] } futures = { workspace = true } tokio = { workspace = true, features = ["macros", "sync", "rt-multi-thread"] } diff --git a/intent_brokering/ess/benches/load_bench.rs b/intent_brokering/ess/benches/load_bench.rs index 25ea68f5..616cc4da 100644 --- a/intent_brokering/ess/benches/load_bench.rs +++ b/intent_brokering/ess/benches/load_bench.rs @@ -1,7 +1,7 @@ -use chariott_common::tokio_runtime_fork::BuilderExt; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use ess::EventSubSystem; use futures::StreamExt; +use intent_brokering_common::tokio_runtime_fork::BuilderExt; use std::sync::Arc; use tokio::sync::broadcast::{self, Receiver}; type Ess = EventSubSystem; diff --git a/intent_brokering/ess/src/ess.rs b/intent_brokering/ess/src/ess.rs index b52148c2..9ef3d4eb 100644 --- a/intent_brokering/ess/src/ess.rs +++ b/intent_brokering/ess/src/ess.rs @@ -443,7 +443,7 @@ where #[cfg(test)] mod tests { use crate::{EventSubSystem, UpsertResult}; - use chariott_common::tokio_runtime_fork; + use intent_brokering_common::tokio_runtime_fork; use std::time::Duration; #[derive(Debug, Clone, Eq, PartialEq, Hash)] diff --git a/intent_brokering/examples/applications/Dockerfile.base b/intent_brokering/examples/applications/Dockerfile.base index 79def7e2..d740b9de 100644 --- a/intent_brokering/examples/applications/Dockerfile.base +++ b/intent_brokering/examples/applications/Dockerfile.base @@ -5,7 +5,7 @@ ARG RUST_VERSION=1.70 FROM docker.io/library/rust:${RUST_VERSION} AS builder -# Dockerfile for building Eclipse Chariott base image +# Dockerfile for building Eclipse Chariott Intent Brokering base image # # This Dockerfile builds the packages from chariott workspace with # statically linked dependencies (using musl) for x86_64 architecture diff --git a/intent_brokering/examples/applications/Dockerfile.cloud-object-detection b/intent_brokering/examples/applications/Dockerfile.cloud-object-detection index acc8113f..a8a85c96 100644 --- a/intent_brokering/examples/applications/Dockerfile.cloud-object-detection +++ b/intent_brokering/examples/applications/Dockerfile.cloud-object-detection @@ -1,7 +1,7 @@ ##################################################################################################### ## Final image #################################################################################################### -FROM chariott:base as base +FROM intent_brokering_examples:base as base FROM alpine:latest ARG APP_NAME ENV USER_NAME=sample diff --git a/intent_brokering/examples/applications/Dockerfile.generic b/intent_brokering/examples/applications/Dockerfile.generic index 9fb21bef..6aacc023 100644 --- a/intent_brokering/examples/applications/Dockerfile.generic +++ b/intent_brokering/examples/applications/Dockerfile.generic @@ -1,7 +1,7 @@ ##################################################################################################### ## Final image #################################################################################################### -FROM chariott:base as base +FROM intent_brokering_examples:base as base FROM alpine:latest ARG APP_NAME ENV USER_NAME=sample diff --git a/intent_brokering/examples/applications/Dockerfile.kv-app.ci b/intent_brokering/examples/applications/Dockerfile.kv-app.ci index ee8fa39f..9bd044de 100644 --- a/intent_brokering/examples/applications/Dockerfile.kv-app.ci +++ b/intent_brokering/examples/applications/Dockerfile.kv-app.ci @@ -5,9 +5,9 @@ ARG RUST_VERSION=1.70 FROM docker.io/library/rust:${RUST_VERSION} AS builder -# Dockerfile for building Eclipse Chariott container +# Dockerfile for building the kv-app container # -# This Dockerfile utilizes a two step build process. It builds Chariott with +# This Dockerfile utilizes a two step build process. It builds kv-app with # statically linked dependencies (using musl vs. glibc to accomplish this) for a # specific architecture such that we can utilize a scratch container without # further dependencies for our final container, minimizing container size. @@ -29,7 +29,7 @@ RUN rustup target add x86_64-unknown-linux-musl RUN cargo build --release --target=x86_64-unknown-linux-musl --package kv-app -# unprivileged identity to run Chariott as +# unprivileged identity to run kv-app as RUN adduser \ --disabled-password \ --gecos "" \ @@ -45,7 +45,7 @@ RUN adduser \ FROM alpine:latest ARG APP_NAME ARG USER_NAME -# Import Chariott user and group from builder. +# Import kv-app user and group from builder. COPY --from=builder /etc/passwd /etc/passwd COPY --from=builder /etc/group /etc/group @@ -54,6 +54,6 @@ WORKDIR /sdv # Copy our build COPY --from=builder /sdv/target/x86_64-unknown-linux-musl/release/kv-app /sdv/kv-app -# Use the unprivileged chariott user during execution. +# Use the unprivileged kv-app user during execution. USER ${USER_NAME}:${USER_NAME} CMD ["sh", "-c", "./kv-app"] diff --git a/intent_brokering/examples/applications/Dockerfile.lt-provider-app.ci b/intent_brokering/examples/applications/Dockerfile.lt-provider-app.ci index 119395f1..a9230e79 100644 --- a/intent_brokering/examples/applications/Dockerfile.lt-provider-app.ci +++ b/intent_brokering/examples/applications/Dockerfile.lt-provider-app.ci @@ -5,12 +5,13 @@ ARG RUST_VERSION=1.70 FROM docker.io/library/rust:${RUST_VERSION} AS builder -# Dockerfile for building Eclipse Chariott container +# Dockerfile for building the "load test" container # -# This Dockerfile utilizes a two step build process. It builds Chariott with -# statically linked dependencies (using musl vs. glibc to accomplish this) for a -# specific architecture such that we can utilize a scratch container without -# further dependencies for our final container, minimizing container size. +# This Dockerfile utilizes a two step build process. It builds "load test" +# with statically linked dependencies (using musl vs. glibc to accomplish this) +# for a specific architecture such that we can utilize a scratch container +# without further dependencies for our final container, minimizing container +# size. # Examples user id ARG SAMPLE_UID=10001 @@ -29,7 +30,7 @@ RUN rustup target add x86_64-unknown-linux-musl RUN cargo build --release --target=x86_64-unknown-linux-musl --package lt-provider-app -# unprivileged identity to run Chariott as +# unprivileged identity to run "load test" as RUN adduser \ --disabled-password \ --gecos "" \ @@ -45,7 +46,7 @@ RUN adduser \ FROM alpine:latest ARG APP_NAME ARG USER_NAME -# Import Chariott user and group from builder. +# Import "load test" user and group from builder. COPY --from=builder /etc/passwd /etc/passwd COPY --from=builder /etc/group /etc/group @@ -54,6 +55,6 @@ WORKDIR /sdv # Copy our build COPY --from=builder /sdv/target/x86_64-unknown-linux-musl/release/lt-provider-app /sdv/lt-provider-app -# Use the unprivileged chariott user during execution. +# Use the unprivileged "load test" user during execution. USER ${USER_NAME}:${USER_NAME} CMD ["sh", "-c", "./lt-provider-app"] diff --git a/intent_brokering/examples/applications/Dockerfile.mock-vas b/intent_brokering/examples/applications/Dockerfile.mock-vas index 2020ad21..bbd2e84c 100644 --- a/intent_brokering/examples/applications/Dockerfile.mock-vas +++ b/intent_brokering/examples/applications/Dockerfile.mock-vas @@ -1,7 +1,7 @@ ##################################################################################################### ## Final image #################################################################################################### -FROM chariott:base as base +FROM intent_brokering_examples:base as base FROM alpine:latest ARG APP_NAME ENV USER_NAME=sample diff --git a/intent_brokering/examples/applications/Dockerfile.simulated-camera b/intent_brokering/examples/applications/Dockerfile.simulated-camera index bdf11f1f..5ebe1431 100644 --- a/intent_brokering/examples/applications/Dockerfile.simulated-camera +++ b/intent_brokering/examples/applications/Dockerfile.simulated-camera @@ -1,7 +1,7 @@ ##################################################################################################### ## Final image #################################################################################################### -FROM chariott:base as base +FROM intent_brokering_examples:base as base FROM alpine:latest ARG APP_NAME ENV USER_NAME=sample diff --git a/intent_brokering/examples/applications/cloud-object-detection/Cargo.toml b/intent_brokering/examples/applications/cloud-object-detection/Cargo.toml index 28a4a0b9..c54052b4 100644 --- a/intent_brokering/examples/applications/cloud-object-detection/Cargo.toml +++ b/intent_brokering/examples/applications/cloud-object-detection/Cargo.toml @@ -7,8 +7,8 @@ license = "MIT" [dependencies] async-trait = { workspace = true } base64 = "0.21.7" -chariott-common = { workspace = true } -chariott-proto = { workspace = true } +intent_brokering_common = { workspace = true } +intent_brokering_proto = { workspace = true } examples-common = { path = "../../common/" } futures = { workspace = true } lazy_static = { workspace = true } @@ -24,7 +24,7 @@ url = { workspace = true } [dev-dependencies] async-trait = { workspace = true } -chariott-common = { workspace = true } +intent_brokering_common = { workspace = true } [build-dependencies] tonic-build = { workspace = true } diff --git a/intent_brokering/examples/applications/cloud-object-detection/README.md b/intent_brokering/examples/applications/cloud-object-detection/README.md index 1d18b9fc..15265aff 100644 --- a/intent_brokering/examples/applications/cloud-object-detection/README.md +++ b/intent_brokering/examples/applications/cloud-object-detection/README.md @@ -5,8 +5,8 @@ Cognitive Services. To run the application: -1. Start chariott runtime by executing `cargo run` from the root directory -2. Start it by executing `cargo run` from the +1. Start the Intent Brokering runtime by executing `cargo run -p intent_brokering` +2. Start the cloud object detection by executing `cargo run` from the `intent_brokering/examples/applications/cloud-object-detection` directory while specifying `COGNITIVE_ENDPOINT` (i.e. `myendpoint.cognitiveservices.azure.com`) and `COGNITIVE_KEY` environment variables. @@ -38,5 +38,5 @@ To run the application: 4. Execute detection with `grpcurl -v -plaintext -import-path proto/ \ -import-path intent_brokering/examples/applications/proto -use-reflection -proto \ intent_brokering/examples/applications/proto/examples/detection/v1/detection.proto -d @ \ - localhost:4243 chariott.runtime.v1.ChariottService/Fulfill < \ + localhost:4243 intent_brokering.runtime.v1.IntentBrokeringService/Fulfill < \ detect_image.json` diff --git a/intent_brokering/examples/applications/cloud-object-detection/src/detection.rs b/intent_brokering/examples/applications/cloud-object-detection/src/detection.rs index 77f168f7..79bf6779 100644 --- a/intent_brokering/examples/applications/cloud-object-detection/src/detection.rs +++ b/intent_brokering/examples/applications/cloud-object-detection/src/detection.rs @@ -2,8 +2,8 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -use chariott_common::error::{Error, ResultExt}; use examples_common::examples::detection::{DetectRequest, DetectResponse, DetectionObject}; +use intent_brokering_common::error::{Error, ResultExt}; use reqwest::Client; use serde::{Deserialize, Serialize}; use std::{env, mem}; diff --git a/intent_brokering/examples/applications/cloud-object-detection/src/chariott_provider.rs b/intent_brokering/examples/applications/cloud-object-detection/src/intent_provider.rs similarity index 92% rename from intent_brokering/examples/applications/cloud-object-detection/src/chariott_provider.rs rename to intent_brokering/examples/applications/cloud-object-detection/src/intent_provider.rs index ec28b1b4..23d07f8d 100644 --- a/intent_brokering/examples/applications/cloud-object-detection/src/chariott_provider.rs +++ b/intent_brokering/examples/applications/cloud-object-detection/src/intent_provider.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use async_trait::async_trait; -use chariott_proto::{ +use intent_brokering_proto::{ common::{FulfillmentEnum, FulfillmentMessage, IntentEnum}, provider::{provider_service_server::ProviderService, FulfillRequest, FulfillResponse}, }; @@ -13,15 +13,15 @@ use tracing::error; use crate::detection::DetectionLogic; use examples_common::{ - chariott::inspection::{fulfill, Entry}, examples::detection::DetectRequest, + intent_brokering::inspection::{fulfill, Entry}, }; -pub struct ChariottProvider { +pub struct IntentProvider { internal_logic: DetectionLogic, } -impl ChariottProvider { +impl IntentProvider { pub fn new() -> Self { let internal_logic = DetectionLogic::new(); Self { internal_logic } @@ -39,7 +39,7 @@ lazy_static::lazy_static! { } #[async_trait] -impl ProviderService for ChariottProvider { +impl ProviderService for IntentProvider { async fn fulfill( &self, request: Request, diff --git a/intent_brokering/examples/applications/cloud-object-detection/src/main.rs b/intent_brokering/examples/applications/cloud-object-detection/src/main.rs index 6e822e88..bf96eb0a 100644 --- a/intent_brokering/examples/applications/cloud-object-detection/src/main.rs +++ b/intent_brokering/examples/applications/cloud-object-detection/src/main.rs @@ -2,24 +2,24 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -mod chariott_provider; mod detection; +mod intent_provider; -use chariott_common::error::Error; -use chariott_common::shutdown::RouterExt as _; -use chariott_proto::{ +use examples_common::intent_brokering; +use intent_brokering_common::error::Error; +use intent_brokering_common::shutdown::RouterExt as _; +use intent_brokering_proto::{ provider::provider_service_server::ProviderServiceServer, runtime::{intent_registration::Intent, intent_service_registration::ExecutionLocality}, }; -use examples_common::chariott; use tonic::transport::Server; -use crate::chariott_provider::ChariottProvider; +use crate::intent_provider::IntentProvider; -chariott::provider::main!(wain); +intent_brokering::provider::main!(wain); async fn wain() -> Result<(), Error> { - let (url, socket_address) = chariott::provider::register( + let (url, socket_address) = intent_brokering::provider::register( "sdv.cloud-detection", "0.0.1", "sdv.detection", @@ -33,7 +33,7 @@ async fn wain() -> Result<(), Error> { tracing::info!("Application listening on: {url}"); Server::builder() - .add_service(ProviderServiceServer::new(ChariottProvider::new())) + .add_service(ProviderServiceServer::new(IntentProvider::new())) .serve_with_ctrl_c_shutdown(socket_address) .await } diff --git a/intent_brokering/examples/applications/dog-mode-logic/Cargo.toml b/intent_brokering/examples/applications/dog-mode-logic/Cargo.toml index 5119f5ca..ed4045b0 100644 --- a/intent_brokering/examples/applications/dog-mode-logic/Cargo.toml +++ b/intent_brokering/examples/applications/dog-mode-logic/Cargo.toml @@ -8,8 +8,8 @@ license = "MIT" anyhow = { workspace = true } async-stream = "0.3.3" async-trait = { workspace = true } -chariott-common = { workspace = true } -chariott-proto = { workspace = true } +intent_brokering_common = { workspace = true } +intent_brokering_proto = { workspace = true } examples-common = { path = "../../common/" } futures = { workspace = true } prost = { workspace = true } diff --git a/intent_brokering/examples/applications/dog-mode-logic/src/dog_mode_status.rs b/intent_brokering/examples/applications/dog-mode-logic/src/dog_mode_status.rs index 2b3547a1..764f8808 100644 --- a/intent_brokering/examples/applications/dog-mode-logic/src/dog_mode_status.rs +++ b/intent_brokering/examples/applications/dog-mode-logic/src/dog_mode_status.rs @@ -4,25 +4,25 @@ use anyhow::{anyhow, Error}; use async_stream::try_stream; -use chariott_proto::common::Blob; use examples_common::{ - chariott::{ - api::{Chariott, ChariottExt as _, GrpcChariott}, + examples::proto::detection::{DetectRequest, DetectResponse}, + intent_brokering::{ + api::{GrpcIntentBrokering, IntentBrokering, IntentBrokeringExt as _}, value::Value, }, - examples::proto::detection::{DetectRequest, DetectResponse}, }; use futures::{stream::BoxStream, TryStreamExt}; +use intent_brokering_proto::common::Blob; use tokio_stream::StreamExt; use tracing::{info, warn}; use crate::{DogModeState, DOG_MODE_STATUS_ID, KEY_VALUE_STORE_NAMESPACE}; pub(crate) async fn stream_dog_mode_status( - mut chariott: GrpcChariott, + mut intent_broker: GrpcIntentBrokering, state: &mut DogModeState, ) -> Result>, Error> { - if let ok @ Ok(_) = detect_dog(chariott.clone()).await { + if let ok @ Ok(_) = detect_dog(intent_broker.clone()).await { info!("Using automated dog detection."); // The dog mode logic application is responsible for updating the @@ -34,7 +34,7 @@ pub(crate) async fn stream_dog_mode_status( warn!("Automatic dog detection failed. Falling back to using an external application to turn on the dog mode."); Ok(Box::pin( - chariott + intent_broker .listen(KEY_VALUE_STORE_NAMESPACE, [DOG_MODE_STATUS_ID.into()]) .await? .map_err(|e| e.into()) @@ -48,7 +48,7 @@ pub(crate) async fn stream_dog_mode_status( } async fn detect_dog( - mut chariott: GrpcChariott, + mut intent_broker: GrpcIntentBrokering, ) -> Result>, Error> { const CAMERA_NAMESPACE: &str = "sdv.camera.simulated"; const FRAMES_METADATA_KEY: &str = "frames_per_minute"; @@ -61,22 +61,22 @@ async fn detect_dog( /// namespace. If there are intents, we assume that those are the /// supported intent. async fn ensure_vehicle_functionality( - chariott: &mut impl Chariott, + intent_broker: &mut impl IntentBrokering, namespace: &str, ) -> Result<(), Error> { - if chariott.inspect(SYSTEM_REGISTRY_NAMESPACE, namespace).await?.is_empty() { + if intent_broker.inspect(SYSTEM_REGISTRY_NAMESPACE, namespace).await?.is_empty() { Err(anyhow!("Vehicle does not have registrations for namespace '{namespace}'.")) } else { Ok(()) } } - ensure_vehicle_functionality(&mut chariott, CAMERA_NAMESPACE).await?; - ensure_vehicle_functionality(&mut chariott, OBJECT_DETECTION_NAMESPACE).await?; + ensure_vehicle_functionality(&mut intent_broker, CAMERA_NAMESPACE).await?; + ensure_vehicle_functionality(&mut intent_broker, OBJECT_DETECTION_NAMESPACE).await?; // Stream images from the camera at the highest frame rate. - let (subscription_key, frames) = chariott + let (subscription_key, frames) = intent_broker .inspect(CAMERA_NAMESPACE, "**") .await? .into_iter() @@ -93,15 +93,18 @@ async fn detect_dog( info!("Streaming with frame rate of {frames}fpm."); - let images = chariott.listen(CAMERA_NAMESPACE, [subscription_key]).await?; + let images = intent_broker.listen(CAMERA_NAMESPACE, [subscription_key]).await?; let dog_mode_state_stream = try_stream! { for await image in images { - yield image_contains_dog(&mut chariott, image?.data).await?; + yield image_contains_dog(&mut intent_broker, image?.data).await?; } }; - async fn image_contains_dog(chariott: &mut impl Chariott, image: Value) -> Result { + async fn image_contains_dog( + intent_broker: &mut impl IntentBrokering, + image: Value, + ) -> Result { use prost::Message; let (media_type, bytes) = image @@ -113,7 +116,7 @@ async fn detect_dog( let mut detect_request_bytes = vec![]; detect_request.encode(&mut detect_request_bytes)?; - let detection_result = chariott + let detection_result = intent_broker .invoke( OBJECT_DETECTION_NAMESPACE, DETECT_COMMAND_NAME, diff --git a/intent_brokering/examples/applications/dog-mode-logic/src/main.rs b/intent_brokering/examples/applications/dog-mode-logic/src/main.rs index afb1a00d..69afc7df 100644 --- a/intent_brokering/examples/applications/dog-mode-logic/src/main.rs +++ b/intent_brokering/examples/applications/dog-mode-logic/src/main.rs @@ -9,8 +9,8 @@ use std::{ use anyhow::{anyhow, Error}; use dog_mode_status::stream_dog_mode_status; -use examples_common::chariott::{ - api::{Chariott, ChariottExt as _, GrpcChariott}, +use examples_common::intent_brokering::{ + api::{GrpcIntentBrokering, IntentBrokering, IntentBrokeringExt as _}, value::Value, }; use tokio::{select, time::sleep_until}; @@ -83,7 +83,7 @@ pub async fn main() -> Result<(), Error> { .finish() .init(); - let mut chariott = GrpcChariott::connect().await?; + let mut intent_broker = GrpcIntentBrokering::connect().await?; let mut state = DogModeState::new(); // Inspect vehicle hardware to assert that all requirements are met before @@ -102,7 +102,7 @@ pub async fn main() -> Result<(), Error> { (ACTIVATE_AIR_CONDITIONING_ID, /*..*/ MEMBER_TYPE_COMMAND, "IAcmeAirconControl"), ] { inspect_dependency( - &mut chariott, + &mut intent_broker, path, &[(MEMBER_TYPE, member_type.into()), (TYPE, /*..*/ r#type.into())], ) @@ -114,7 +114,7 @@ pub async fn main() -> Result<(), Error> { (SET_UI_MESSAGE_ID, "ISetUiMessage", &mut state.set_ui_message_disabled), ] { if let Err(e) = inspect_dependency( - &mut chariott, + &mut intent_broker, path, &[(MEMBER_TYPE, MEMBER_TYPE_COMMAND.into()), (TYPE, /*..*/ r#type.into())], ) @@ -130,11 +130,11 @@ pub async fn main() -> Result<(), Error> { } async fn inspect_dependency( - chariott: &mut GrpcChariott, + intent_broker: &mut GrpcIntentBrokering, path: impl Into> + Send, expected_properties: &[(&str, Value)], ) -> Result<(), Error> { - let inspection_result = chariott.inspect(VDT_NAMESPACE, path).await?; + let inspection_result = intent_broker.inspect(VDT_NAMESPACE, path).await?; inspection_result.iter().map(|m| { expected_properties.iter().map(|(expected_key, expected_value)| m.get(*expected_key) .ok_or_else(|| anyhow!("Member does not specify {expected_key:?}.")) @@ -154,7 +154,7 @@ pub async fn main() -> Result<(), Error> { // Set up the VDT and dog mode status streaming. - let mut vdt_stream = chariott + let mut vdt_stream = intent_broker .listen( VDT_NAMESPACE, [ @@ -165,7 +165,8 @@ pub async fn main() -> Result<(), Error> { ) .await?; - let mut dog_mode_status_stream = stream_dog_mode_status(chariott.clone(), &mut state).await?; + let mut dog_mode_status_stream = + stream_dog_mode_status(intent_broker.clone(), &mut state).await?; let mut next_timer_wakeup = Instant::now() + TIMEOUT_EVALUATION_INTERVAL; @@ -176,7 +177,7 @@ pub async fn main() -> Result<(), Error> { let state_update = select! { _ = sleep_until(next_timer_wakeup.into()) => { next_timer_wakeup = Instant::now() + TIMEOUT_EVALUATION_INTERVAL; - if let Some(new_state) = on_dog_mode_timer(&state, &mut chariott).await? { + if let Some(new_state) = on_dog_mode_timer(&state, &mut intent_broker).await? { state = new_state; } @@ -214,7 +215,7 @@ pub async fn main() -> Result<(), Error> { state = new_state } - match run_dog_mode(&state, &previous_state, &mut chariott).await { + match run_dog_mode(&state, &previous_state, &mut intent_broker).await { Ok(Some(new_state)) => state = new_state, Err(e) => error!("{e:?}"), Ok(None) => {} @@ -225,7 +226,7 @@ pub async fn main() -> Result<(), Error> { async fn run_dog_mode( state: &DogModeState, previous_state: &DogModeState, - chariott: &mut impl Chariott, + intent_broker: &mut impl IntentBrokering, ) -> Result, Error> { if state == previous_state { return Ok(None); @@ -250,7 +251,7 @@ async fn run_dog_mode( log_change("Battery level", state, previous_state, |s| s.battery_level)?; if state.write_dog_mode_status && (state.dogmode_status != previous_state.dogmode_status) { - chariott + intent_broker .write(KEY_VALUE_STORE_NAMESPACE, DOG_MODE_STATUS_ID, state.dogmode_status.into()) .await?; } @@ -258,7 +259,7 @@ async fn run_dog_mode( // Immediately end, if dog mode is disabled if !state.dogmode_status { if previous_state.dogmode_status { - activate_air_conditioning(chariott, false).await?; + activate_air_conditioning(intent_broker, false).await?; } return Ok(None); @@ -269,7 +270,7 @@ async fn run_dog_mode( // If the temperature falls below the set minimum, turn off air conditioning if MIN_TEMPERATURE >= state.temperature && state.air_conditioning_active { if let Some(last_air_conditioning_invocation_time) = - activate_air_conditioning_with_throttling(false, state, chariott).await? + activate_air_conditioning_with_throttling(false, state, intent_broker).await? { output_state = Some(DogModeState { last_air_conditioning_invocation_time, ..*state }); } @@ -278,7 +279,7 @@ async fn run_dog_mode( // If all criteria is fulfilled, activate air conditioning if state.temperature > MAX_TEMPERATURE && !state.air_conditioning_active { if let Some(last_air_conditioning_invocation_time) = - activate_air_conditioning_with_throttling(true, state, chariott).await? + activate_air_conditioning_with_throttling(true, state, intent_broker).await? { output_state = Some(DogModeState { last_air_conditioning_invocation_time, @@ -291,13 +292,13 @@ async fn run_dog_mode( async fn activate_air_conditioning_with_throttling( value: bool, state: &DogModeState, - chariott: &mut impl Chariott, + intent_broker: &mut impl IntentBrokering, ) -> Result, Error> { let now = Instant::now(); if now > state.last_air_conditioning_invocation_time + FUNCTION_INVOCATION_THROTTLING_DURATION { - activate_air_conditioning(chariott, value).await?; + activate_air_conditioning(intent_broker, value).await?; return Ok(Some(now)); } @@ -306,32 +307,36 @@ async fn run_dog_mode( // Air conditioning state was changed by the provider. if state.air_conditioning_active && !previous_state.air_conditioning_active { - send_notification(chariott, "The car is now being cooled.", state).await?; - set_ui_message(chariott, "The car is cooled, no need to worry.", state).await?; + send_notification(intent_broker, "The car is now being cooled.", state).await?; + set_ui_message(intent_broker, "The car is cooled, no need to worry.", state).await?; } // If the battery level fell below a threshold value, send a warning to the car owner. if previous_state.battery_level > LOW_BATTERY_LEVEL && state.battery_level <= LOW_BATTERY_LEVEL { - send_notification(chariott, "The battery is low, please return to the car.", state).await?; - set_ui_message(chariott, "The battery is low, the animal is in danger.", state).await?; + send_notification(intent_broker, "The battery is low, please return to the car.", state) + .await?; + set_ui_message(intent_broker, "The battery is low, the animal is in danger.", state) + .await?; } async fn activate_air_conditioning( - chariott: &mut impl Chariott, + intent_broker: &mut impl IntentBrokering, value: bool, ) -> Result<(), Error> { - _ = chariott.invoke(VDT_NAMESPACE, ACTIVATE_AIR_CONDITIONING_ID, [value.into()]).await?; + _ = intent_broker + .invoke(VDT_NAMESPACE, ACTIVATE_AIR_CONDITIONING_ID, [value.into()]) + .await?; Ok(()) } async fn send_notification( - chariott: &mut impl Chariott, + intent_broker: &mut impl IntentBrokering, message: &str, state: &DogModeState, ) -> Result<(), Error> { if !state.send_notification_disabled { - _ = chariott.invoke(VDT_NAMESPACE, SEND_NOTIFICATION_ID, [message.into()]).await?; + _ = intent_broker.invoke(VDT_NAMESPACE, SEND_NOTIFICATION_ID, [message.into()]).await?; Ok(()) } else { // as this is an optional method we don't care @@ -340,12 +345,12 @@ async fn run_dog_mode( } async fn set_ui_message( - chariott: &mut impl Chariott, + intent_broker: &mut impl IntentBrokering, message: &str, state: &DogModeState, ) -> Result<(), Error> { if !state.set_ui_message_disabled { - _ = chariott.invoke(VDT_NAMESPACE, SET_UI_MESSAGE_ID, [message.into()]).await?; + _ = intent_broker.invoke(VDT_NAMESPACE, SET_UI_MESSAGE_ID, [message.into()]).await?; Ok(()) } else { // as this is an optional method we don't care @@ -358,7 +363,7 @@ async fn run_dog_mode( async fn on_dog_mode_timer( state: &DogModeState, - chariott: &mut impl Chariott, + intent_broker: &mut impl IntentBrokering, ) -> Result, Error> { if let Some(air_conditioning_activation_time) = state.air_conditioning_activation_time { if state.air_conditioning_active { @@ -366,7 +371,7 @@ async fn on_dog_mode_timer( } else if Instant::now() > air_conditioning_activation_time + AIR_CONDITIONING_ACTIVATION_TIMEOUT { - _ = chariott + _ = intent_broker .invoke( VDT_NAMESPACE, SEND_NOTIFICATION_ID, @@ -384,8 +389,8 @@ async fn on_dog_mode_timer( #[cfg(test)] mod tests { use async_trait::async_trait; - use chariott_common::error::Error; - use examples_common::chariott::{api::Service, inspection::Entry}; + use examples_common::intent_brokering::{api::Service, inspection::Entry}; + use intent_brokering_common::error::Error; use super::*; @@ -397,7 +402,7 @@ mod tests { } #[async_trait] - impl Chariott for CarControllerMock { + impl IntentBrokering for CarControllerMock { async fn invoke + Send>( &mut self, namespace: impl Into> + Send, diff --git a/intent_brokering/examples/applications/dog-mode-ui/src/DogModeDashboard.csproj b/intent_brokering/examples/applications/dog-mode-ui/src/DogModeDashboard.csproj index 7e72d59e..8774c3e9 100644 --- a/intent_brokering/examples/applications/dog-mode-ui/src/DogModeDashboard.csproj +++ b/intent_brokering/examples/applications/dog-mode-ui/src/DogModeDashboard.csproj @@ -17,7 +17,7 @@ - + diff --git a/intent_brokering/examples/applications/dog-mode-ui/src/Program.cs b/intent_brokering/examples/applications/dog-mode-ui/src/Program.cs index 26313c7c..e63e22a9 100644 --- a/intent_brokering/examples/applications/dog-mode-ui/src/Program.cs +++ b/intent_brokering/examples/applications/dog-mode-ui/src/Program.cs @@ -9,9 +9,9 @@ using Grpc.Core; using Grpc.Net.Client; using Microsoft.AspNetCore.Mvc; -using ChariottCommon = Chariott.Common.V1; -using ChariottRuntime = Chariott.Runtime.V1; -using ChariottStreaming = Chariott.Streaming.V1; +using IntentBrokeringCommon = IntentBrokering.Common.V1; +using IntentBrokeringRuntime = IntentBrokering.Runtime.V1; +using IntentBrokeringStreaming = IntentBrokering.Streaming.V1; var clients = new ConcurrentList>(); @@ -24,7 +24,7 @@ builder.Services.AddSingleton>>(clients); builder.Services.AddSingleton(_ => new SocketsHttpHandler { EnableMultipleHttp2Connections = true }); -builder.Services.AddGrpcClient((sp, options) => +builder.Services.AddGrpcClient((sp, options) => { options.Address = new Uri("http://localhost:4243/"); // DevSkim: ignore DS162092 options.ChannelOptionsActions.Add(options => @@ -39,17 +39,17 @@ app.UseDefaultFiles(); app.UseStaticFiles(); -app.MapPost("/dog-mode", async (HttpContext context, [FromServices] ChariottRuntime.ChariottService.ChariottServiceClient client) => +app.MapPost("/dog-mode", async (HttpContext context, [FromServices] IntentBrokeringRuntime.IntentBrokeringService.IntentBrokeringServiceClient client) => { - _ = await client.FulfillAsync(new ChariottRuntime.FulfillRequest + _ = await client.FulfillAsync(new IntentBrokeringRuntime.FulfillRequest { Namespace = KeyValueStoreProperties.Namespace, - Intent = new ChariottCommon.Intent + Intent = new IntentBrokeringCommon.Intent { - Write = new ChariottCommon.WriteIntent + Write = new IntentBrokeringCommon.WriteIntent { Key = KeyValueStoreProperties.DogModeStatus, - Value = new ChariottCommon.Value { Bool = "on" == context.Request.Form["on"] } + Value = new IntentBrokeringCommon.Value { Bool = "on" == context.Request.Form["on"] } } } }); @@ -67,15 +67,15 @@ { var dataLine = obj switch { - ChariottStreaming.Event e => + IntentBrokeringStreaming.Event e => JsonSerializer.Serialize(new { id = e.Source, data = e.Value.ValueCase switch { - ChariottCommon.Value.ValueOneofCase.Int32 => (object)e.Value.Int32, - ChariottCommon.Value.ValueOneofCase.Bool => e.Value.Bool, - ChariottCommon.Value.ValueOneofCase.Blob => new { type = e.Value.Blob.MediaType, value = e.Value.Blob.Bytes.ToBase64() }, + IntentBrokeringCommon.Value.ValueOneofCase.Int32 => (object)e.Value.Int32, + IntentBrokeringCommon.Value.ValueOneofCase.Bool => e.Value.Bool, + IntentBrokeringCommon.Value.ValueOneofCase.Blob => new { type = e.Value.Blob.MediaType, value = e.Value.Blob.Bytes.ToBase64() }, _ => "Unsupported value type", } }), @@ -112,13 +112,13 @@ sealed class SdvEventReadingService : BackgroundService { - readonly ChariottRuntime.ChariottService.ChariottServiceClient _client; + readonly IntentBrokeringRuntime.IntentBrokeringService.IntentBrokeringServiceClient _client; readonly IEnumerable> _writers; readonly SocketsHttpHandler _httpHandler; readonly ILoggerFactory _loggerFactory; readonly ILogger _logger; - public SdvEventReadingService(ChariottRuntime.ChariottService.ChariottServiceClient client, + public SdvEventReadingService(IntentBrokeringRuntime.IntentBrokeringService.IntentBrokeringServiceClient client, IEnumerable> writers, SocketsHttpHandler httpHandler, ILoggerFactory loggerFactory, @@ -236,21 +236,21 @@ public void Add(IDisposable disposable) => public void Dispose() => _disposables.ForEach(d => d.Dispose()); } - async Task<(IDisposable, IAsyncEnumerable)> StreamAsync(string @namespace, IEnumerable sources, CancellationToken cancellationToken) + async Task<(IDisposable, IAsyncEnumerable)> StreamAsync(string @namespace, IEnumerable sources, CancellationToken cancellationToken) { var disposables = new DisposableList(); try { - var streamingAddressCandidates = await _client.FulfillAsync(new ChariottRuntime.FulfillRequest + var streamingAddressCandidates = await _client.FulfillAsync(new IntentBrokeringRuntime.FulfillRequest { Namespace = @namespace, - Intent = new ChariottCommon.Intent { Discover = new ChariottCommon.DiscoverIntent() } + Intent = new IntentBrokeringCommon.Intent { Discover = new IntentBrokeringCommon.DiscoverIntent() } }, cancellationToken: cancellationToken); var streamingAddress = streamingAddressCandidates.Fulfillment.Discover.Services - .First(s => s.SchemaReference == "chariott.streaming.v1" && s.SchemaKind == "grpc+proto") + .First(s => s.SchemaReference == "intent_brokering.streaming.v1" && s.SchemaKind == "grpc+proto") .Url; var channel = GrpcChannel.ForAddress(streamingAddress, new GrpcChannelOptions @@ -261,8 +261,8 @@ public void Add(IDisposable disposable) => disposables.Add(channel); - var streamingClient = new ChariottStreaming.ChannelService.ChannelServiceClient(channel); - var streamingCall = streamingClient.Open(new ChariottStreaming.OpenRequest(), cancellationToken: cancellationToken); + var streamingClient = new IntentBrokeringStreaming.ChannelService.ChannelServiceClient(channel); + var streamingCall = streamingClient.Open(new IntentBrokeringStreaming.OpenRequest(), cancellationToken: cancellationToken); disposables.Add(streamingCall); var channelId = (await streamingCall.GetResponseHeadersAsync(cancellationToken)).Get("x-chariott-channel-id")?.Value ?? throw new InvalidOperationException("Channel ID not present in response header."); @@ -274,12 +274,12 @@ public void Add(IDisposable disposable) => foreach (var writer in _writers) await writer.WriteAsync("connected", cancellationToken); - var rsr = await _client.FulfillAsync(new ChariottRuntime.FulfillRequest + var rsr = await _client.FulfillAsync(new IntentBrokeringRuntime.FulfillRequest { Namespace = @namespace, - Intent = new ChariottCommon.Intent + Intent = new IntentBrokeringCommon.Intent { - Subscribe = new ChariottCommon.SubscribeIntent + Subscribe = new IntentBrokeringCommon.SubscribeIntent { ChannelId = channelId, Sources = { sources } diff --git a/intent_brokering/examples/applications/invoke-command/Cargo.toml b/intent_brokering/examples/applications/invoke-command/Cargo.toml index 372858e4..94971e42 100644 --- a/intent_brokering/examples/applications/invoke-command/Cargo.toml +++ b/intent_brokering/examples/applications/invoke-command/Cargo.toml @@ -6,8 +6,8 @@ license = "MIT" [dependencies] async-trait = { workspace = true } -chariott-common = { workspace = true } -chariott-proto = { workspace = true } +intent_brokering_common = { workspace = true } +intent_brokering_proto = { workspace = true } ess = { path = "../../../ess/" } examples-common = { path = "../../common/" } keyvalue = { path = "../../../keyvalue/" } diff --git a/intent_brokering/examples/applications/invoke-command/README.md b/intent_brokering/examples/applications/invoke-command/README.md index 2b64e4ed..58525e24 100644 --- a/intent_brokering/examples/applications/invoke-command/README.md +++ b/intent_brokering/examples/applications/invoke-command/README.md @@ -5,18 +5,18 @@ It shows an example of a command that takes a json string as an input. ## Testing -Start Chariott followed by this application: +Start the Intent Brokering service followed by this application: ```bash -cargo run -p chariott & +cargo run -p intent_brokering & cargo run -p invoke-command & ``` Once both are up and running successfully, use the following to 'discover' -the provider. This will let you know that the provider is registered with Chariott: +the provider. This will let you know that the provider is registered with the Intent Brokering service: ```bash -grpcurl -plaintext -d @ 0.0.0.0:4243 chariott.runtime.v1.ChariottService/Fulfill < Self { Self { url } } @@ -61,7 +61,7 @@ impl ChariottProvider { } #[async_trait] -impl ProviderService for ChariottProvider { +impl ProviderService for IntentProvider { async fn fulfill( &self, request: Request, diff --git a/intent_brokering/examples/applications/invoke-command/src/main.rs b/intent_brokering/examples/applications/invoke-command/src/main.rs index 622836b9..111c29bf 100644 --- a/intent_brokering/examples/applications/invoke-command/src/main.rs +++ b/intent_brokering/examples/applications/invoke-command/src/main.rs @@ -2,25 +2,25 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -mod chariott_provider; +mod intent_provider; use std::sync::Arc; -use chariott_common::error::Error; -use chariott_common::shutdown::RouterExt as _; -use chariott_proto::{ +use examples_common::intent_brokering; +use intent_brokering_common::error::Error; +use intent_brokering_common::shutdown::RouterExt as _; +use intent_brokering_proto::{ provider::provider_service_server::ProviderServiceServer, runtime::{intent_registration::Intent, intent_service_registration::ExecutionLocality}, }; -use examples_common::chariott; use tonic::transport::Server; -use crate::chariott_provider::ChariottProvider; +use crate::intent_provider::IntentProvider; -chariott::provider::main!(wain); +intent_brokering::provider::main!(wain); async fn wain() -> Result<(), Error> { - let (url, socket_address) = chariott::provider::register( + let (url, socket_address) = intent_brokering::provider::register( "sdv.invoke.controller", "0.0.1", "sdv.invoke.controller", @@ -33,7 +33,7 @@ async fn wain() -> Result<(), Error> { tracing::info!("Application listening on: {url}"); - let provider = Arc::new(ChariottProvider::new(url.clone())); + let provider = Arc::new(IntentProvider::new(url.clone())); Server::builder() .add_service(ProviderServiceServer::from_arc(Arc::clone(&provider))) diff --git a/intent_brokering/examples/applications/invoke_object_detection.sh b/intent_brokering/examples/applications/invoke_object_detection.sh index c939f1fb..37154a0a 100755 --- a/intent_brokering/examples/applications/invoke_object_detection.sh +++ b/intent_brokering/examples/applications/invoke_object_detection.sh @@ -52,6 +52,6 @@ EOF grpcurl -plaintext --import-path ../../proto/ -import-path ./proto \ -use-reflection -proto ./proto/examples/detection/v1/detection.proto \ - -d @ "${CHARIOTT_ADDRESS:-0.0.0.0:4243}" \ - chariott.runtime.v1.ChariottService/Fulfill < <(echo "$REQ") \ + -d @ "${INTENT_BROKER_ADDRESS:-0.0.0.0:4243}" \ + intent_brokering.runtime.v1.IntentBrokeringService/Fulfill < <(echo "$REQ") \ | jq .fulfillment.invoke.return.any.entries diff --git a/intent_brokering/examples/applications/kv-app/Cargo.toml b/intent_brokering/examples/applications/kv-app/Cargo.toml index 9ea3550f..3c9bde1e 100644 --- a/intent_brokering/examples/applications/kv-app/Cargo.toml +++ b/intent_brokering/examples/applications/kv-app/Cargo.toml @@ -6,8 +6,8 @@ license = "MIT" [dependencies] async-trait = { workspace = true } -chariott-common = { workspace = true } -chariott-proto = { workspace = true } +intent_brokering_common = { workspace = true } +intent_brokering_proto = { workspace = true } ess = { path = "../../../ess/" } examples-common = { path = "../../common/" } keyvalue = { path = "../../../keyvalue/" } diff --git a/intent_brokering/examples/applications/kv-app/README.md b/intent_brokering/examples/applications/kv-app/README.md index 7ca4f3cd..96dcc5bc 100644 --- a/intent_brokering/examples/applications/kv-app/README.md +++ b/intent_brokering/examples/applications/kv-app/README.md @@ -7,18 +7,18 @@ channel. ## Testing -Start Chariott followed by this application: +Start the Intent Brokering Service followed by this application: ```bash -cargo run -p chariott & +cargo run -p intent_brokering & cargo run -p kv-app & ``` Once both are up and running successfully, use the following to write a -key-value pair to the store via Chariott: +key-value pair to the store via the Intent Brokering Service: ```bash -grpcurl -plaintext -d @ 0.0.0.0:4243 chariott.runtime.v1.ChariottService/Fulfill <; +pub type StreamingStore = intent_brokering::streaming::StreamingStore; -pub struct ChariottProvider { +pub struct IntentProvider { url: Url, streaming_store: Arc, } -impl ChariottProvider { +impl IntentProvider { pub fn new(url: Url, streaming_store: Arc) -> Self { Self { url, streaming_store } } @@ -42,7 +42,7 @@ impl ChariottProvider { } #[async_trait] -impl ProviderService for ChariottProvider { +impl ProviderService for IntentProvider { async fn fulfill( &self, request: Request, @@ -60,7 +60,7 @@ impl ProviderService for ChariottProvider { services: vec![Service { url: self.url.to_string(), schema_kind: "grpc+proto".to_owned(), - schema_reference: "chariott.streaming.v1".to_owned(), + schema_reference: "intent_brokering.streaming.v1".to_owned(), metadata: HashMap::new(), }], })), diff --git a/intent_brokering/examples/applications/kv-app/src/main.rs b/intent_brokering/examples/applications/kv-app/src/main.rs index f63ae371..de527109 100644 --- a/intent_brokering/examples/applications/kv-app/src/main.rs +++ b/intent_brokering/examples/applications/kv-app/src/main.rs @@ -2,26 +2,26 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -mod chariott_provider; +mod intent_provider; use std::sync::Arc; -use chariott_common::error::Error; -use chariott_common::shutdown::RouterExt as _; -use chariott_proto::{ +use examples_common::intent_brokering; +use intent_brokering_common::error::Error; +use intent_brokering_common::shutdown::RouterExt as _; +use intent_brokering_proto::{ provider::provider_service_server::ProviderServiceServer, runtime::{intent_registration::Intent, intent_service_registration::ExecutionLocality}, streaming::channel_service_server::ChannelServiceServer, }; -use examples_common::chariott; use tonic::transport::Server; -use crate::chariott_provider::{ChariottProvider, StreamingStore}; +use crate::intent_provider::{IntentProvider, StreamingStore}; -chariott::provider::main!(wain); +intent_brokering::provider::main!(wain); async fn wain() -> Result<(), Error> { - let (url, socket_address) = chariott::provider::register( + let (url, socket_address) = intent_brokering::provider::register( "sdv.key-value-store", "0.0.1", "sdv.kvs", @@ -35,7 +35,7 @@ async fn wain() -> Result<(), Error> { tracing::info!("Application listening on: {url}"); let streaming_store = Arc::new(StreamingStore::new()); - let provider = Arc::new(ChariottProvider::new(url.clone(), Arc::clone(&streaming_store))); + let provider = Arc::new(IntentProvider::new(url.clone(), Arc::clone(&streaming_store))); Server::builder() .add_service(ProviderServiceServer::from_arc(Arc::clone(&provider))) diff --git a/intent_brokering/examples/applications/local-object-detection/Cargo.toml b/intent_brokering/examples/applications/local-object-detection/Cargo.toml index ebda4f09..e67ba535 100644 --- a/intent_brokering/examples/applications/local-object-detection/Cargo.toml +++ b/intent_brokering/examples/applications/local-object-detection/Cargo.toml @@ -6,8 +6,8 @@ license = "MIT" [dependencies] async-trait = { workspace = true } -chariott-common = { workspace = true } -chariott-proto = { workspace = true } +intent_brokering_common = { workspace = true } +intent_brokering_proto = { workspace = true } examples-common = { path = "../../common/" } image = "0.24.8" lazy_static = { workspace = true } diff --git a/intent_brokering/examples/applications/local-object-detection/README.md b/intent_brokering/examples/applications/local-object-detection/README.md index 396fc328..22237c61 100644 --- a/intent_brokering/examples/applications/local-object-detection/README.md +++ b/intent_brokering/examples/applications/local-object-detection/README.md @@ -5,7 +5,7 @@ TensorFlow and ssd_mobilenet_v1_coco model. To run the application: -1. Start chariott runtime by executing `cargo run` from the root directory +1. Start the Intent Brokering runtime by executing `cargo run -p intent_brokering` 2. Start detection application by executing `cargo run` from the `intent_brokering/examples/applications/local-object-detection` directory. 3. In the root directory create a `detect_image.json` file with the following @@ -36,5 +36,5 @@ To run the application: 4. Execute detection with `grpcurl -v -plaintext -import-path proto/ \ -import-path intent_brokering/examples/applications/proto -use-reflection -proto \ intent_brokering/examples/applications/proto/examples/detection/v1/detection.proto -d @ \ - localhost:4243 chariott.runtime.v1.ChariottService/Fulfill < \ + localhost:4243 intent_brokering.runtime.v1.IntentBrokeringService/Fulfill < \ detect_image.json` diff --git a/intent_brokering/examples/applications/local-object-detection/src/detection.rs b/intent_brokering/examples/applications/local-object-detection/src/detection.rs index 11e3cae8..aa7870c3 100644 --- a/intent_brokering/examples/applications/local-object-detection/src/detection.rs +++ b/intent_brokering/examples/applications/local-object-detection/src/detection.rs @@ -2,9 +2,9 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -use chariott_common::error::Error; use examples_common::examples::detection::{DetectRequest, DetectResponse, DetectionObject}; use image::{io::Reader, DynamicImage, GenericImageView}; +use intent_brokering_common::error::Error; use ndarray::prelude::Array; use serde::{Deserialize, Serialize}; use std::{ diff --git a/intent_brokering/examples/applications/local-object-detection/src/chariott_provider.rs b/intent_brokering/examples/applications/local-object-detection/src/intent_provider.rs similarity index 92% rename from intent_brokering/examples/applications/local-object-detection/src/chariott_provider.rs rename to intent_brokering/examples/applications/local-object-detection/src/intent_provider.rs index 38c43559..7112b8df 100644 --- a/intent_brokering/examples/applications/local-object-detection/src/chariott_provider.rs +++ b/intent_brokering/examples/applications/local-object-detection/src/intent_provider.rs @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT use async_trait::async_trait; -use chariott_proto::{ +use intent_brokering_proto::{ common::{FulfillmentEnum, FulfillmentMessage, IntentEnum}, provider::{provider_service_server::ProviderService, FulfillRequest, FulfillResponse}, }; @@ -13,15 +13,15 @@ use tracing::error; use crate::detection::DetectionLogic; use examples_common::{ - chariott::inspection::{fulfill, Entry}, examples::detection::DetectRequest, + intent_brokering::inspection::{fulfill, Entry}, }; -pub struct ChariottProvider { +pub struct IntentProvider { internal_logic: DetectionLogic, } -impl ChariottProvider { +impl IntentProvider { pub fn new() -> Self { let internal_logic = DetectionLogic::new(); Self { internal_logic } @@ -39,7 +39,7 @@ lazy_static::lazy_static! { } #[async_trait] -impl ProviderService for ChariottProvider { +impl ProviderService for IntentProvider { async fn fulfill( &self, request: Request, diff --git a/intent_brokering/examples/applications/local-object-detection/src/main.rs b/intent_brokering/examples/applications/local-object-detection/src/main.rs index 5b9be3c0..7f691860 100644 --- a/intent_brokering/examples/applications/local-object-detection/src/main.rs +++ b/intent_brokering/examples/applications/local-object-detection/src/main.rs @@ -2,24 +2,24 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -mod chariott_provider; mod detection; +mod intent_provider; -use chariott_common::error::Error; -use chariott_common::shutdown::RouterExt as _; -use chariott_proto::{ +use examples_common::intent_brokering; +use intent_brokering_common::error::Error; +use intent_brokering_common::shutdown::RouterExt as _; +use intent_brokering_proto::{ provider::provider_service_server::ProviderServiceServer, runtime::{intent_registration::Intent, intent_service_registration::ExecutionLocality}, }; -use examples_common::chariott; use tonic::transport::Server; -use crate::chariott_provider::ChariottProvider; +use crate::intent_provider::IntentProvider; -chariott::provider::main!(wain); +intent_brokering::provider::main!(wain); async fn wain() -> Result<(), Error> { - let (url, socket_address) = chariott::provider::register( + let (url, socket_address) = intent_brokering::provider::register( "sdv.local-detection", "0.0.1", "sdv.detection", @@ -33,7 +33,7 @@ async fn wain() -> Result<(), Error> { tracing::info!("Application application listening: {url}"); Server::builder() - .add_service(ProviderServiceServer::new(ChariottProvider::new())) + .add_service(ProviderServiceServer::new(IntentProvider::new())) .serve_with_ctrl_c_shutdown(socket_address) .await } diff --git a/intent_brokering/examples/applications/lt-consumer/Cargo.toml b/intent_brokering/examples/applications/lt-consumer/Cargo.toml index f3fd6e3d..eec2c0b6 100644 --- a/intent_brokering/examples/applications/lt-consumer/Cargo.toml +++ b/intent_brokering/examples/applications/lt-consumer/Cargo.toml @@ -6,7 +6,7 @@ license = "MIT" [dependencies] bollard = "0.15" -chariott-common = { workspace = true } +intent_brokering_common = { workspace = true } examples-common = { path = "../../common/" } futures = { workspace = true } futures-util = "0.3" diff --git a/intent_brokering/examples/applications/lt-consumer/src/main.rs b/intent_brokering/examples/applications/lt-consumer/src/main.rs index 8be76354..a980fb7d 100644 --- a/intent_brokering/examples/applications/lt-consumer/src/main.rs +++ b/intent_brokering/examples/applications/lt-consumer/src/main.rs @@ -3,16 +3,16 @@ // SPDX-License-Identifier: MIT use bollard::{container::StatsOptions, Docker}; -use chariott_common::{ - config::env, - error::{Error, ResultExt}, -}; -use examples_common::chariott::{ +use examples_common::intent_brokering::{ self, - api::{Chariott, GrpcChariott}, + api::{GrpcIntentBrokering, IntentBrokering}, value::Value, }; use futures_util::stream::StreamExt; +use intent_brokering_common::{ + config::env, + error::{Error, ResultExt}, +}; use metrics_util::Summary; use serde::Serialize; use std::{ @@ -28,7 +28,7 @@ use std::{ use tokio::time::{sleep, sleep_until}; use tracing::{debug, error, info, warn}; -const CHARIOTT_CONTAINER_NAME: &str = "chariott"; +const INTENT_BROKERING_CONTAINER_NAME: &str = "intent_brokering"; const LT_PROVIDER_NAMESPACE: &str = "lt.provider"; // How many invoke fulfillments to schedule. @@ -50,7 +50,7 @@ const RESULT_FILE: &str = "lt-output/app.out"; const RESULT_FILE_DOCKER: &str = "lt-output/docker.out"; const SAMPLE_RATE: u64 = 50; -chariott::provider::main!(wain); +intent_brokering::provider::main!(wain); async fn wain() -> Result<(), Error> { let invoke_count: u64 = env(TARGET_INVOKE_COUNT_ENV).unwrap(); @@ -58,7 +58,7 @@ async fn wain() -> Result<(), Error> { let collect_docker_stats = env(COLLECT_DOCKER_STATS_ENV).unwrap_or(false); let chunk_execution_duration = Duration::from_millis(1_000 * CHUNK_SIZE / target_rate as u64); - let chariott = GrpcChariott::connect().await?; + let intent_broker = GrpcIntentBrokering::connect().await?; let latency_metric = Arc::new(Mutex::new(Summary::with_defaults())); let invoke_fulfillments = Arc::new(AtomicUsize::new(0)); @@ -99,7 +99,7 @@ async fn wain() -> Result<(), Error> { break; } - let mut chariott = chariott.clone(); + let mut intent_broker = intent_broker.clone(); let latency_metric = Arc::clone(&latency_metric); let invoke_fulfillments = Arc::clone(&invoke_fulfillments); @@ -109,7 +109,8 @@ async fn wain() -> Result<(), Error> { // Only the namespace matters when invoking. The load testing // provider will not take action based on payload or command. - let sent_value = chariott.invoke(LT_PROVIDER_NAMESPACE, "foo", [Value::NULL]).await; + let sent_value = + intent_broker.invoke(LT_PROVIDER_NAMESPACE, "foo", [Value::NULL]).await; if let Some(request_instant) = now { let latency = request_instant.elapsed().as_millis() as _; @@ -200,7 +201,7 @@ async fn evaluate_docker_stats( let docker = Docker::connect_with_local_defaults() .map_err_with("could not connect with defaults to docker")?; let mut stats = docker.stats( - CHARIOTT_CONTAINER_NAME, + INTENT_BROKERING_CONTAINER_NAME, Some(StatsOptions { stream: true, ..Default::default() }), ); diff --git a/intent_brokering/examples/applications/lt-provider/Cargo.toml b/intent_brokering/examples/applications/lt-provider/Cargo.toml index 2178f993..2d1ff8b2 100644 --- a/intent_brokering/examples/applications/lt-provider/Cargo.toml +++ b/intent_brokering/examples/applications/lt-provider/Cargo.toml @@ -5,8 +5,8 @@ edition = "2021" license = "MIT" [dependencies] -chariott-common = { workspace = true } -chariott-proto = { workspace = true } +intent_brokering_common = { workspace = true } +intent_brokering_proto = { workspace = true } examples-common = { path = "../../common/" } rand = "0.8" rand_distr = "0.4" diff --git a/intent_brokering/examples/applications/lt-provider/src/main.rs b/intent_brokering/examples/applications/lt-provider/src/main.rs index ee70e593..81047246 100644 --- a/intent_brokering/examples/applications/lt-provider/src/main.rs +++ b/intent_brokering/examples/applications/lt-provider/src/main.rs @@ -7,11 +7,13 @@ use std::{ time::Duration, }; -use chariott_common::{ +use examples_common::intent_brokering; +use examples_common::intent_brokering::value::Value; +use intent_brokering_common::{ config::env, error::{Error, ResultExt as _}, }; -use chariott_proto::{ +use intent_brokering_proto::{ common::{FulfillmentEnum, FulfillmentMessage, IntentEnum, InvokeFulfillment}, provider::{ provider_service_server::{ProviderService, ProviderServiceServer}, @@ -19,8 +21,6 @@ use chariott_proto::{ }, runtime::{intent_registration::Intent, intent_service_registration::ExecutionLocality}, }; -use examples_common::chariott; -use examples_common::chariott::value::Value; use rand::{rngs::SmallRng, SeedableRng}; use rand_distr::{DistIter, Distribution, Normal}; use tokio::time::sleep; @@ -34,10 +34,10 @@ const LATENCY_MEAN_ENV: &str = "LATENCY_MEAN"; // Standard deviation of latency distribution in milliseconds. const LATENCY_STD_DEV_ENV: &str = "LATENCY_STD_DEV"; -chariott::provider::main!(wain); +intent_brokering::provider::main!(wain); async fn wain() -> Result<(), Error> { - let (url, socket_address) = chariott::provider::register( + let (url, socket_address) = intent_brokering::provider::register( "lt.provider", "0.0.1", "lt.provider", @@ -51,8 +51,8 @@ async fn wain() -> Result<(), Error> { info!("LT provider listening: {url}"); let provider = match (env(LATENCY_MEAN_ENV), env(LATENCY_STD_DEV_ENV)) { - (Some(mean), Some(std_dev)) => ChariottProvider::normal(mean, std_dev), - (_, _) => ChariottProvider::new(), + (Some(mean), Some(std_dev)) => IntentProvider::normal(mean, std_dev), + (_, _) => IntentProvider::new(), }; Server::builder() @@ -64,11 +64,11 @@ async fn wain() -> Result<(), Error> { type Rand = Arc, SmallRng, f32>>>; -struct ChariottProvider { +struct IntentProvider { latency_distribution: Option, } -impl ChariottProvider { +impl IntentProvider { pub fn new() -> Self { info!("No simulation of response latencies, responding immediately."); Self { latency_distribution: None } @@ -90,7 +90,7 @@ impl ChariottProvider { } #[async_trait] -impl ProviderService for ChariottProvider { +impl ProviderService for IntentProvider { async fn fulfill( &self, request: Request, diff --git a/intent_brokering/examples/applications/mock-vas/Cargo.toml b/intent_brokering/examples/applications/mock-vas/Cargo.toml index 1a31f5e8..abc8551b 100644 --- a/intent_brokering/examples/applications/mock-vas/Cargo.toml +++ b/intent_brokering/examples/applications/mock-vas/Cargo.toml @@ -8,8 +8,8 @@ license = "MIT" anyhow = { workspace = true } async-std = "1.12" async-trait = { workspace = true } -chariott-common = { workspace = true } -chariott-proto = { workspace = true } +intent_brokering_common = { workspace = true } +intent_brokering_proto = { workspace = true } ess = { path = "../../../ess/" } examples-common = { path = "../../common/" } futures = { workspace = true } @@ -27,7 +27,7 @@ uuid = { workspace = true } [dev-dependencies] async-trait = { workspace = true } -chariott-common = { path = "../../../common/" } +intent_brokering_common = { path = "../../../common/" } env_logger = "*" test-log = "0.2.14" tokio-test = "0.4.3" diff --git a/intent_brokering/examples/applications/mock-vas/README.md b/intent_brokering/examples/applications/mock-vas/README.md index 61b8b808..dc781a1a 100644 --- a/intent_brokering/examples/applications/mock-vas/README.md +++ b/intent_brokering/examples/applications/mock-vas/README.md @@ -4,7 +4,7 @@ This code sample shows you how to use the mocked VAS for the dog mode scenario. The dog mode allows a car owner to keep their dog safe, while they are away from the car. -## How-to consume a streaming service using Chariott +## How-to consume a streaming service using Chariott Intent Broker > As an application developer, I want to consume events from a streaming > service. @@ -15,17 +15,17 @@ using [gRPCurl](https://github.com/fullstorydev/grpcurl) calls from the command From the root directory: -1. In a terminal (A) start Chariott with `cargo run`. +1. In a terminal (A) start Intent Brokering with `cargo run -p intent_brokering`. 2. In another terminal (B) start the mock-vas with `cargo run -p mock-vas`. 3. In a terminal (C), open a channel to the mock-vas with `grpcurl -v -plaintext \ - -import-path proto -proto proto/chariott/streaming/v1/streaming.proto \ - localhost:50051 chariott.streaming.v1.ChannelService/Open` and take a note of + -import-path proto -proto proto/intent_brokering/streaming/v1/streaming.proto \ + localhost:50051 intent_brokering.streaming.v1.ChannelService/Open` and take a note of the returned channel id in the metadata _x-chariott-channel-id_. 4. In another terminal D call the following, using the channel id from the previous step: ```shell - grpcurl -v -plaintext -d @ localhost:4243 chariott.runtime.v1.ChariottService/Fulfill < Result<(), Error> { let streaming_store = Arc::new(StreamingStore::new()); let simulation = VehicleSimulation::new(Arc::clone(&streaming_store)); - let provider = ChariottProvider::new(url, simulation.clone(), Arc::clone(&streaming_store)); + let provider = IntentProvider::new(url, simulation.clone(), Arc::clone(&streaming_store)); let cancellation_token = ctrl_c_cancellation(); let server_token = cancellation_token.child_token(); diff --git a/intent_brokering/examples/applications/mock-vas/src/chariott_provider.rs b/intent_brokering/examples/applications/mock-vas/src/intent_provider.rs similarity index 89% rename from intent_brokering/examples/applications/mock-vas/src/chariott_provider.rs rename to intent_brokering/examples/applications/mock-vas/src/intent_provider.rs index 2bb2bbe4..e0720880 100644 --- a/intent_brokering/examples/applications/mock-vas/src/chariott_provider.rs +++ b/intent_brokering/examples/applications/mock-vas/src/intent_provider.rs @@ -7,17 +7,17 @@ use std::sync::Arc; use std::vec; use async_trait::async_trait; -use chariott_proto::{ +use examples_common::intent_brokering; +use examples_common::intent_brokering::inspection::{fulfill, Entry}; +use examples_common::intent_brokering::streaming::ProtoExt as _; +use examples_common::intent_brokering::value::Value; +use intent_brokering_proto::{ common::{ discover_fulfillment::Service, DiscoverFulfillment, FulfillmentEnum, FulfillmentMessage, IntentEnum, InvokeFulfillment, ValueMessage, }, provider::{provider_service_server::ProviderService, FulfillRequest, FulfillResponse}, }; -use examples_common::chariott; -use examples_common::chariott::inspection::{fulfill, Entry}; -use examples_common::chariott::streaming::ProtoExt as _; -use examples_common::chariott::value::Value; use tonic::{Request, Response, Status}; use url::Url; @@ -30,18 +30,18 @@ pub const ACTIVATE_AIR_CONDITIONING_COMMAND: &str = "Vehicle.Cabin.HVAC.IsAirCon pub const SEND_NOTIFICATION_COMMAND: &str = "send_notification"; pub const SET_UI_MESSAGE_COMMAND: &str = "set_ui_message"; -const SCHEMA_VERSION_STREAMING: &str = "chariott.streaming.v1"; +const SCHEMA_VERSION_STREAMING: &str = "intent_brokering.streaming.v1"; const SCHEMA_REFERENCE: &str = "grpc+proto"; -pub type StreamingStore = chariott::streaming::StreamingStore; +pub type StreamingStore = intent_brokering::streaming::StreamingStore; -pub struct ChariottProvider { +pub struct IntentProvider { url: Url, vehicle_simulation: VehicleSimulation, streaming_store: Arc, } -impl ChariottProvider { +impl IntentProvider { pub fn new( url: Url, simulation: VehicleSimulation, @@ -80,7 +80,7 @@ fn command(path: &str, r#type: &str) -> Entry { } #[async_trait] -impl ProviderService for ChariottProvider { +impl ProviderService for IntentProvider { async fn fulfill( &self, request: Request, diff --git a/intent_brokering/examples/applications/mock-vas/src/main.rs b/intent_brokering/examples/applications/mock-vas/src/main.rs index 533c2d3d..ac1339d5 100644 --- a/intent_brokering/examples/applications/mock-vas/src/main.rs +++ b/intent_brokering/examples/applications/mock-vas/src/main.rs @@ -2,20 +2,20 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -mod chariott_provider; mod communication; +mod intent_provider; mod simulation; -use chariott_common::error::Error; -use chariott_proto::runtime::{ +use examples_common::intent_brokering; +use intent_brokering_common::error::Error; +use intent_brokering_proto::runtime::{ intent_registration::Intent, intent_service_registration::ExecutionLocality, }; -use examples_common::chariott; -chariott::provider::main!(wain); +intent_brokering::provider::main!(wain); async fn wain() -> Result<(), Error> { - let (url, socket_address) = chariott::provider::register( + let (url, socket_address) = intent_brokering::provider::register( "sdv.mock-vas", "0.0.1", "sdv.vdt", diff --git a/intent_brokering/examples/applications/mock-vas/src/simulation.rs b/intent_brokering/examples/applications/mock-vas/src/simulation.rs index fa36bb72..3e79c0d5 100644 --- a/intent_brokering/examples/applications/mock-vas/src/simulation.rs +++ b/intent_brokering/examples/applications/mock-vas/src/simulation.rs @@ -2,14 +2,14 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -use chariott_common::error::{Error, ResultExt}; -use examples_common::chariott::value::Value; +use examples_common::intent_brokering::value::Value; +use intent_brokering_common::error::{Error, ResultExt}; use std::{env, sync::Arc}; use tokio::sync::broadcast::{self, Sender}; use tokio_util::sync::CancellationToken; use tracing::{debug, info}; -use crate::chariott_provider::{ +use crate::intent_provider::{ StreamingStore, ACTIVATE_AIR_CONDITIONING_COMMAND, AIR_CONDITIONING_STATE_PROPERTY, BATTERY_LEVEL_PROPERTY, CABIN_TEMPERATURE_PROPERTY, SEND_NOTIFICATION_COMMAND, SET_UI_MESSAGE_COMMAND, diff --git a/intent_brokering/examples/applications/proto/examples/detection/v1/detection.proto b/intent_brokering/examples/applications/proto/examples/detection/v1/detection.proto index ff9b6156..1b89b3bd 100644 --- a/intent_brokering/examples/applications/proto/examples/detection/v1/detection.proto +++ b/intent_brokering/examples/applications/proto/examples/detection/v1/detection.proto @@ -6,10 +6,10 @@ syntax = "proto3"; package examples.detection.v1; -import "chariott/common/v1/common.proto"; +import "intent_brokering/common/v1/common.proto"; message DetectRequest { - chariott.common.v1.Blob blob = 1; + intent_brokering.common.v1.Blob blob = 1; } message DetectResponse { diff --git a/intent_brokering/examples/applications/run_demo.sh b/intent_brokering/examples/applications/run_demo.sh index db8908e5..8abc30a4 100755 --- a/intent_brokering/examples/applications/run_demo.sh +++ b/intent_brokering/examples/applications/run_demo.sh @@ -7,7 +7,7 @@ set -e cd "$(dirname "$0")/../../.." if [[ "$1" == "-h" || "$1" == "--help" ]]; then - echo 'Run Chariott demo. + echo 'Run Intent Brokering DogMode demo. This script allows you to specify the following parameters: @@ -37,7 +37,7 @@ trap cleanup SIGINT cleanup() { echo>&2 "Stopping applications..." - pkill chariott || true + pkill intent_brokering || true pkill kv-app || true pkill dog-mode-logic-app || true pkill DogModeDashboard || true @@ -56,7 +56,7 @@ fi cargo build --workspace -./target/debug/chariott > target/logs/chariott.txt 2>&1 & +cargo run -p intent_brokering > target/logs/intent_brokering.txt 2>&1 & sleep 2 diff --git a/intent_brokering/examples/applications/simple-provider/Cargo.toml b/intent_brokering/examples/applications/simple-provider/Cargo.toml index 297d4513..94031ec6 100644 --- a/intent_brokering/examples/applications/simple-provider/Cargo.toml +++ b/intent_brokering/examples/applications/simple-provider/Cargo.toml @@ -6,8 +6,8 @@ license = "MIT" [dependencies] async-trait = { workspace = true } -chariott-common = { workspace = true } -chariott-proto = { workspace = true } +intent_brokering_common = { workspace = true } +intent_brokering_proto = { workspace = true } ess = { path = "../../../ess/" } examples-common = { path = "../../common/" } keyvalue = { path = "../../../keyvalue/" } diff --git a/intent_brokering/examples/applications/simple-provider/README.md b/intent_brokering/examples/applications/simple-provider/README.md index 34402e28..6fe5659c 100644 --- a/intent_brokering/examples/applications/simple-provider/README.md +++ b/intent_brokering/examples/applications/simple-provider/README.md @@ -1,21 +1,21 @@ # Simple Provider Example -This is an example Chariott provider that shows how to register a provider with chariott. +This is an example Intent provider that shows how to register a provider with the Intent Brokering service. ## Testing -Start Chariott followed by this application: +Start the Intent Brokering service followed by this application: ```bash -cargo run -p chariott & +cargo run -p intent_brokering & cargo run -p simple-provider & ``` Once both are up and running successfully, use the following to 'discover' -the provider. This will let you know that the provider is registered with Chariott: +the provider. This will let you know that the provider is registered with the Intent Brokering service: ```bash -grpcurl -plaintext -d @ 0.0.0.0:4243 chariott.runtime.v1.ChariottService/Fulfill < Self { Self { url } } } #[async_trait] -impl ProviderService for ChariottProvider { +impl ProviderService for IntentProvider { async fn fulfill( &self, request: Request, diff --git a/intent_brokering/examples/applications/simple-provider/src/main.rs b/intent_brokering/examples/applications/simple-provider/src/main.rs index 76041654..e5211050 100644 --- a/intent_brokering/examples/applications/simple-provider/src/main.rs +++ b/intent_brokering/examples/applications/simple-provider/src/main.rs @@ -2,28 +2,28 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -mod chariott_provider; +mod intent_provider; use std::{net::SocketAddr, sync::Arc, time::Duration}; use url::Url; -use chariott_common::error::Error; -use chariott_common::shutdown::RouterExt as _; -use chariott_proto::{ +use examples_common::intent_brokering; +use intent_brokering_common::error::Error; +use intent_brokering_common::shutdown::RouterExt as _; +use intent_brokering_proto::{ provider::provider_service_server::ProviderServiceServer, runtime::{ - chariott_service_client::ChariottServiceClient, intent_registration::Intent, + intent_brokering_service_client::IntentBrokeringServiceClient, intent_registration::Intent, intent_service_registration::ExecutionLocality, AnnounceRequest, IntentRegistration, IntentServiceRegistration, RegisterRequest, RegistrationState, }, }; -use examples_common::chariott; use tokio::time::sleep; use tonic::transport::{Channel, Server}; use tracing::warn; -use crate::chariott_provider::ChariottProvider; +use crate::intent_provider::IntentProvider; #[derive(Clone)] struct RegisterParams { @@ -32,29 +32,30 @@ struct RegisterParams { version: String, intents: Vec, url: String, - chariott_url: String, + intent_brokering_url: String, locality: ExecutionLocality, } -async fn connect_chariott_client( - client: &mut Option>, - chariott_url: String, +async fn connect_intent_brokering_client( + client: &mut Option>, + intent_brokering_url: String, ) -> Result<(), Error> { - *client = Some(ChariottServiceClient::connect(chariott_url).await.map_err(|e| { - *client = None; // Set client back to None on error. - Error::from_error("Could not connect to client", Box::new(e)) - })?); + *client = + Some(IntentBrokeringServiceClient::connect(intent_brokering_url).await.map_err(|e| { + *client = None; // Set client back to None on error. + Error::from_error("Could not connect to client", Box::new(e)) + })?); Ok(()) } async fn register_and_announce_once( - client: &mut Option>, + client: &mut Option>, reg_params: RegisterParams, ) -> Result<(), Error> { // If there is no client, need to attempt connection. if client.is_none() { - connect_chariott_client(client, reg_params.chariott_url).await?; + connect_intent_brokering_client(client, reg_params.intent_brokering_url).await?; } let service = Some(IntentServiceRegistration { @@ -66,19 +67,19 @@ async fn register_and_announce_once( let announce_req = AnnounceRequest { service: service.clone() }; - // Always announce to Chariott. + // Always announce to IntentBrokering. let registration_state = client .as_mut() .expect("No client found") .announce(announce_req.clone()) .await - .map_err(|e| Error::from_error("Error announcing to Chariott.", Box::new(e)))? + .map_err(|e| Error::from_error("Error announcing to IntentBrokering.", Box::new(e)))? .into_inner() .registration_state; - // Only attempt registration with Chariott if the announced state is 'ANNOUNCED'. - // The 'ANNOUNCED' state means that this service is not currently registered in Chariott. - // This also handles re-registration if Chariott crashes and comes back online. + // Only attempt registration with IntentBrokering if the announced state is 'ANNOUNCED'. + // The 'ANNOUNCED' state means that this service is not currently registered in IntentBrokering. + // This also handles re-registration if IntentBrokering crashes and comes back online. if registration_state == RegistrationState::Announced as i32 { let register_req = RegisterRequest { service: service.clone(), @@ -92,14 +93,16 @@ async fn register_and_announce_once( .collect(), }; - tracing::info!("Registered with Chariott runtime: {:?}", register_req); + tracing::info!("Registered with IntentBrokering runtime: {:?}", register_req); _ = client .as_mut() .expect("No client found") .register(register_req.clone()) .await - .map_err(|e| Error::from_error("Error registering with Chariott.", Box::new(e)))?; + .map_err(|e| { + Error::from_error("Error registering with IntentBrokering.", Box::new(e)) + })?; } Ok(()) @@ -131,11 +134,11 @@ async fn register_and_announce_provider( } // This macro sets up tracing and exit code handling. -chariott::provider::main!(wain); +intent_brokering::provider::main!(wain); async fn wain() -> Result<(), Error> { - // Intitialize addresses for provider and chariott communication. - let chariott_url = "http://0.0.0.0:4243".to_string(); // DevSkim: ignore DS137138 + // Intitialize addresses for provider and intent_brokering communication. + let intent_brokering_url = "http://0.0.0.0:4243".to_string(); // DevSkim: ignore DS137138 let base_provider_address = "0.0.0.0:50064".to_string(); let provider_url_str = format!("http://{}", base_provider_address.clone()); // DevSkim: ignore DS137138 let socket_address: SocketAddr = base_provider_address @@ -151,7 +154,7 @@ async fn wain() -> Result<(), Error> { version: "0.0.1".to_string(), intents: [Intent::Discover].to_vec(), url: provider_url_str.clone(), - chariott_url, + intent_brokering_url, locality: ExecutionLocality::Local, }; @@ -160,7 +163,7 @@ async fn wain() -> Result<(), Error> { tracing::info!("Application listening on: {provider_url_str}"); - let provider = Arc::new(ChariottProvider::new(provider_url.clone())); + let provider = Arc::new(IntentProvider::new(provider_url.clone())); Server::builder() .add_service(ProviderServiceServer::from_arc(Arc::clone(&provider))) diff --git a/intent_brokering/examples/applications/simulated-camera/Cargo.toml b/intent_brokering/examples/applications/simulated-camera/Cargo.toml index bb6ed2a5..a3cedab9 100644 --- a/intent_brokering/examples/applications/simulated-camera/Cargo.toml +++ b/intent_brokering/examples/applications/simulated-camera/Cargo.toml @@ -9,8 +9,8 @@ anyhow = { workspace = true } async-std = "1.12" async-stream = "0.3.3" async-trait = { workspace = true } -chariott-common = { workspace = true } -chariott-proto = { workspace = true } +intent_brokering_common = { workspace = true } +intent_brokering_proto = { workspace = true } ess = { path = "../../../ess/" } keyvalue = { path = "../../../keyvalue/" } examples-common = { path = "../../common/" } diff --git a/intent_brokering/examples/applications/simulated-camera/README.md b/intent_brokering/examples/applications/simulated-camera/README.md index fd5df7cb..208ba063 100644 --- a/intent_brokering/examples/applications/simulated-camera/README.md +++ b/intent_brokering/examples/applications/simulated-camera/README.md @@ -7,22 +7,22 @@ manual mode where you specify the frame rate event yourself. ## To run the application -1. Start chariott runtime by executing `cargo run -p chariott` from the root directory +1. Start the Intent Brokering runtime by executing `cargo run -p intent_brokering` from the root directory 2. Navigate to `intent_brokering/examples/applications/simulated-camera` directory -3. Create a `images` directory and place there all the `.jpg` files you want the +3. Create an `images` directory and place there all the `.jpg` files you want the camera application to stream 4. Start camera application by executing `cargo run` from the `intent_brokering/examples/applications/simulated-camera` directory. 5. In another terminal, open a channel to the simulated-camera with `grpcurl -v \ -plaintext -import-path proto -proto \ - intent_brokering/proto/chariott/streaming/v1/streaming.proto localhost:50066 \ - chariott.streaming.v1.ChannelService/Open` and take a note of the returned + intent_brokering/proto/intent_brokering/streaming/v1/streaming.proto localhost:50066 \ + intent_brokering.streaming.v1.ChannelService/Open` and take a note of the returned channel id in the metadata _x-chariott-channel-id_. 6. In yet another terminal, call the following, using the channel id from the previous step: ```shell - grpcurl -v -plaintext -d @ localhost:4243 chariott.runtime.v1.ChariottService/Fulfill <, diff --git a/intent_brokering/examples/applications/simulated-camera/src/communication.rs b/intent_brokering/examples/applications/simulated-camera/src/communication.rs index 02240236..6b681f8a 100644 --- a/intent_brokering/examples/applications/simulated-camera/src/communication.rs +++ b/intent_brokering/examples/applications/simulated-camera/src/communication.rs @@ -5,22 +5,22 @@ use std::sync::Arc; use std::{env::args, net::SocketAddr}; -use chariott_common::{ +use futures::future::join_all; +use intent_brokering_common::{ error::{Error, ResultExt as _}, shutdown::{ctrl_c_cancellation, RouterExt as _}, }; -use chariott_proto::{ +use intent_brokering_proto::{ provider::provider_service_server::ProviderServiceServer, streaming::channel_service_server::ChannelServiceServer, }; -use futures::future::join_all; use tokio::spawn; use tonic::transport::Server; use url::Url; use crate::{ camera::CameraLogic, - chariott_provider::{ChariottProvider, StreamingStore}, + intent_provider::{IntentProvider, StreamingStore}, }; pub async fn serve(url: Url, address: SocketAddr) -> Result<(), Error> { @@ -44,7 +44,7 @@ pub async fn serve(url: Url, address: SocketAddr) -> Result<(), Error> { let server_handle = spawn( Server::builder() - .add_service(ProviderServiceServer::new(ChariottProvider::new( + .add_service(ProviderServiceServer::new(IntentProvider::new( url, Arc::clone(&streaming_store), ))) diff --git a/intent_brokering/examples/applications/simulated-camera/src/chariott_provider.rs b/intent_brokering/examples/applications/simulated-camera/src/intent_provider.rs similarity index 88% rename from intent_brokering/examples/applications/simulated-camera/src/chariott_provider.rs rename to intent_brokering/examples/applications/simulated-camera/src/intent_provider.rs index 924f975f..8937e46e 100644 --- a/intent_brokering/examples/applications/simulated-camera/src/chariott_provider.rs +++ b/intent_brokering/examples/applications/simulated-camera/src/intent_provider.rs @@ -6,7 +6,7 @@ use std::collections::HashMap; use std::sync::Arc; use async_trait::async_trait; -use chariott_proto::{ +use intent_brokering_proto::{ common::{ discover_fulfillment::Service, intent::Intent, DiscoverFulfillment, FulfillmentEnum, FulfillmentMessage, @@ -16,24 +16,24 @@ use chariott_proto::{ use tonic::{Request, Response, Status}; use url::Url; -use examples_common::chariott::{ +use examples_common::intent_brokering::{ self, inspection::{fulfill, Entry}, streaming::ProtoExt as _, value::Value, }; -pub type StreamingStore = chariott::streaming::StreamingStore; +pub type StreamingStore = intent_brokering::streaming::StreamingStore; -const SCHEMA_VERSION_STREAMING: &str = "chariott.streaming.v1"; +const SCHEMA_VERSION_STREAMING: &str = "intent_brokering.streaming.v1"; const SCHEMA_REFERENCE: &str = "grpc+proto"; -pub struct ChariottProvider { +pub struct IntentProvider { url: Url, store: Arc, } -impl ChariottProvider { +impl IntentProvider { pub fn new(url: Url, store: Arc) -> Self { Self { url, store } } @@ -61,7 +61,7 @@ fn property(path: &str, fpm: i32) -> Entry { } #[async_trait] -impl ProviderService for ChariottProvider { +impl ProviderService for IntentProvider { async fn fulfill( &self, request: Request, diff --git a/intent_brokering/examples/applications/simulated-camera/src/main.rs b/intent_brokering/examples/applications/simulated-camera/src/main.rs index e17e6bb0..da118bed 100644 --- a/intent_brokering/examples/applications/simulated-camera/src/main.rs +++ b/intent_brokering/examples/applications/simulated-camera/src/main.rs @@ -3,19 +3,19 @@ // SPDX-License-Identifier: MIT mod camera; -mod chariott_provider; mod communication; +mod intent_provider; -use chariott_common::error::Error; -use chariott_proto::runtime::{ +use examples_common::intent_brokering; +use intent_brokering_common::error::Error; +use intent_brokering_proto::runtime::{ intent_registration::Intent, intent_service_registration::ExecutionLocality, }; -use examples_common::chariott; -chariott::provider::main!(wain); +intent_brokering::provider::main!(wain); async fn wain() -> Result<(), Error> { - let (url, socket_address) = chariott::provider::register( + let (url, socket_address) = intent_brokering::provider::register( "sdv.cabin.camera", "0.0.1", "sdv.camera.simulated", diff --git a/intent_brokering/examples/common/Cargo.toml b/intent_brokering/examples/common/Cargo.toml index dd6dd4ab..bc60b8cd 100644 --- a/intent_brokering/examples/common/Cargo.toml +++ b/intent_brokering/examples/common/Cargo.toml @@ -7,8 +7,8 @@ license = "MIT" [dependencies] async-trait = { workspace = true } bytes = "1.5" -chariott-common = { path = "../../common/" } -chariott-proto = { workspace = true } +intent_brokering_common = { workspace = true } +intent_brokering_proto = { workspace = true } ess = { path = "../../ess/" } keyvalue = { path = "../../keyvalue" } futures = { workspace = true } diff --git a/intent_brokering/examples/common/src/examples/detection.rs b/intent_brokering/examples/common/src/examples/detection.rs index cd7181c3..fafa88a3 100644 --- a/intent_brokering/examples/common/src/examples/detection.rs +++ b/intent_brokering/examples/common/src/examples/detection.rs @@ -2,11 +2,11 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -use chariott_common::error::{Error, ResultExt}; -use chariott_proto::common::{Blob, InvokeFulfillment, InvokeIntent}; +use intent_brokering_common::error::{Error, ResultExt}; +use intent_brokering_proto::common::{Blob, InvokeFulfillment, InvokeIntent}; use prost::Message; -use crate::chariott::value::Value; +use crate::intent_brokering::value::Value; use super::proto::detection::{ DetectEntry, DetectRequest as DetectRequestMessage, DetectResponse as DetectResponseMessage, diff --git a/intent_brokering/examples/common/src/examples/mod.rs b/intent_brokering/examples/common/src/examples/mod.rs index 81ece431..ae16d1a6 100644 --- a/intent_brokering/examples/common/src/examples/mod.rs +++ b/intent_brokering/examples/common/src/examples/mod.rs @@ -2,7 +2,7 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -/// Modules in `examples` are not common to Chariott in general, but common to +/// Modules in `examples` are not common to IntentBrokering in general, but common to /// one of our examples. The sub-modules illustrate how shared code between /// similar examples can look like. pub mod detection; diff --git a/intent_brokering/examples/common/src/examples/proto.rs b/intent_brokering/examples/common/src/examples/proto.rs index fd5f56c9..e3533f47 100644 --- a/intent_brokering/examples/common/src/examples/proto.rs +++ b/intent_brokering/examples/common/src/examples/proto.rs @@ -2,9 +2,9 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -mod chariott { +mod intent_brokering { pub mod common { - pub use chariott_proto::common as v1; + pub use intent_brokering_proto::common as v1; } } diff --git a/intent_brokering/examples/common/src/chariott/api.rs b/intent_brokering/examples/common/src/intent_brokering/api.rs similarity index 88% rename from intent_brokering/examples/common/src/chariott/api.rs rename to intent_brokering/examples/common/src/intent_brokering/api.rs index e27b6ace..066bf40e 100644 --- a/intent_brokering/examples/common/src/chariott/api.rs +++ b/intent_brokering/examples/common/src/intent_brokering/api.rs @@ -3,8 +3,8 @@ // SPDX-License-Identifier: MIT // api.rs contains code that can be considered "boilerplate" when -// interacting with the Chariott runtime. It will most likely need to be -// repeated for all applications interacting with Chariott. +// interacting with the Intent Brokering runtime. It will most likely need to be +// repeated for all applications interacting with Intent Brokering. use std::{ collections::HashMap, @@ -15,23 +15,26 @@ use std::{ use super::{inspection::Entry as InspectionEntry, value::Value}; use async_trait::async_trait; -use chariott_common::error::{Error, ResultExt as _}; -use chariott_proto::{ +use futures::{stream::BoxStream, StreamExt}; +use intent_brokering_common::error::{Error, ResultExt as _}; +use intent_brokering_proto::{ common::{ discover_fulfillment::Service as ServiceMessage, DiscoverFulfillment, DiscoverIntent, FulfillmentEnum, InspectFulfillment, InspectIntent, IntentEnum, IntentMessage, InvokeFulfillment, InvokeIntent, ReadFulfillment, ReadIntent, SubscribeFulfillment, SubscribeIntent, WriteFulfillment, WriteIntent, }, - runtime::{chariott_service_client::ChariottServiceClient, FulfillRequest, FulfillResponse}, + runtime::{ + intent_brokering_service_client::IntentBrokeringServiceClient, FulfillRequest, + FulfillResponse, + }, streaming::{channel_service_client::ChannelServiceClient, OpenRequest}, }; -use futures::{stream::BoxStream, StreamExt}; use tonic::{transport::Channel, Request, Response}; use tracing::debug; -const CHARIOTT_URL_KEY: &str = "CHARIOTT_URL"; -const DEFAULT_CHARIOTT_URL: &str = env!("DEFAULT_CHARIOTT_URL"); +const INTENT_BROKER_URL_KEY: &str = "INTENT_BROKER_URL"; +const DEFAULT_INTENT_BROKER_URL: &str = env!("DEFAULT_INTENT_BROKER_URL"); struct Fulfillment(FulfillmentEnum); @@ -79,24 +82,24 @@ impl_try_from_var!(Fulfillment, FulfillmentEnum::Subscribe, SubscribeFulfillment impl_try_from_var!(Fulfillment, FulfillmentEnum::Discover, DiscoverFulfillment); #[derive(Clone)] -pub struct GrpcChariott { - client: ChariottServiceClient, +pub struct GrpcIntentBrokering { + client: IntentBrokeringServiceClient, } -impl GrpcChariott { +impl GrpcIntentBrokering { pub async fn connect() -> Result { - let chariott_url = - env::var(CHARIOTT_URL_KEY).unwrap_or_else(|_| DEFAULT_CHARIOTT_URL.to_string()); - let client = ChariottServiceClient::connect(chariott_url) + let intent_brokering_url = env::var(INTENT_BROKER_URL_KEY) + .unwrap_or_else(|_| DEFAULT_INTENT_BROKER_URL.to_string()); + let client = IntentBrokeringServiceClient::connect(intent_brokering_url) .await - .map_err_with("Connecting to Chariott failed.")?; + .map_err_with("Connecting to IntentBrokering failed.")?; Ok(Self { client }) } } #[async_trait] -impl ChariottCommunication for GrpcChariott { +impl IntentBrokeringCommunication for GrpcIntentBrokering { async fn fulfill( &mut self, namespace: impl Into> + Send, @@ -112,10 +115,10 @@ impl ChariottCommunication for GrpcChariott { } } -/// Chariott abstracts the Communication layer, but is based on the Protobuf -/// definitions of the Chariott API. +/// IntentBrokering abstracts the Communication layer, but is based on the Protobuf +/// definitions of the IntentBrokering API. #[async_trait] -pub trait ChariottCommunication: Send { +pub trait IntentBrokeringCommunication: Send { async fn fulfill( &mut self, namespace: impl Into> + Send, @@ -123,9 +126,9 @@ pub trait ChariottCommunication: Send { ) -> Result, Error>; } -/// Chariott abstracts the Protobuf definitions that define Chariott's API. +/// IntentBrokering abstracts the Protobuf definitions that define IntentBrokering's API. #[async_trait] -pub trait Chariott: Send { +pub trait IntentBrokering: Send { async fn invoke + Send>( &mut self, namespace: impl Into> + Send, @@ -166,7 +169,7 @@ pub trait Chariott: Send { } #[async_trait] -impl Chariott for T { +impl IntentBrokering for T { async fn invoke + Send>( &mut self, namespace: impl Into> + Send, @@ -297,7 +300,7 @@ impl Chariott for T { } #[async_trait::async_trait] -pub trait ChariottExt { +pub trait IntentBrokeringExt { async fn listen<'b>( self, namespace: impl Into> + Send, @@ -306,9 +309,9 @@ pub trait ChariottExt { } #[async_trait::async_trait] -impl ChariottExt for &mut T +impl IntentBrokeringExt for &mut T where - T: Chariott + Send, + T: IntentBrokering + Send, { async fn listen<'b>( self, @@ -316,7 +319,7 @@ where subscription_sources: impl IntoIterator> + Send, ) -> Result>, Error> { const CHANNEL_ID_HEADER_NAME: &str = "x-chariott-channel-id"; - const SDV_EVENT_STREAMING_SCHEMA_REFERENCE: &str = "chariott.streaming.v1"; + const SDV_EVENT_STREAMING_SCHEMA_REFERENCE: &str = "intent_brokering.streaming.v1"; const SDV_EVENT_STREAMING_SCHEMA_KIND: &str = "grpc+proto"; let namespace = namespace.into(); diff --git a/intent_brokering/examples/common/src/chariott/inspection.rs b/intent_brokering/examples/common/src/intent_brokering/inspection.rs similarity index 93% rename from intent_brokering/examples/common/src/chariott/inspection.rs rename to intent_brokering/examples/common/src/intent_brokering/inspection.rs index 03260a15..a493b185 100644 --- a/intent_brokering/examples/common/src/chariott/inspection.rs +++ b/intent_brokering/examples/common/src/intent_brokering/inspection.rs @@ -4,8 +4,8 @@ use std::{borrow::Borrow, collections::HashMap}; -use chariott_common::query::regex_from_query; -use chariott_proto::common::{ +use intent_brokering_common::query::regex_from_query; +use intent_brokering_proto::common::{ fulfillment::Fulfillment, inspect_fulfillment::Entry as EntryMessage, InspectFulfillment, }; diff --git a/intent_brokering/examples/common/src/chariott/mod.rs b/intent_brokering/examples/common/src/intent_brokering/mod.rs similarity index 100% rename from intent_brokering/examples/common/src/chariott/mod.rs rename to intent_brokering/examples/common/src/intent_brokering/mod.rs diff --git a/intent_brokering/examples/common/src/chariott/provider.rs b/intent_brokering/examples/common/src/intent_brokering/provider.rs similarity index 90% rename from intent_brokering/examples/common/src/chariott/provider.rs rename to intent_brokering/examples/common/src/intent_brokering/provider.rs index ff71e055..f07d7fb1 100644 --- a/intent_brokering/examples/common/src/chariott/provider.rs +++ b/intent_brokering/examples/common/src/intent_brokering/provider.rs @@ -3,12 +3,12 @@ // SPDX-License-Identifier: MIT #[macro_export] -macro_rules! chariott_provider_main { +macro_rules! intent_provider_main { ($main:ident) => { #[cfg(not(tarpaulin_include))] #[::tokio::main] async fn main() -> ::std::process::ExitCode { - use ::examples_common::chariott::provider::internal::trace_result; + use ::examples_common::intent_brokering::provider::internal::trace_result; use ::std::process::ExitCode; use ::tracing_subscriber::{util::SubscriberInitExt, EnvFilter}; @@ -33,15 +33,15 @@ macro_rules! chariott_provider_main { }; } -pub use chariott_provider_main as main; +pub use intent_provider_main as main; use std::net::SocketAddr; use url::Url; -use chariott_common::config::env; -use chariott_common::error::{Error, ResultExt}; -use chariott_proto::runtime::{ +use intent_brokering_common::config::env; +use intent_brokering_common::error::{Error, ResultExt}; +use intent_brokering_proto::runtime::{ intent_registration::Intent, intent_service_registration::ExecutionLocality, }; diff --git a/intent_brokering/examples/common/src/chariott/registration.rs b/intent_brokering/examples/common/src/intent_brokering/registration.rs similarity index 74% rename from intent_brokering/examples/common/src/chariott/registration.rs rename to intent_brokering/examples/common/src/intent_brokering/registration.rs index 30abe41c..0a55c119 100644 --- a/intent_brokering/examples/common/src/chariott/registration.rs +++ b/intent_brokering/examples/common/src/intent_brokering/registration.rs @@ -4,12 +4,12 @@ use std::{env, net::SocketAddr, time::Duration}; -use chariott_common::{ +use intent_brokering_common::{ config, error::{Error, ResultExt}, }; -use chariott_proto::runtime::{ - chariott_service_client::ChariottServiceClient, intent_registration::Intent, +use intent_brokering_proto::runtime::{ + intent_brokering_service_client::IntentBrokeringServiceClient, intent_registration::Intent, intent_service_registration::ExecutionLocality, AnnounceRequest, IntentRegistration, IntentServiceRegistration, RegisterRequest, RegistrationState, }; @@ -20,8 +20,8 @@ use url::Url; use crate::url::UrlExt as _; -const CHARIOTT_URL_KEY: &str = "CHARIOTT_URL"; -const DEFAULT_CHARIOTT_URL: &str = env!("DEFAULT_CHARIOTT_URL"); +const INTENT_BROKER_URL_KEY: &str = "INTENT_BROKER_URL"; +const DEFAULT_INTENT_BROKER_URL: &str = env!("DEFAULT_INTENT_BROKER_URL"); const ANNOUNCE_URL_KEY: &str = "ANNOUNCE_URL"; pub enum ConfigSource<'a, T> { @@ -36,7 +36,7 @@ pub struct Builder { provider_url: Url, namespace: Box, intents: Vec, - chariott_url: Url, + intent_broker_url: Url, registration_interval: Duration, locality: ExecutionLocality, } @@ -50,13 +50,13 @@ impl Builder { intents: impl IntoIterator, locality: ExecutionLocality, ) -> Self { - let chariott_url = env::var(CHARIOTT_URL_KEY) - .unwrap_or_else(|_| DEFAULT_CHARIOTT_URL.to_string()) + let intent_broker_url = env::var(INTENT_BROKER_URL_KEY) + .unwrap_or_else(|_| DEFAULT_INTENT_BROKER_URL.to_string()) .parse() .unwrap(); let announce_url: Url = - chariott_common::config::env(ANNOUNCE_URL_KEY).unwrap_or_else(|| url.clone()); + intent_brokering_common::config::env(ANNOUNCE_URL_KEY).unwrap_or_else(|| url.clone()); Self { name: name.into(), @@ -65,7 +65,7 @@ impl Builder { provider_url: url, namespace: namespace.into(), intents: intents.into_iter().collect(), - chariott_url, + intent_broker_url, registration_interval: Duration::from_secs(5), locality, } @@ -75,7 +75,7 @@ impl Builder { match value { ConfigSource::Value(value) => self.registration_interval = value, ConfigSource::Environment(name) => { - let name = name.unwrap_or("CHARIOTT_REGISTRATION_INTERVAL"); + let name = name.unwrap_or("INTENT_BROKER_REGISTRATION_INTERVAL"); let registration_interval = self.registration_interval; return self.set_registration_interval(ConfigSource::Value( config::env::(name) @@ -87,13 +87,13 @@ impl Builder { self } - pub fn set_chariott_url(mut self, value: ConfigSource) -> Self { + pub fn set_intent_broker_url(mut self, value: ConfigSource) -> Self { match value { - ConfigSource::Value(value) => self.chariott_url = value, + ConfigSource::Value(value) => self.intent_broker_url = value, ConfigSource::Environment(name) => { - let name = name.unwrap_or("CHARIOTT_URL"); + let name = name.unwrap_or("INTENT_BROKER_URL"); if let Some(url) = config::env::(name) { - return self.set_chariott_url(ConfigSource::Value(url)); + return self.set_intent_broker_url(ConfigSource::Value(url)); } } } @@ -101,7 +101,7 @@ impl Builder { } pub fn from_env(self) -> Self { - self.set_chariott_url(ConfigSource::Environment(None)) + self.set_intent_broker_url(ConfigSource::Environment(None)) .set_registration_interval(ConfigSource::Environment(None)) } @@ -143,14 +143,17 @@ impl Builder { pub async fn register_once( &self, - client: &mut Option>, + client: &mut Option>, first_iteration: bool, ) -> Result<(), Error> { if client.is_none() { *client = Some( - ChariottServiceClient::connect(self.chariott_url.to_string()).await.map_err_with( - format!("Could not connect to Chariott ({})", self.chariott_url), - )?, + IntentBrokeringServiceClient::connect(self.intent_broker_url.to_string()) + .await + .map_err_with(format!( + "Could not connect to IntentBrokering ({})", + self.intent_broker_url + ))?, ); } @@ -167,7 +170,7 @@ impl Builder { let registration_state = client .announce(announce_request.clone()) .await - .map_err_with("Error when announcing to Chariott.")? + .map_err_with("Error when announcing to IntentBrokering.")? .into_inner() .registration_state; @@ -184,11 +187,11 @@ impl Builder { .collect(), }; - tracing::info!("Registered with Chariott runtime: {:?}", register_request); + tracing::info!("Registered with IntentBrokering runtime: {:?}", register_request); _ = client .register(register_request.clone()) .await - .map_err_with("Error when registering with Chariott.")?; + .map_err_with("Error when registering with IntentBrokering.")?; } } diff --git a/intent_brokering/examples/common/src/chariott/streaming.rs b/intent_brokering/examples/common/src/intent_brokering/streaming.rs similarity index 93% rename from intent_brokering/examples/common/src/chariott/streaming.rs rename to intent_brokering/examples/common/src/intent_brokering/streaming.rs index 50934f8c..672841af 100644 --- a/intent_brokering/examples/common/src/chariott/streaming.rs +++ b/intent_brokering/examples/common/src/intent_brokering/streaming.rs @@ -2,8 +2,8 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -use chariott_common::streaming_ess::StreamingEss; -use chariott_proto::common::{ +use intent_brokering_common::streaming_ess::StreamingEss; +use intent_brokering_proto::common::{ fulfillment::Fulfillment, ReadFulfillment, ReadIntent, SubscribeIntent, ValueEnum, ValueMessage, }; use keyvalue::{InMemoryKeyValueStore, Observer}; @@ -24,7 +24,7 @@ impl Observer for InternalStreamingEss } /// Represents an in-memory store that contains a blanket implementation for -/// integration with the Chariott streaming API. It generalizes over any type of +/// integration with the IntentBrokering streaming API. It generalizes over any type of /// value to be published, as long as that value can be transformed into a value /// which is compatible with the Proto contract. pub struct StreamingStore { diff --git a/intent_brokering/examples/common/src/chariott/value.rs b/intent_brokering/examples/common/src/intent_brokering/value.rs similarity index 98% rename from intent_brokering/examples/common/src/chariott/value.rs rename to intent_brokering/examples/common/src/intent_brokering/value.rs index eb6fe107..29697962 100644 --- a/intent_brokering/examples/common/src/chariott/value.rs +++ b/intent_brokering/examples/common/src/intent_brokering/value.rs @@ -4,7 +4,7 @@ use std::{error::Error, fmt::Display}; -use chariott_proto::common::{Blob, ValueEnum, ValueMessage}; +use intent_brokering_proto::common::{Blob, ValueEnum, ValueMessage}; #[derive(Debug)] pub struct InvalidType; diff --git a/intent_brokering/examples/common/src/lib.rs b/intent_brokering/examples/common/src/lib.rs index f00e9aca..c549cccd 100644 --- a/intent_brokering/examples/common/src/lib.rs +++ b/intent_brokering/examples/common/src/lib.rs @@ -2,6 +2,6 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -pub mod chariott; pub mod examples; +pub mod intent_brokering; pub mod url; diff --git a/intent_brokering/proto.rs/Cargo.toml b/intent_brokering/proto.rs/Cargo.toml index 77a97e3f..4d2ebfd6 100644 --- a/intent_brokering/proto.rs/Cargo.toml +++ b/intent_brokering/proto.rs/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "chariott-proto" +name = "intent_brokering_proto" version = "0.1.0" edition = "2021" license = "MIT" diff --git a/intent_brokering/proto.rs/build.rs b/intent_brokering/proto.rs/build.rs index 06e3e498..4323d30a 100644 --- a/intent_brokering/proto.rs/build.rs +++ b/intent_brokering/proto.rs/build.rs @@ -6,9 +6,9 @@ use std::{error::Error, path::Path}; use tonic_build::configure; fn main() -> Result<(), Box> { - compile_with_common("../proto/chariott/runtime/v1/runtime.proto")?; - compile_with_common("../proto/chariott/provider/v1/provider.proto")?; - compile_with_common("../proto/chariott/streaming/v1/streaming.proto")?; + compile_with_common("../proto/intent_brokering/runtime/v1/runtime.proto")?; + compile_with_common("../proto/intent_brokering/provider/v1/provider.proto")?; + compile_with_common("../proto/intent_brokering/streaming/v1/streaming.proto")?; Ok(()) } diff --git a/intent_brokering/proto.rs/src/lib.rs b/intent_brokering/proto.rs/src/lib.rs index 67ca85d2..88f56c23 100644 --- a/intent_brokering/proto.rs/src/lib.rs +++ b/intent_brokering/proto.rs/src/lib.rs @@ -7,10 +7,10 @@ // why we use allow derive_partial_eq_without_eq #![allow(clippy::derive_partial_eq_without_eq)] -mod chariott { +pub mod intent_brokering { pub mod common { pub mod v1 { - tonic::include_proto!("chariott.common.v1"); + tonic::include_proto!("intent_brokering.common.v1"); // Re-exporting these types under a different name makes it more // ergonomic in scenarios where both the "outer" (*Message) and @@ -26,22 +26,22 @@ mod chariott { } pub mod provider { pub mod v1 { - tonic::include_proto!("chariott.provider.v1"); + tonic::include_proto!("intent_brokering.provider.v1"); } } pub mod runtime { pub mod v1 { - tonic::include_proto!("chariott.runtime.v1"); + tonic::include_proto!("intent_brokering.runtime.v1"); } } pub mod streaming { pub mod v1 { - tonic::include_proto!("chariott.streaming.v1"); + tonic::include_proto!("intent_brokering.streaming.v1"); } } } -pub use chariott::common::v1 as common; -pub use chariott::provider::v1 as provider; -pub use chariott::runtime::v1 as runtime; -pub use chariott::streaming::v1 as streaming; +pub use intent_brokering::common::v1 as common; +pub use intent_brokering::provider::v1 as provider; +pub use intent_brokering::runtime::v1 as runtime; +pub use intent_brokering::streaming::v1 as streaming; diff --git a/intent_brokering/proto/buf.yaml b/intent_brokering/proto/buf.yaml index 8ef1c5eb..f5a5bcc0 100644 --- a/intent_brokering/proto/buf.yaml +++ b/intent_brokering/proto/buf.yaml @@ -9,4 +9,4 @@ lint: - ENUM_ZERO_VALUE_SUFFIX ignore_only: RPC_RESPONSE_STANDARD_NAME: - - chariott/streaming/v1/streaming.proto + - intent_brokering/streaming/v1/streaming.proto diff --git a/intent_brokering/proto/chariott/common/v1/common.proto b/intent_brokering/proto/intent_brokering/common/v1/common.proto similarity index 93% rename from intent_brokering/proto/chariott/common/v1/common.proto rename to intent_brokering/proto/intent_brokering/common/v1/common.proto index 17519c6d..697ddb4e 100644 --- a/intent_brokering/proto/chariott/common/v1/common.proto +++ b/intent_brokering/proto/intent_brokering/common/v1/common.proto @@ -3,7 +3,7 @@ // SPDX-License-Identifier: MIT /** -* Common Messages for the Chariott runtime. +* Common Messages for the IntentBrokering runtime. * * The protobuf definitions for messages common to the other definitions. */ @@ -11,7 +11,7 @@ syntax = "proto3"; -package chariott.common.v1; +package intent_brokering.common.v1; import "google/protobuf/timestamp.proto"; import "google/protobuf/any.proto"; @@ -46,7 +46,7 @@ message WriteFulfillment { /** Subscribe to a source on the application. This requires an already open streaming channel. * The `channel_id` is used to identify the channel to use for subscription. This is provided * by the provider as a gRPC metadata header when establishing a channel through the streaming -* interface call. See [chariott.streaming.v1.proto](chariott.streaming.v1.proto) for more details. +* interface call. See [intent_brokering.streaming.v1.proto](intent_brokering.streaming.v1.proto) for more details. */ message SubscribeIntent { string channel_id = 1; @@ -113,7 +113,7 @@ message InspectFulfillment { /** * Invoke Intent * -* The invoke intent is used to invoke a method on the application through the chariott runtime. +* The invoke intent is used to invoke a method on the application through the Intent Brokering runtime. */ message InvokeIntent { string command = 1; diff --git a/intent_brokering/proto/chariott/provider/v1/provider.proto b/intent_brokering/proto/intent_brokering/provider/v1/provider.proto similarity index 52% rename from intent_brokering/proto/chariott/provider/v1/provider.proto rename to intent_brokering/proto/intent_brokering/provider/v1/provider.proto index e9809216..2798534c 100644 --- a/intent_brokering/proto/chariott/provider/v1/provider.proto +++ b/intent_brokering/proto/intent_brokering/provider/v1/provider.proto @@ -5,20 +5,20 @@ /** * Provider definition * -* This proto file defines the contract between chariott and an intent provider. +* This proto file defines the contract between the Intent Broker and an intent provider. */ syntax = "proto3"; -package chariott.provider.v1; +package intent_brokering.provider.v1; -import "chariott/common/v1/common.proto"; +import "intent_brokering/common/v1/common.proto"; /** * The provider service definition. * -* This service is used by chariott to communicate with the provider. Each service application +* This service the Intent Broker to communicate with the provider. Each service application * that wants to be a provider must implement this service. */ service ProviderService { @@ -26,9 +26,9 @@ service ProviderService { } message FulfillRequest { - chariott.common.v1.Intent intent = 1; + intent_brokering.common.v1.Intent intent = 1; } message FulfillResponse { - chariott.common.v1.Fulfillment fulfillment = 1; + intent_brokering.common.v1.Fulfillment fulfillment = 1; } diff --git a/intent_brokering/proto/chariott/runtime/v1/runtime.proto b/intent_brokering/proto/intent_brokering/runtime/v1/runtime.proto similarity index 74% rename from intent_brokering/proto/chariott/runtime/v1/runtime.proto rename to intent_brokering/proto/intent_brokering/runtime/v1/runtime.proto index b2708c3b..8f0ddeae 100644 --- a/intent_brokering/proto/chariott/runtime/v1/runtime.proto +++ b/intent_brokering/proto/intent_brokering/runtime/v1/runtime.proto @@ -3,34 +3,34 @@ // SPDX-License-Identifier: MIT /** -* Chariott Runtime +* Intent Brokering Runtime * -* The prototype definitions for Chariott. +* The prototype definitions for Intent Brokering. */ syntax = "proto3"; -package chariott.runtime.v1; +package intent_brokering.runtime.v1; -import "chariott/common/v1/common.proto"; +import "intent_brokering/common/v1/common.proto"; /** -* The service entry point to Chariott. All functionality is provided through +* The service entry point to Chariott Intent Brokering. All functionality is provided through * this service. * -* **Announce** a service to Chariott. +* **Announce** a service to the Intent Brokering service. * -* The Announce method is used to announce a service to Chariott. +* The Announce method is used to announce a service to the Intent Brokering service. * If an application calls this method with a not already registered service * it will get back that the service is in `ANNOUNCED` state. If the service * is already registered it will return `NOT_CHANGED`. Each service needs to * periodically call within 5 seconds this method in order to keep the service -* active with Chariott. +* active with the Intent Brokering service. * More details in the [ADR-0012](docs/adr/ctp-2/0012-intent-registration.md) * -* **Register** a service to Chariott. +* **Register** a service to the Intent Brokering service. * -* The Register method is used to register a service to Chariott, +* The Register method is used to register a service to the Intent Brokering service, * together with the locality where the service is supposed to run. It also * takes a list of intents that the service can handle. It prunes all old * registrations for the same service, where a service is identified by the @@ -39,16 +39,16 @@ import "chariott/common/v1/common.proto"; * * **Fulfill** an intent. * -* The Fulfill method is used to fulfill an intent. Chariott will +* The Fulfill method is used to fulfill an intent. The Intent Broker will * lookup the registered services that can handle the intent. This is -* opaque to the caller. It will call the Fulfill method on the selected -* service that is Chariott selected to be able to handle the intent. +* opaque to the caller. It will call the Fulfill method on the service that is +* selected to be able to handle the intent. * More details on intents can be found in the following ADRs: * [ADR-0014](docs/adr/ctp-2/0014-intent-discover.md) * [ADR-0015](docs/adr/ctp-2/0015-inspection.md) * [ADR-0017](docs/adr/ctp-2/0016-intent-invoke.md) */ -service ChariottService { +service IntentBrokeringService { rpc Announce(AnnounceRequest) returns (AnnounceResponse); rpc Register(RegisterRequest) returns (RegisterResponse); rpc Fulfill(FulfillRequest) returns (FulfillResponse); @@ -65,7 +65,7 @@ message IntentServiceRegistration { /** * A side note about the `ExecutionLocality`. When `CLOUD` is selected this doesn't - * mean that the service will be invoked directly in the cloud through Chariott, + * mean that the service will be invoked directly in the cloud through the Intent Broker, * but that the service will be invoked in the cloud through a local installed provider * that acts as a proxy to the cloud service. This allows abstraction of the cloud * service interface and protocol. @@ -80,7 +80,7 @@ message IntentServiceRegistration { * This is used as input to the `Announce` method. * * Message to check if a service is already registered and also to announce a -* service's health to Chariott. +* service's health to the Intent Brokering service. */ message AnnounceRequest { IntentServiceRegistration service = 1; @@ -113,15 +113,15 @@ message IntentRegistration { } enum RegistrationState { - REGISTRATION_STATE_ANNOUNCED = 0; // service is not registered for Chariott, upon this result the service should call the `Register` method. - REGISTRATION_STATE_NOT_CHANGED = 1; // service is registered and successfully announced to Chariott. + REGISTRATION_STATE_ANNOUNCED = 0; // service is not registered, upon this result the service should call the `Register` method. + REGISTRATION_STATE_NOT_CHANGED = 1; // service is registered and successfully announced to the Intent Brokering service. } message FulfillRequest { string namespace = 1; - chariott.common.v1.Intent intent = 2; + intent_brokering.common.v1.Intent intent = 2; } message FulfillResponse { - chariott.common.v1.Fulfillment fulfillment = 1; + intent_brokering.common.v1.Fulfillment fulfillment = 1; } diff --git a/intent_brokering/proto/chariott/streaming/v1/streaming.proto b/intent_brokering/proto/intent_brokering/streaming/v1/streaming.proto similarity index 69% rename from intent_brokering/proto/chariott/streaming/v1/streaming.proto rename to intent_brokering/proto/intent_brokering/streaming/v1/streaming.proto index 44579475..2ce9098d 100644 --- a/intent_brokering/proto/chariott/streaming/v1/streaming.proto +++ b/intent_brokering/proto/intent_brokering/streaming/v1/streaming.proto @@ -7,17 +7,17 @@ * * This contract is used to stream data from a service application registered as provider and * a service application that is a consumer. This interface will be discovered using the -* `Discover` intent through the chariott runtime. The communication is done after discovery -* peer to peer without chariott being involved. Only the subscription of sources will be -* handled by chariott again, but data flows peer to peer without chariott in between. +* `Discover` intent through the Intent Broker runtime. The communication is done after discovery +* peer to peer without the Intent Broker being involved. Only the subscription of sources will be +* handled by the Intent Broker again, but data flows peer to peer without the broker in between. * More details found here: * [ADR-0016](docs/adr/ctp-2/0016-streaming-support.md) */ syntax = "proto3"; -package chariott.streaming.v1; +package intent_brokering.streaming.v1; -import "chariott/common/v1/common.proto"; +import "intent_brokering/common/v1/common.proto"; import "google/protobuf/timestamp.proto"; /** @@ -37,14 +37,14 @@ message OpenRequest {} * * The first response is sending the metadata containing the channel id that was created to be used * for subscribing to sources. The metadata field is called `x-chariott-channel-id`. The channel id -* has to be used to subscribe to sources as defined in the `chariott.runtime.v1.proto` file. +* has to be used to subscribe to sources as defined in the `intent_brokering.runtime.v1.proto` file. * * Each subscribed source will be sending an event through this response stream once subscribed to * and if an event occurs. */ message Event { string source = 1; // The source id of the event - chariott.common.v1.Value value = 2; // The value of the event + intent_brokering.common.v1.Value value = 2; // The value of the event uint64 seq = 3; // The sequence number of the event google.protobuf.Timestamp timestamp = 4; // The timestamp at which the event was generated } diff --git a/intent_brokering/src/connection_provider.rs b/intent_brokering/src/connection_provider.rs index 8201d341..e31ad2fb 100644 --- a/intent_brokering/src/connection_provider.rs +++ b/intent_brokering/src/connection_provider.rs @@ -5,8 +5,8 @@ use std::sync::Arc; use async_trait::async_trait; -use chariott_common::error::{Error, ResultExt as _}; -use chariott_proto::provider::{ +use intent_brokering_common::error::{Error, ResultExt as _}; +use intent_brokering_proto::provider::{ provider_service_client::ProviderServiceClient, FulfillRequest, FulfillResponse, }; use tokio::sync::Mutex; @@ -127,8 +127,8 @@ mod tests { }; use async_trait::async_trait; - use chariott_common::error::Error; - use chariott_proto::provider::{FulfillRequest, FulfillResponse}; + use intent_brokering_common::error::Error; + use intent_brokering_proto::provider::{FulfillRequest, FulfillResponse}; use url::Url; use super::{ConnectedProvider, ConnectionProvider, ReusableProvider}; diff --git a/intent_brokering/src/execution.rs b/intent_brokering/src/execution.rs index 3e92b902..63a6a94a 100644 --- a/intent_brokering/src/execution.rs +++ b/intent_brokering/src/execution.rs @@ -8,8 +8,8 @@ use crate::connection_provider::{ConnectedProvider, ConnectionProvider}; use crate::registry::IntentConfiguration; use crate::streaming::StreamingEss; use async_recursion::async_recursion; -use chariott_common::query::regex_from_query; -use chariott_proto::{ +use intent_brokering_common::query::regex_from_query; +use intent_brokering_proto::{ common::{ discover_fulfillment::Service, inspect_fulfillment::Entry, DiscoverFulfillment, FulfillmentEnum, FulfillmentMessage, InspectFulfillment, IntentEnum, IntentMessage, List, @@ -116,7 +116,7 @@ where } } RuntimeBinding::SystemDiscover(url) => { - const SCHEMA_VERSION_STREAMING: &str = "chariott.streaming.v1"; + const SCHEMA_VERSION_STREAMING: &str = "intent_brokering.streaming.v1"; const SCHEMA_REFERENCE: &str = "grpc+proto"; fulfill_response(FulfillmentEnum::Discover(DiscoverFulfillment { @@ -152,14 +152,14 @@ pub(crate) mod tests { registry::{IntentConfiguration, IntentKind}, }; use async_trait::async_trait; - use chariott_proto::{ + use futures::Stream; + use intent_brokering_proto::{ common::{ DiscoverFulfillment, FulfillmentEnum, FulfillmentMessage, InspectIntent, InvokeFulfillment, SubscribeFulfillment, SubscribeIntent, }, streaming::{channel_service_server::ChannelService, OpenRequest}, }; - use futures::Stream; use tokio_stream::StreamExt as _; use tonic::{Code, Request}; @@ -364,7 +364,7 @@ pub(crate) mod tests { services: vec![Service { url: url.to_string(), schema_kind: "grpc+proto".to_owned(), - schema_reference: "chariott.streaming.v1".to_owned(), + schema_reference: "intent_brokering.streaming.v1".to_owned(), metadata: HashMap::new(), }], })), diff --git a/intent_brokering/src/intent_broker.rs b/intent_brokering/src/intent_broker.rs index ee0f79ac..2364c8c6 100644 --- a/intent_brokering/src/intent_broker.rs +++ b/intent_brokering/src/intent_broker.rs @@ -162,7 +162,7 @@ mod tests { sync::Arc, }; - use chariott_common::streaming_ess::StreamingEss; + use intent_brokering_common::streaming_ess::StreamingEss; use url::Url; use crate::{ diff --git a/intent_brokering/src/chariott_grpc.rs b/intent_brokering/src/intent_brokering_grpc.rs similarity index 92% rename from intent_brokering/src/chariott_grpc.rs rename to intent_brokering/src/intent_brokering_grpc.rs index 9725295d..260baafb 100644 --- a/intent_brokering/src/chariott_grpc.rs +++ b/intent_brokering/src/intent_brokering_grpc.rs @@ -5,10 +5,10 @@ use std::sync::{Arc, RwLock}; use std::time::Instant; -use chariott_proto::{ +use intent_brokering_proto::{ common::intent::Intent, runtime::{ - chariott_service_server::ChariottService, AnnounceRequest, AnnounceResponse, + intent_brokering_service_server::IntentBrokeringService, AnnounceRequest, AnnounceResponse, FulfillRequest, FulfillResponse, IntentRegistration, IntentServiceRegistration, RegisterRequest, RegisterResponse, RegistrationState, }, @@ -34,12 +34,12 @@ const INTENT_MAPPING_WRITE: i32 = 3; const INTENT_MAPPING_INVOKE: i32 = 4; const INTENT_MAPPING_SUBSCRIBE: i32 = 5; -pub struct ChariottServer { +pub struct IntentBrokeringServer { broker: IntentBroker, registry: Arc>>, } -impl ChariottServer { +impl IntentBrokeringServer { pub fn new(registry: Registry, broker: IntentBroker) -> Self { Self { registry: Arc::new(RwLock::new(registry)), broker } } @@ -52,7 +52,7 @@ impl ChariottServer { fn create_configruation_from_registration( intent: IntentRegistration, ) -> Result { - ChariottServer::::map_intent_value(intent.intent) + IntentBrokeringServer::::map_intent_value(intent.intent) .map(|kind| IntentConfiguration::new(intent.namespace, kind)) } @@ -81,7 +81,7 @@ impl ChariottServer { } #[async_trait] -impl ChariottService for ChariottServer { +impl IntentBrokeringService for IntentBrokeringServer { async fn announce( &self, request: Request, @@ -113,7 +113,7 @@ impl ChariottService for ChariottServer let intents: Result, _> = request .intents .into_iter() - .map(ChariottServer::::create_configruation_from_registration) + .map(IntentBrokeringServer::::create_configruation_from_registration) .collect(); self.registry .write() @@ -134,7 +134,7 @@ impl ChariottService for ChariottServer let config = IntentConfiguration::new( request.namespace, match intent.intent { - Some(ref intent) => Ok(ChariottServer::::map_intent_variant(intent)), + Some(ref intent) => Ok(IntentBrokeringServer::::map_intent_variant(intent)), None => Err(Status::invalid_argument("Intent is not known.")), }?, ); @@ -187,11 +187,12 @@ mod tests { use crate::registry::{Change, Observer, Registry}; use crate::streaming::StreamingEss; use crate::{connection_provider::GrpcProvider, execution::tests::TestBinding}; - use chariott_proto::{ + use intent_brokering_proto::{ common, runtime::{ - chariott_service_server::ChariottService, intent_registration, AnnounceRequest, - IntentRegistration, IntentServiceRegistration, RegisterRequest, RegistrationState, + intent_brokering_service_server::IntentBrokeringService, intent_registration, + AnnounceRequest, IntentRegistration, IntentServiceRegistration, RegisterRequest, + RegistrationState, }, }; use tonic::Code; @@ -258,7 +259,7 @@ mod tests { #[test] fn intent_match_failure_are_caught() { - assert!(ChariottServer::::map_intent_value(-1).is_err()); + assert!(IntentBrokeringServer::::map_intent_value(-1).is_err()); } #[test] @@ -279,7 +280,7 @@ mod tests { fn test(intent_value: i32, kind: IntentKind) { assert_eq!( - ChariottServer::::map_intent_value(intent_value).unwrap(), + IntentBrokeringServer::::map_intent_value(intent_value).unwrap(), kind ); } @@ -398,7 +399,10 @@ mod tests { IntentKind::Subscribe, ), ] { - assert_eq!(expected, ChariottServer::::map_intent_variant(&intent)); + assert_eq!( + expected, + IntentBrokeringServer::::map_intent_variant(&intent) + ); } } @@ -430,10 +434,10 @@ mod tests { } } - fn setup() -> ChariottServer { + fn setup() -> IntentBrokeringServer { let broker = IntentBroker::new("https://localhost:4243".parse().unwrap(), StreamingEss::new()); // DevSkim: ignore DS162092 - ChariottServer::new(Registry::new(broker.clone(), Default::default()), broker) + IntentBrokeringServer::new(Registry::new(broker.clone(), Default::default()), broker) } fn create_announce_request() -> AnnounceRequest { diff --git a/intent_brokering/src/lib.rs b/intent_brokering/src/lib.rs index 71fc8d22..0bac11a1 100644 --- a/intent_brokering/src/lib.rs +++ b/intent_brokering/src/lib.rs @@ -2,10 +2,10 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -pub mod chariott_grpc; mod connection_provider; mod execution; mod intent_broker; +pub mod intent_brokering_grpc; pub use intent_broker::IntentBroker; pub mod registry; pub mod streaming; diff --git a/intent_brokering/src/main.rs b/intent_brokering/src/main.rs index e8ca0e87..124a7d13 100644 --- a/intent_brokering/src/main.rs +++ b/intent_brokering/src/main.rs @@ -2,15 +2,15 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -use chariott::chariott_grpc::ChariottServer; -use chariott::registry::{self, Registry}; -use chariott::streaming::StreamingEss; -use chariott::IntentBroker; -use chariott_common::config::{env, try_env}; -use chariott_common::ext::OptionExt as _; -use chariott_common::shutdown::{ctrl_c_cancellation, RouterExt as _}; -use chariott_proto::{ - runtime::chariott_service_server::ChariottServiceServer, +use intent_brokering::intent_brokering_grpc::IntentBrokeringServer; +use intent_brokering::registry::{self, Registry}; +use intent_brokering::streaming::StreamingEss; +use intent_brokering::IntentBroker; +use intent_brokering_common::config::{env, try_env}; +use intent_brokering_common::ext::OptionExt as _; +use intent_brokering_common::shutdown::{ctrl_c_cancellation, RouterExt as _}; +use intent_brokering_proto::{ + runtime::intent_brokering_service_server::IntentBrokeringServiceServer, streaming::channel_service_server::ChannelServiceServer, }; use registry::Composite; @@ -53,7 +53,7 @@ async fn main() -> Result<(), Box> { streaming_ess.clone(), ); - let registry_config = try_env::("CHARIOTT_REGISTRY_TTL_SECS") + let registry_config = try_env::("INTENT_BROKERING_REGISTRY_TTL_SECS") .ok()? .map(Duration::from_secs) .map(|v| registry::Config::default().set_entry_ttl_bounded(v)) @@ -71,11 +71,11 @@ async fn main() -> Result<(), Box> { tracing::info!("starting grpc services"); let addr = format!("0.0.0.0:{PORT}").parse().unwrap(); - tracing::info!("chariott listening on {addr}"); + tracing::info!("Intent Broker listening on {addr}"); - let server = Arc::new(ChariottServer::new(registry, broker)); + let server = Arc::new(IntentBrokeringServer::new(registry, broker)); let router = Server::builder() - .add_service(ChariottServiceServer::from_arc(Arc::clone(&server))) + .add_service(IntentBrokeringServiceServer::from_arc(Arc::clone(&server))) .add_service(ChannelServiceServer::new(streaming_ess)); #[cfg(build = "debug")] @@ -108,7 +108,7 @@ async fn main() -> Result<(), Box> { } async fn registry_prune_loop( - server: Arc>>, + server: Arc>>, ctrl_c_cancellation_token: CancellationToken, error_cancellation_token: CancellationToken, ) { diff --git a/intent_brokering/src/registry.rs b/intent_brokering/src/registry.rs index 0aee1738..6ba7be25 100644 --- a/intent_brokering/src/registry.rs +++ b/intent_brokering/src/registry.rs @@ -6,7 +6,7 @@ use core::fmt; use std::collections::{HashMap, HashSet}; use std::time::{Duration, Instant}; -use chariott_common::error::Error; +use intent_brokering_common::error::Error; use url::Url; use crate::streaming::StreamingEss; @@ -387,8 +387,8 @@ pub(crate) mod tests { time::Instant, }; - use chariott_common::streaming_ess::StreamingEss; - use chariott_proto::common::{value::Value, SubscribeIntent}; + use intent_brokering_common::streaming_ess::StreamingEss; + use intent_brokering_proto::common::{value::Value, SubscribeIntent}; use test_case::test_case; use crate::{ diff --git a/intent_brokering/src/streaming.rs b/intent_brokering/src/streaming.rs index 60fe9656..78868ab0 100644 --- a/intent_brokering/src/streaming.rs +++ b/intent_brokering/src/streaming.rs @@ -2,4 +2,4 @@ // Licensed under the MIT license. // SPDX-License-Identifier: MIT -pub type StreamingEss = chariott_common::streaming_ess::StreamingEss<()>; +pub type StreamingEss = intent_brokering_common::streaming_ess::StreamingEss<()>; diff --git a/intent_brokering/tests/README.md b/intent_brokering/tests/README.md index 061941e4..7bf68e52 100644 --- a/intent_brokering/tests/README.md +++ b/intent_brokering/tests/README.md @@ -1,6 +1,6 @@ # E2E Tests -The E2E tests are executed using Chariott and the KV App. Test files are +The E2E tests are executed using Intent Brokering and the KV App. Test files are suffixed with `e2e.rs`. To run the tests, you can either use the CI, or run the tests locally. @@ -10,10 +10,10 @@ To run the tests, you can either use the CI, or run the tests locally. Assuming the current working directory is the project root, run: ```sh -cargo build --release -p chariott -p kv-app -CHARIOTT_REGISTRY_TTL_SECS=7 ./target/release/chariott & +cargo build --release -p intent_brokering -p kv-app +INTENT_BROKERING_REGISTRY_TTL_SECS=7 ./target/release/intent_brokering & ./target/release/kv-app & -CHARIOTT_REGISTRY_TTL_SECS=7 cargo test --test '*e2e' +INTENT_BROKERING_REGISTRY_TTL_SECS=7 cargo test --test '*e2e' ``` If you want to display debug logs, make sure to set the log level via the `RUST_LOG` environment variable. @@ -26,7 +26,7 @@ From the project root, run the following command: ./tests/container-e2e-tests-wsl2.sh . ``` -This will build the Chariott and KV App Docker images, and run the tests. +This will build the Intent Brokering and KV App Docker images, and run the tests. ## Adding new tests diff --git a/intent_brokering/tests/chariott_integration.rs b/intent_brokering/tests/chariott_integration.rs index 366f412e..f3450cce 100644 --- a/intent_brokering/tests/chariott_integration.rs +++ b/intent_brokering/tests/chariott_integration.rs @@ -6,23 +6,27 @@ use std::sync::atomic::{AtomicU16, Ordering}; use std::time::Instant; use async_trait::async_trait; -use chariott::registry::{ +use common::get_uuid; +use examples_common::intent_brokering::{ + api::{IntentBrokering, IntentBrokeringCommunication}, + value::Value, +}; +use intent_brokering::registry::{ ExecutionLocality, IntentConfiguration, IntentKind, ServiceConfiguration, ServiceId, }; -use chariott::streaming::StreamingEss; -use chariott::{chariott_grpc::ChariottServer, registry::Registry, IntentBroker}; -use chariott_common::error::{Error, ResultExt as _}; -use chariott_common::shutdown::RouterExt as _; -use chariott_proto::{ +use intent_brokering::streaming::StreamingEss; +use intent_brokering::{ + intent_brokering_grpc::IntentBrokeringServer, registry::Registry, IntentBroker, +}; +use intent_brokering_common::error::{Error, ResultExt as _}; +use intent_brokering_common::shutdown::RouterExt as _; +use intent_brokering_proto::{ common::{IntentEnum, IntentMessage}, - runtime::{chariott_service_server::ChariottService, FulfillRequest, FulfillResponse}, + runtime::{ + intent_brokering_service_server::IntentBrokeringService, FulfillRequest, FulfillResponse, + }, streaming::channel_service_server::ChannelServiceServer, }; -use common::get_uuid; -use examples_common::chariott::{ - api::{Chariott, ChariottCommunication}, - value::Value, -}; use provider::Provider; use tokio::task::spawn; use tokio_util::sync::CancellationToken; @@ -138,7 +142,7 @@ async fn when_cancelled_shuts_down_provider() -> anyhow::Result<()> { struct Subject { namespace: String, - subject: ChariottServer, + subject: IntentBrokeringServer, } struct ProviderSetup { @@ -179,11 +183,11 @@ async fn setup_multiple(providers: impl IntoIterator) -> S .unwrap(); } - Subject { namespace, subject: ChariottServer::new(registry, broker) } + Subject { namespace, subject: IntentBrokeringServer::new(registry, broker) } } #[async_trait] -impl ChariottCommunication for Subject { +impl IntentBrokeringCommunication for Subject { async fn fulfill( &mut self, namespace: impl Into> + Send, diff --git a/intent_brokering/tests/container-e2e-tests-wsl2.sh b/intent_brokering/tests/container-e2e-tests-wsl2.sh index b025e4e1..031b3ef4 100755 --- a/intent_brokering/tests/container-e2e-tests-wsl2.sh +++ b/intent_brokering/tests/container-e2e-tests-wsl2.sh @@ -12,7 +12,7 @@ set -e # set up error handler to clean up docker containers and network function cleanup { echo "Cleaning up containers and network" - docker rm -f chariott 2>/dev/null + docker rm -f intent_brokering 2>/dev/null docker rm -f kv-app 2>/dev/null } @@ -35,13 +35,13 @@ if cleanup; then echo "Cleaned up existing containers and network" fi -# build chariott docker container -docker build --tag "chariott:$TAG" --file "$DOCKERFILE_CONTEXT/Dockerfile" "$DOCKERFILE_CONTEXT" -docker run --init --rm --name chariott --detach --publish 4243:4243 "chariott:$TAG" +# build intent_brokering docker container +docker build --tag "intent_brokering:$TAG" --file "$DOCKERFILE_CONTEXT/Dockerfile" "$DOCKERFILE_CONTEXT" +docker run --init --rm --name intent_brokering --detach --publish 4243:4243 "intent_brokering:$TAG" # build kv-app docker container docker build --tag "kv-app:$TAG" --file "$DOCKERFILE_CONTEXT/examples/applications/Dockerfile.kv-app.ci" --build-arg APP_NAME=kv-app "$DOCKERFILE_CONTEXT" -docker run --init --rm --name kv-app --detach --publish 50064:50064 --env ANNOUNCE_URL=http://host.docker.internal:50064 --env CHARIOTT_URL=http://host.docker.internal:4243 "kv-app:$TAG" # DevSkim: ignore DS137138 +docker run --init --rm --name kv-app --detach --publish 50064:50064 --env ANNOUNCE_URL=http://host.docker.internal:50064 --env INTENT_BROKER_URL=http://host.docker.internal:4243 "kv-app:$TAG" # DevSkim: ignore DS137138 # run the end to end tests cargo test --test "*e2e" diff --git a/intent_brokering/tests/provider.rs b/intent_brokering/tests/provider.rs index 802af58f..db82e839 100644 --- a/intent_brokering/tests/provider.rs +++ b/intent_brokering/tests/provider.rs @@ -5,14 +5,14 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use async_trait::async_trait; -use chariott_proto::{ +use examples_common::intent_brokering::value::Value; +use intent_brokering_proto::{ common::{FulfillmentEnum, FulfillmentMessage, IntentEnum, InvokeFulfillment, InvokeIntent}, provider::{ provider_service_server::{ProviderService, ProviderServiceServer}, FulfillRequest, FulfillResponse, }, }; -use examples_common::chariott::value::Value; use tokio::{net::TcpSocket, spawn}; use tokio_stream::wrappers::TcpListenerStream; use tonic::{transport::Server, Request, Response, Status}; diff --git a/intent_brokering/tests/registry-e2e.rs b/intent_brokering/tests/registry-e2e.rs index 60a9bcf2..590b3cd0 100644 --- a/intent_brokering/tests/registry-e2e.rs +++ b/intent_brokering/tests/registry-e2e.rs @@ -4,14 +4,14 @@ use std::time::Duration; -use chariott_proto::runtime::{ - intent_registration::Intent, intent_service_registration::ExecutionLocality, -}; use common::get_uuid; -use examples_common::chariott::{ - api::{Chariott, ChariottExt as _, GrpcChariott}, +use examples_common::intent_brokering::{ + api::{GrpcIntentBrokering, IntentBrokering, IntentBrokeringExt as _}, registration::Builder as RegistrationBuilder, }; +use intent_brokering_proto::runtime::{ + intent_registration::Intent, intent_service_registration::ExecutionLocality, +}; use tokio::time::*; use tokio_stream::StreamExt as _; @@ -31,15 +31,16 @@ async fn expired_registrations_are_pruned_after_ttl() -> Result<(), anyhow::Erro ExecutionLocality::Local, ); - let mut chariott = setup().await; + let mut intent_broker = setup().await; // act builder.register_once(&mut None, true).await?; - let initial_entries = chariott.inspect("system.registry", namespace.clone()).await?; - let ttl = Duration::from_secs(env!("CHARIOTT_REGISTRY_TTL_SECS").parse::().unwrap() + 1); + let initial_entries = intent_broker.inspect("system.registry", namespace.clone()).await?; + let ttl = + Duration::from_secs(env!("INTENT_BROKERING_REGISTRY_TTL_SECS").parse::().unwrap() + 1); sleep(ttl).await; - let entries = chariott.inspect("system.registry", namespace).await?; + let entries = intent_broker.inspect("system.registry", namespace).await?; // assert assert_eq!(1, initial_entries.len()); @@ -82,6 +83,6 @@ async fn when_provider_registers_notifies_registry_observers() -> anyhow::Result Ok(()) } -async fn setup() -> impl Chariott { - GrpcChariott::connect().await.unwrap() +async fn setup() -> impl IntentBrokering { + GrpcIntentBrokering::connect().await.unwrap() } diff --git a/intent_brokering/tests/store-e2e.rs b/intent_brokering/tests/store-e2e.rs index 80b816d4..d447cba0 100644 --- a/intent_brokering/tests/store-e2e.rs +++ b/intent_brokering/tests/store-e2e.rs @@ -4,12 +4,12 @@ use std::{collections::HashSet, error::Error as _, time::Duration}; -use chariott_common::error::Error; use common::get_uuid; -use examples_common::chariott::{ - api::{Chariott, ChariottExt, Event, GrpcChariott}, +use examples_common::intent_brokering::{ + api::{Event, GrpcIntentBrokering, IntentBrokering, IntentBrokeringExt}, value::Value, }; +use intent_brokering_common::error::Error; use tokio::time::{sleep_until, Instant}; use tokio_stream::StreamExt as _; @@ -20,10 +20,10 @@ const KV_NAMESPACE: &str = "sdv.kvs"; #[tokio::test] async fn when_key_does_not_exist_returns_none() -> Result<(), anyhow::Error> { // arrange - let mut chariott = setup().await; + let mut intent_broker = setup().await; // act - let response = chariott.read(KV_NAMESPACE, get_uuid()).await?; + let response = intent_broker.read(KV_NAMESPACE, get_uuid()).await?; // assert assert_eq!(None, response); @@ -34,13 +34,13 @@ async fn when_key_does_not_exist_returns_none() -> Result<(), anyhow::Error> { #[tokio::test] async fn when_writing_value_returns_value_on_read() -> Result<(), anyhow::Error> { // arrange - let mut chariott = setup().await; + let mut intent_broker = setup().await; let value: Value = "some_value".into(); let key = get_uuid(); // act - chariott.write(KV_NAMESPACE, key.clone(), value.clone()).await?; - let response = chariott.read(KV_NAMESPACE, key).await?; + intent_broker.write(KV_NAMESPACE, key.clone(), value.clone()).await?; + let response = intent_broker.read(KV_NAMESPACE, key).await?; // assert assert_eq!(Some(value), response); @@ -51,10 +51,10 @@ async fn when_writing_value_returns_value_on_read() -> Result<(), anyhow::Error> #[tokio::test] async fn when_provider_does_not_exist_returns_error() { // arrange - let mut chariott = setup().await; + let mut intent_broker = setup().await; // act - let response = chariott.read("sdv.does_not_exist", "key").await; + let response = intent_broker.read("sdv.does_not_exist", "key").await; // assert assert!(response.unwrap_err().source().unwrap().to_string().contains("No provider found.")); @@ -63,13 +63,13 @@ async fn when_provider_does_not_exist_returns_error() { #[tokio::test] async fn when_writing_while_streaming_publishes_value() -> Result<(), anyhow::Error> { // arrange - let mut chariott = setup().await; + let mut intent_broker = setup().await; let key = get_uuid(); let value: Value = 10.into(); // act - let response_stream = chariott.listen(KV_NAMESPACE, [key.clone()]).await?; - chariott.write(KV_NAMESPACE, key.clone(), value.clone()).await?; + let response_stream = intent_broker.listen(KV_NAMESPACE, [key.clone()]).await?; + intent_broker.write(KV_NAMESPACE, key.clone(), value.clone()).await?; // assert let event = response_stream.take(1).collect::>>().await; @@ -85,13 +85,13 @@ async fn when_writing_while_streaming_publishes_value() -> Result<(), anyhow::Er async fn when_streaming_increases_sequence_number() -> Result<(), anyhow::Error> { // arrange const NUMBER_OF_EVENTS: u64 = 5; - let mut chariott = setup().await; + let mut intent_broker = setup().await; let key = get_uuid(); // act - let response_stream = chariott.listen(KV_NAMESPACE, [key.clone()]).await?; + let response_stream = intent_broker.listen(KV_NAMESPACE, [key.clone()]).await?; for _ in 0..NUMBER_OF_EVENTS { - chariott.write(KV_NAMESPACE, key.clone(), 10.into()).await?; + intent_broker.write(KV_NAMESPACE, key.clone(), 10.into()).await?; } // assert @@ -114,11 +114,11 @@ async fn when_streaming_increases_sequence_number() -> Result<(), anyhow::Error> #[tokio::test] async fn when_writing_to_a_different_key_does_not_publish_value() -> Result<(), anyhow::Error> { // arrange - let mut chariott = setup().await; + let mut intent_broker = setup().await; // act - let mut response_stream = chariott.listen(KV_NAMESPACE, [get_uuid()]).await?; - chariott.write(KV_NAMESPACE, get_uuid(), 10.into()).await?; + let mut response_stream = intent_broker.listen(KV_NAMESPACE, [get_uuid()]).await?; + intent_broker.write(KV_NAMESPACE, get_uuid(), 10.into()).await?; // assert @@ -136,6 +136,6 @@ async fn when_writing_to_a_different_key_does_not_publish_value() -> Result<(), Ok(()) } -async fn setup() -> impl Chariott { - GrpcChariott::connect().await.unwrap() +async fn setup() -> impl IntentBrokering { + GrpcIntentBrokering::connect().await.unwrap() } diff --git a/intent_brokering/tools/charc b/intent_brokering/tools/charc index 0f9b6935..c4290494 100755 --- a/intent_brokering/tools/charc +++ b/intent_brokering/tools/charc @@ -36,9 +36,9 @@ EOF fi local ID; ID="$(date -u +%s.%N)" echo "$REQ" > "$GRPC_LOG_DIR_PATH/req-$ID" - grpcurl -plaintext -import-path ../proto -proto ../proto/chariott/runtime/v1/runtime.proto \ - -d @ "${CHARIOTT_ADDRESS:-0.0.0.0:4243}" \ - chariott.runtime.v1.ChariottService/Fulfill <<< "$REQ" \ + grpcurl -plaintext -import-path ../proto -proto ../proto/intent_brokering/runtime/v1/runtime.proto \ + -d @ "${INTENT_BROKER_ADDRESS:-0.0.0.0:4243}" \ + intent_brokering.runtime.v1.IntentBrokeringService/Fulfill <<< "$REQ" \ | tee "$GRPC_LOG_DIR_PATH/rsp-$ID" if [[ "${PIPESTATUS[*]}" != '0 0' ]]; then return 1; fi } @@ -193,7 +193,7 @@ cmd_listen() { fi local ADDRESS; ADDRESS="$( cmd_discover \ - | jq -r '.[] | select(.schemaReference == "chariott.streaming.v1" and .schemaKind == "grpc+proto") | .url' \ + | jq -r '.[] | select(.schemaReference == "intent_brokering.streaming.v1" and .schemaKind == "grpc+proto") | .url' \ | tr -d / | sed -E "s/^http://" )" if [ -z "$ADDRESS" ]; then @@ -211,8 +211,8 @@ cmd_listen() { mkfifo "$EVENT_STREAM_FIFO" fi grpcurl -v -plaintext -import-path ../proto -proto \ - ../proto/chariott/streaming/v1/streaming.proto "$ADDRESS" \ - chariott.streaming.v1.ChannelService/Open > "$EVENT_STREAM_FIFO" & + ../proto/intent_brokering/streaming/v1/streaming.proto "$ADDRESS" \ + intent_brokering.streaming.v1.ChannelService/Open > "$EVENT_STREAM_FIFO" & echo>"$LISTENER_PID_FILE_PATH" $! touch "$EVENTS_FILE_PATH" "$MUX_EVENTS_FILE_PATH" local LINE @@ -318,7 +318,7 @@ init_channel_context() { EVENTS_FILE_PATH="$CHAR_HOME/channel/$NAMESPACE/events" } -chariott_cmd() { +intent_brokering_cmd() { if [ -z "$2" ]; then echo>&2 'Missing namespace argument.' return 1 @@ -342,7 +342,7 @@ case "$1" in listen|\ channel|\ inspect) - chariott_cmd "$@" + intent_brokering_cmd "$@" ;; events) shift diff --git a/intent_brokering/tools/charc.md b/intent_brokering/tools/charc.md index 2012287c..59134845 100644 --- a/intent_brokering/tools/charc.md +++ b/intent_brokering/tools/charc.md @@ -1,7 +1,7 @@ # `charc` `charc` is a Bash script for simple and quick session-based interactions with -Chariott. `charc` stands for _Chariott console_. +Chariott Intent Brokering. `charc` stands for _Chariott intent console_. ## Usage @@ -24,10 +24,10 @@ Chariott. `charc` stands for _Chariott console_. charc inspect -Issues the _inspect intent_ to Chariott for fullfilment by some provider +Issues the _inspect intent_ to the Intent Broker for fullfilment by some provider providing the capability. -For inspection of the Chariott registry of providers, use `system.registry` +For inspection of the intent registry of providers, use `system.registry` for the `` argument: ./charc inspect system.registry "**" @@ -36,7 +36,7 @@ for the `` argument: charc discover -Issues the _discover intent_ to Chariott for fullfilment by some provider +Issues the _discover intent_ to the Intent Broker for fullfilment by some provider providing the capability, e.g.: ./charc discover sdv.vdt @@ -48,7 +48,7 @@ connections. charc read -Issues the _read intent_ to Chariott for fullfilment by some provider +Issues the _read intent_ to the Intent Broker for fullfilment by some provider providing the capability, e.g.: ./charc read sdv.kvs time @@ -57,7 +57,7 @@ providing the capability, e.g.: charc write -Issues the _write intent_ to Chariott for fullfilment by some provider +Issues the _write intent_ to the Intent Broker for fullfilment by some provider providing the capability, e.g.: ./charc write sdv.kvs time "$(date)" @@ -66,7 +66,7 @@ providing the capability, e.g.: charc invoke [( )...] -Issues the _invoke intent_ to Chariott for fullfilment by some provider +Issues the _invoke intent_ to the Intent Broker for fullfilment by some provider providing the capability. The arguments after `` are always in pairs of `` and ``, @@ -97,7 +97,7 @@ of the following: ./charc discovery sdv.kvs The end-point must use gRPC (`grpc+proto`) and conform to -`chariott.streaming.v1`. +`intent_brokering.streaming.v1`. This sub-command only needs to be issued once per namespace, but supports concurrently listening to multiple streams. It is required to use @@ -113,7 +113,7 @@ eventually to close all opened streams. charc subscribe -Issues the _subscribe intent_ to Chariott for fullfilment by some provider +Issues the _subscribe intent_ to the Intent Broker for fullfilment by some provider providing the capability, e.g.: ./charc subscribe sdv.kvs time @@ -148,7 +148,7 @@ for `` to open a streaming channel. charc show (req|request|rsp|response) Shows the last gRPC request (`req`) sent or response (`rsp`) received by the -last sub-command that communicated with Chariott. +last sub-command that communicated with the Intent Broker. ### `end`