Skip to content

Port library to utopia-php conventions#1

Merged
ChiragAgg5k merged 3 commits into
mainfrom
feat/initial-port
Apr 22, 2026
Merged

Port library to utopia-php conventions#1
ChiragAgg5k merged 3 commits into
mainfrom
feat/initial-port

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

Summary

Rehome the base circuit-breaker library (originally developed at ChiragAgg5k/circuit-breaker) under the Utopia organisation so it can ship as utopia-php/circuit-breaker. Public behaviour, adapter surface, telemetry wiring, cache semantics, and test coverage are unchanged — this is a structural + cosmetic port only.

What changed

Namespaces & layout

Before After
src/CircuitBreaker.php (ChiragAgg5k) src/CircuitBreaker/CircuitBreaker.php (Utopia\CircuitBreaker)
src/CircuitState.php (ChiragAgg5k) src/CircuitBreaker/CircuitState.php (Utopia\CircuitBreaker)
src/CircuitBreaker/Adapter.php same path, namespace Utopia\CircuitBreaker
src/CircuitBreaker/Adapter/*.php same paths, namespace Utopia\CircuitBreaker\Adapter

composer.json

  • Package name → utopia-php/circuit-breaker
  • Authors → Team Appwrite <team@appwrite.io>
  • Keywords → ["php","framework","upf","utopia","circuit-breaker","fault-tolerance","resilience"]
  • PSR-4 → "Utopia\\CircuitBreaker\\": "src/CircuitBreaker"; dev "Utopia\\Tests\\": "tests"
  • Scripts renamed to the utopia standard (lint, format, check, test) while keeping the existing test:unit, test:e2e, test:e2e:docker, telemetry:up|scenario|down helpers
  • suggest keys updated to the new Utopia\CircuitBreaker\Adapter\… class names

Docs & branding

  • README.md rewritten with the utopia banner, badges (build / packagist / discord), marketing paragraph, and standard section ordering (Getting Started → Examples → Shared Cache → Telemetry → System Requirements → Tests → Copyright)
  • LICENSE copyright changed to Utopia

Tooling & CI

  • phpunit.xml.distphpunit.xml, phpstan.neon.distphpstan.neon (utopia uses the non-.dist names)
  • docker-composer.yml / docker-composer.telemetry.yml renamed to the standard docker-compose.* spelling (drops the typo, matches what every tutorial says)
  • .github/workflows/ci.yml split into:
    • linter.yml — pint lint + phpstan
    • tests.yml — unit tests on a PHP 8.2 / 8.3 / 8.4 matrix plus a Docker-based e2e job

Not changed

  • Public API of CircuitBreaker, CircuitState, and all adapters
  • Telemetry metric names (still breaker.*, optional prefix still works)
  • Adapter protocol (get / set / increment / delete)
  • Behaviour of shared cache state, half-open probing, event timestamps
  • PHPStan level (kept at 5 — utopia default is max; a follow-up PR can bump this)

Test plan

  • composer install (locally)
  • composer test10 tests, 50 assertions, all pass
  • composer check — PHPStan level 5, no errors
  • composer lint — Pint reports {"result":"pass"}
  • CI (linter + tests) on this PR
  • E2E Docker job (redis + swoole) on this PR

Bring the full base circuit-breaker library in under the Utopia
namespace and house it to match the shape of other utopia-php
packages (cache, pools, telemetry).

Namespaces
- ChiragAgg5k\CircuitBreaker -> Utopia\CircuitBreaker
- ChiragAgg5k\Tests -> Utopia\Tests
- Sources moved under src/CircuitBreaker/ (matches "src/<Foo>/<Foo>.php"
  PSR-4 layout used by the rest of utopia-php)

composer.json
- Name, description, authors, keywords, PSR-4 roots, suggest keys
- Utopia script names (lint / format / check / test, test:unit,
  test:e2e, test:e2e:docker, telemetry:up/scenario/down)

Docs & branding
- README rewritten with utopia banner, badges, marketing paragraph,
  section ordering, and API reference
- LICENSE copyright changed to "Utopia"

Tooling
- phpunit.xml.dist -> phpunit.xml, phpstan.neon.dist -> phpstan.neon
- docker-composer.yml / docker-composer.telemetry.yml renamed to the
  standard docker-compose.* spelling
- CI split into .github/workflows/linter.yml (pint + phpstan) and
  .github/workflows/tests.yml (unit tests on PHP 8.2/8.3/8.4 plus a
  Docker-based e2e job)

The public API, adapter surface, telemetry wiring, cache semantics,
and test coverage all behave exactly as before; this change is purely
structural + cosmetic. Unit tests, phpstan level 5, and pint all pass
locally.
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 22, 2026

Greptile Summary

This is a structural port of the circuit-breaker library from the ChiragAgg5k namespace into the utopia-php organisation, renaming the package, updating PSR-4 roots, realigning directory layout, splitting CI into linter.yml + tests.yml, and refreshing docs/branding. Public API, adapter contract, telemetry wiring, and test coverage are all unchanged.

Confidence Score: 5/5

Safe to merge — pure structural/namespace migration with no behavioural changes and full test coverage retained

All remaining findings are P2 style suggestions (unnecessary C extensions in linter workflow). No logic, correctness, or security issues were found.

No files require special attention beyond the minor extension cleanup in linter.yml

Important Files Changed

Filename Overview
.github/workflows/linter.yml New linting workflow; installs opentelemetry/protobuf C extensions that are unnecessary for Pint and PHPStan
.github/workflows/tests.yml New test workflow with unit matrix (PHP 8.2/8.3/8.4) and a Docker E2E job; extensions on unit jobs are plausible given telemetry test usage
src/CircuitBreaker/CircuitBreaker.php Namespace updated to Utopia\CircuitBreaker; no public API or behavioural changes detected
src/CircuitBreaker/Adapter/Redis.php Namespace updated to Utopia\CircuitBreaker\Adapter; implementation unchanged
src/CircuitBreaker/Adapter/SwooleTable.php Namespace updated to Utopia\CircuitBreaker\Adapter; implementation unchanged
composer.json Package renamed to utopia-php/circuit-breaker, PSR-4 roots updated, scripts aligned to utopia conventions
tests/unit/CircuitBreakerTest.php Namespace updated to Utopia\Tests\unit; test coverage and assertions are unchanged
phpunit.xml Renamed from phpunit.xml.dist; test suite configuration is identical
phpstan.neon Renamed from phpstan.neon.dist; level 5 with only src/ in paths (tests/ excluded, as noted separately)

Reviews (2): Last reviewed commit: "Address Greptile P2 findings" | Re-trigger Greptile

Comment thread .github/workflows/tests.yml Outdated
- tests.yml: drop opentelemetry/protobuf host extensions from the E2E
  job. The E2E step only shells out to `composer test:e2e:docker`; all
  PHP execution happens inside the Dockerfile container where those
  extensions are installed already.
- phpstan.neon: add `tests` to analysed paths so test helpers,
  anonymous-class cache adapters, and the custom telemetry subclass
  are covered. Paired with a narrow ignoreErrors block for two
  patterns the upstream type system can't express: the $values
  property on anonymous Counter/Gauge subclasses emitted by
  Utopia\Telemetry\Adapter\Test, and the defensive
  method_exists(Redis, 'getLastError') guard.
@ChiragAgg5k ChiragAgg5k merged commit a1647f7 into main Apr 22, 2026
6 checks passed
@ChiragAgg5k ChiragAgg5k deleted the feat/initial-port branch April 22, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant