N

NATS

Protocol adapters available

Publish and request/reply over the NATS line protocol, one op per request.

Install
$ loadr plugin install nats
examples/plugins/nats.yaml
# NATS load test, driven by the `loadr-plugin-nats` native protocol plugin.
#
# NATS is NOT built into loadr core — it is a runtime-loadable plugin that
# speaks the NATS client line protocol directly over TCP (no `async-nats`
# crate, no OpenSSL). The plugin declares the `nats://` URL scheme, so once it
# is installed a request to a `nats://` URL routes straight to it; no explicit
# `protocol:` is needed.
#
# Each request runs one operation from its `plugin:` block: a fire-and-forget
# `publish`, or a `request` that waits for a responder's reply. loadr records
# the round-trip latency in `nats_req_duration` and counts operations in
# `nats_reqs`. Success is status 0; a `-ERR`, a request timeout, or a
# connection failure is status 1 and fails the request.
#
# Build + install the plugin, then run:
#   cargo build -p loadr-plugin-nats --release
#   mkdir -p dist && cp plugins/loadr-plugin-nats/plugin.toml dist/ \
#     && cp target/release/libloadr_plugin_nats.so dist/
#   loadr plugin install dist
#   loadr run examples/plugins/nats.yaml
#
# Or point the plan's `plugins:` entry at the built artifact directly (below).
name: nats
description: publish + request/reply against NATS via loadr-plugin-nats

plugins:
  # Resolve `nats` by name from the plugins dir (after `loadr plugin install`).
  # To run straight from a build tree instead, set:
  #   path: target/release/libloadr_plugin_nats.so
  - name: nats

scenarios:
  # Fire-and-forget publishers push messages onto a subject.
  publish:
    executor: constant-vus
    vus: 20
    duration: 15s
    flow:
      - request:
          name: publish event
          url: nats://msg.example.com:4222
          plugin:
            operation: publish
            subject: events.ingest
            body: '{"vu": ${vu}, "iteration": ${iteration}}'
          assert:
            - { type: status, equals: 0 }        # 0 = ok, 1 = protocol error

  # Request/reply against a responder, at a fixed rate.
  request_reply:
    executor: constant-arrival-rate
    rate: 200
    duration: 15s
    pre_allocated_vus: 30
    max_vus: 100
    flow:
      - request:
          name: ask service
          url: nats://msg.example.com:4222
          plugin:
            operation: request
            subject: rpc.echo
            body: "ping ${vu}"
          checks:
            - { type: status, equals: 0 }
            - { type: body_contains, value: pong }
            - { type: duration, name: reply is fast, max: 50ms }

thresholds:
  checks: [ "rate>0.99" ]
  nats_req_duration: [ "p(95)<50ms" ]
  nats_reqs: [ "count>0" ]

A real run: install from the signed index, then watch the plugin work.

A runtime plugin, never in the binary

Installing pulls a per-platform driver from the signed index, verifies its SHA-256 and checks its ABI before it ever loads. Remove it any time with loadr plugin remove nats.