Skip to content

v2.2.0 — per-feature NATS server-version requirements

Choose a tag to compare

@bpacholek bpacholek released this 10 Jun 20:25
· 497 commits to main since this release

Makes the per-feature NATS server-version requirements visible to users — without forcing a version check on every call.

✨ Added

  • Compatibility table + PHPDoc notes. Every version-gated feature now documents its minimum NATS version: a table in the README ("NATS Server Version Requirements") and Requires NATS X.Y+ notes in the method docblocks (so it shows up in your IDE).
  • Programmatic registry. IDCT\NATS\JetStream\FeatureSupport::requiredVersion('allow_atomic') → "2.12".
  • Reactive typed exception. New IDCT\NATS\Exception\UnsupportedFeatureException (a subclass of JetStreamException). When a request fails because the connected server is too old (it rejects the config field with unknown field "X"), the client raises this exception carrying the feature, the required version, and the server's reported version — instead of an opaque error.
use IDCT\NATS\Exception\UnsupportedFeatureException;

try {
    $js->batch()->add('orders.created', $payload)->commit()->await();
} catch (UnsupportedFeatureException $e) {
    echo "{$e->feature} needs NATS {$e->requiredVersion}; server is {$e->serverVersion}\n";
}

How it works

The detection is reactive — derived from the server's own error response on failure, so there is no per-request version probe. Existing catch (JetStreamException) handlers still catch it (JetStreamException is no longer final so it can be specialized).

Test status

PHPStan level 8 clean; 497 unit tests passing.

Full changelog: https://github.com/ideaconnect/php-nats-jetstream-client/blob/main/CHANGELOG.md