Repository navigation
chore: absorb nats into packages/nats - #13969
Conversation
Rename the Composer package from nats/nats to utopia-php/nats and move the root namespace from Nats to Utopia\NATS across src, tests, examples, README, and PSR-4 autoload config. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
refactor: rename package to utopia-php/nats with Utopia\NATS namespace
chore(nats): absorb into the monorepo
build: hoist baseline rector + phpstan configs to the root
Reuse mirror redirect workflow
docs: enforce documentation style with Vale
nats: bring the client to broad + deep feature parity
…ge-dlq-ttl feat(queue,nats): consumer backoff, stream storage choice, dead-letter TTL
…ection fix(nats,pools,queue): stop losing work, dedupe enqueues, end duplicate delivery (CLO-4771/4772/4773)
…ming test(nats): measure which deadline stopped requestMany, not the runner
…elay fix(nats): three defects on the JetStream pull path
chore: stop committing package lock files
feat(nats,queue): batch JetStream publishes instead of one round trip per message
…-reconnect fix(nats): replay a request once after a closing -ERR reconnects
Pipeline NATS requests with individual confirmations
🟢 Tier S · Ready to merge
This PR imports the NATS client into Latest changes: The newest commit adds three Rector skips to preserve imported readonly classes, class constants, and arrow-function return types.
📂 Walkthrough · 7
Reviewed the commits since |
|
Connection declares typed class constants, which PHP 8.1 and 8.2 cannot parse; the manifest allowed >=8.1, so Composer could install the mirror on a runtime that fails to load it.
|
@greptile review |
Raising the PHP floor to 8.3 enabled ReadOnlyClassRector and AddTypeToConstRector (and an arrow-function return-type rule), so Rector's dry run in CI wanted to rewrite 44 files. The absorb keeps the source as released.
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
| $matched = preg_match( | ||
| '#PUB \$JS\.API\.CONSUMER\.MSG\.NEXT\.STREAM\.durable \S+ \d+\r\n(\{.*?\})\r\n#s', | ||
| $fake->written, | ||
| $m, | ||
| ); |
There was a problem hiding this comment.
pullRequest() adds a preg_match pattern to parse a protocol frame. The repository instructs us not to add regular expressions unless the PR explains why string functions or an existing validator cannot work. Please satisfy that requirement before merging; the pattern also makes this test harder to review and maintain.
Context Used: CLAUDE.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/nats/tests/ConsumerPullRequestTest.php
Line: 48-52
Comment:
**Regex in test frame parser**
`pullRequest()` adds a `preg_match` pattern to parse a protocol frame. The repository instructs us not to add regular expressions unless the PR explains why string functions or an existing validator cannot work. Please satisfy that requirement before merging; the pattern also makes this test harder to review and maintain.
**Context Used:** CLAUDE.md ([source](https://github.com/appwrite/appwrite/blob/main/CLAUDE.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
Moves
utopia-php/natsintopackages/natsso Appwrite loads it directly. Part of #13828, following the playbook inrfc/monorepo.md.The RFC planned to move
natstoappwrite/cloud. It lives here instead: its real consumer ispackages/queue, whose NATS JetStream broker (Utopia\Queue\Broker\Nats) needsutopia-php/nats ^1.4. Cloud is private and has no split tooling, and it only gets nats transitively. The RFC's non-goals and phase 7 now say so.replicationis being archived separately, not moved.Merge with a merge commit: a squash drops the
git-subtree-*annotation and orphans the package from its mirror.Add 'packages/nats/' from commit '016f48bd…'mainwith full historychore(nats): mirror plumbingmirror.ymlcalls this repository'smirror-redirect.yml; README banner points here. No banned files to striprefactor: load nats from packages/replace, step A shape, standalonephpstan.neon/rector.php, baselinedocs(rfc): keep nats in packages/ and list its baseline for phase 8Version gap
None. Mirror head
016f48bdis the1.4.0tag, andutopia-php/monorepo'spackages/natsis byte-identical to it. Appwrite did not installutopia-php/natsbefore this PR; queue only had it inrequire-dev/suggest.Step A
src/1.4.0apart from Pint formatting (empty{}constructor and class bodies expanded in 51 files)tests/Unit/*→tests/Utopia\NATS\Tests\Unit→Utopia\NATS\Tests.FakeTransportand a loopbackstream_socket_serveron port 0 only; no NATS server, no Swooletests/E2E/phpunit.xmlunit=testsminusE2E,e2e=tests/E2Edocker-compose.ymlname: utopia-nats, so it never shares a compose projectphpstan.neonsrc+tests(previously included../../phpstan.neon, the monorepo's level 5)rector.phpClassPropertyAssignToConstructorPromotionRectorandReadOnlyPropertyRector(same asbalancer). No changesphpstan-baseline.neonsrc(decodedmixedJSON in the JetStream/KeyValue/ObjectStorefromArray()builders,ServerInfo,Connection), 81 in the unit tests, 72 in e2ecomposer test/composer test:e2e(upstream named a non-existentintegrationsuite). No badges or CONTRIBUTING to fixNothing to hoist:
requireisphpandext-json, already in the rootrequire.Lock
utopia-php/natswas never incomposer.lock, so there is no line to drop.composer update --lockpluscomposer update --no-install --minimal-changeschange only thecontent-hash.Validation
bin/monorepo validatebin/monorepo check natsbin/monorepo test natsutopia-nats, torn down)appwrite/appwrite:2.3.0), registry and--linkedappwrite/appwrite:2.3.0, compose projectabsorb-nats-queue, torn down), registry and--linked(utopia-php/nats1.4.999 mirrored frompackages/nats)phpunit --testsuite packagesinappwrite/appwrite:2.3.0agentsDiffCheckTestworktree.gitissue--filter 'Utopia\\NATS'NatsBrokerConfigTest+ServerJobsTest::testStartKeepsConcurrencyOnTheNatsBrokercomposer validate --no-check-publishbin/monorepo split nats --dry-run5c9cfa64, fast-forwards from mirror head016f48bd(2 commits), tree identical topackages/natsgit diff --checkThe queue tiers crash under macOS host Swoole (unit segfault, e2e bus error), so they ran in the Linux image.
One PHP 8.4+ deprecation comes with the source:
Connection::reconnect()callslcg_value()for jitter. It shows as a deprecation in the rootpackagessuite, which does not fail on deprecations. Left as is to keep this a pure move.Mirror
utopia-php/natshad no ruleset and no classic protection.absorbcreated the canonicalmainruleset (id24166699: deletion, non-fast-forward, pull request) with the split app (4016286) as an always-bypass actor.After merge
Splitutopia-php/natspackages/natsfromutopia-php/monorepoutopia-php/natsfrom appwrite-labs/cloud'scomposer.json; it now arrives throughserver-cepackages/nats🤖 Generated with Claude Code