Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Putting It All Together

Now that you’re familiar with Cargo-ProSA, configuration, observability, and running ProSA, let’s walk through a complete example from scratch using the built-in processors.

Prerequisites

You need Rust and Cargo installed, along with cargo-prosa:

cargo install cargo-prosa

Create and scaffold a project

cargo prosa new my-first-prosa
cd my-first-prosa

This generates a Rust project with a ProSA.toml descriptor, a build.rs, and a main.rs that will be auto-generated from your ProSA configuration.

You can inspect the available components with:

cargo prosa list

This shows all discovered components: Main, TVF, Processors, and Adaptors.

Add processors

Add a stub processor that will respond to requests, and an injector that will send requests:

cargo prosa add -n stub-1 -a StubParotAdaptor stub
cargo prosa add -n inj-1 -a InjDummyAdaptor inj
  • -n sets the processor instance name (used in configuration)
  • -a selects which adaptor to use

Your ProSA.toml file now contains the processor configuration. You can also edit this file manually.

Generate and edit the configuration

Build the project and retrieve the generated configuration from target/config.yml (or target/config.toml).

You can also generate a default configuration using --dry_run (see Run ProSA for details on this flag):

cargo run -- -c config.yaml --dry_run

Then edit config.yaml to wire the injector to the stub. The stub needs to declare a service name, and the injector needs to target that same service:

name: "my-first-prosa"
observability:
  level: debug
  metrics:
    stdout:
      level: info
  traces:
    stdout:
      level: debug

stub_1:
  service_names:
    - "TEST_SERVICE"

inj_1:
  service_name: "TEST_SERVICE"
  max_speed: 1.0

This configures:

  • The stub to respond to requests on "TEST_SERVICE"
  • The injector to send 2 transactions per second to "TEST_SERVICE"
  • Observability output to stdout so you can see what’s happening

Run it

cargo run -- -n "MyFirstProSA" -c config.yaml

You should see log output showing:

  1. ProSA starting with the configured name
  2. The stub processor registering TEST_SERVICE
  3. The injector discovering the service and starting to send transactions
  4. Responses flowing back from the stub to the injector

Press Ctrl+C to stop (see Graceful Shutdown).

What’s next?

You now know how to build and operate a ProSA instance. The next chapters cover how to develop your own components:

  • Adaptor — write custom protocol adaptors
  • Processor — write custom processors with their own business logic