Expose the options that passed the filters - #10
Merged
Conversation
run() answers "which one option should I use", and the filtered set it picks from was unreachable: $filters is private, so a caller that has to act on every qualifying option — fanning a request out rather than balancing between them — had to re-implement filtering outside the class, or subclass to record filters as they were registered. getFilteredOptions() is that set, extracted from run() unchanged. run() now calls it and behaves exactly as before. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR exposes all options surviving the balancer's filters and delegates
Confidence Score: 4/5The PR is not yet safe to merge because its dependency constraint breaks installations that still resolve telemetry 0.1.x. The new ^0.4.0-only requirement conflicts with telemetry 0.1.x consumers even though the compatibility change is intended to support both telemetry series. Files Needing Attention: composer.json Important Files Changed
Prompt To Fix All With AI### Issue 1
composer.json:18
**Telemetry 0.1 compatibility is dropped**
When an existing consumer requires telemetry 0.1.x, the new `^0.4.0`-only constraint makes Composer reject the dependency graph, turning the intended additive compatibility widening into a breaking change.
```suggestion
"utopia-php/telemetry": "^0.1.0 || ^0.4.0"
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (4): Last reviewed commit: "Require telemetry 0.4" | Re-trigger Greptile |
Group's telemetry pin at 0.1.* makes this library uninstallable next to anything on the current utopia telemetry line: utopia-php/pools requires ^0.4.6, so any consumer pulling in pools — through utopia-php/client, for one — cannot also require balancer. The whole surface Group touches is unchanged between the two lines. The Adapter::createHistogram and Histogram::record signatures are identical, and Adapter\None exists in both, so the constraint is widened rather than the code changed. Verified against 0.4.6: tests, PHPStan --level max and PSR-12 all pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Meldiron
added a commit
to utopia-php/cdn
that referenced
this pull request
Aug 13, 2026
CdnBalancer existed to work around a missing accessor, not to add anything: run() returns one option and $filters is private, so the only way to reach the filtered set was to shadow the filters on the way in. utopia-php/balancer#10 exposes getFilteredOptions(), so the adapter now takes an ordinary Utopia\Balancer\Balancer and the subclass is gone. Options are checked to be CdnOption where they are used, since a plain balancer accepts any Option. Provider becomes a class of string constants, matching how the rest of this library and appwrite/appwrite carry these values, and how Certificates\Status already reads. Extend/ now holds the one thing it was for: a typed option. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
4 tasks
TorstenDittmann
approved these changes
Aug 13, 2026
Review preferred caret syntax. ^0.1.0 on its own cannot work: below 1.0.0 Composer's caret is patch-only, so it resolves 0.1.0 or 0.1.1 and still conflicts with utopia-php/pools at ^0.4.6. Both series have to be named. Same resolution as 0.1.*|0.4.*, in the requested style. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Drops the 0.1 series rather than supporting both. 0.1 was already unreachable for any consumer that also pulls in utopia-php/pools, which requires ^0.4.6, so keeping it alive supported a combination nothing could install. Requirements narrow rather than widen: telemetry 0.1.1 needed ext-protobuf and ext-opentelemetry, 0.4.6 needs only ext-protobuf. Breaking for a consumer pinning telemetry to 0.1. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
TorstenDittmann
approved these changes
Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Two changes that together make this library usable for fan-out, and installable alongside the current utopia stack.
1. Expose the options that passed the filters
run()answers "which one option should I use", and the set it picks from was not available to callers:$filtersis private andgetOptions()returns the unfiltered list. A caller that has to act on every qualifying option — fanning a request out to all of them rather than balancing between them — had only bad choices: re-implement filtering outside the class, or subclass and record filters as they are registered so they can be replayed.getFilteredOptions()is that set, extracted fromrun()verbatim.run()now calls it:Purely additive — no behaviour change to
run(),addFilter(),addOption()orGroup.2. Require telemetry 0.4
Group's pin atutopia-php/telemetry: 0.1.*makes this library uninstallable next to anything on the current telemetry line.utopia-php/poolsrequires^0.4.6, so any consumer that pulls in pools — throughutopia-php/client, for one — cannot also require balancer. That is a hard blocker, not a preference.The constraint moves to
^0.4.0. The 0.1 series is dropped rather than kept alongside, because it was already unreachable for any consumer that also pulls in pools — supporting both would keep a combination alive that nothing can install.No code changes: the entire surface
Grouptouches is identical between the two series.Adapter::createHistogram()andHistogram::record()have byte-identical signatures andAdapter\Noneexists in both.Platform requirements narrow, which is worth stating since it is the opposite of what a version bump usually does:
ext-protobufext-opentelemetryTest Plan
composer test— 6 tests, 69 assertions, all passing. The existingtestBalancercase is what provesrun()is unchanged: it drives filters and algorithms through the same sequence as before and was not touched.testFilteredOptionscovers the new method: unfiltered returns everything; one filter returns both survivors whererun()returns only the first; filters compose; keys are reindexed from zero; and a filter matching nothing returns[]whilerun()returnsnull.composer check(PHPStan--level max) reports[OK] No errors,composer lint(PSR-12) passes on all 9 files,composer validateis clean, and the lock resolves telemetry0.4.6.For the constraint itself I checked resolution rather than reasoning about it: a scratch project requiring
utopia-php/pools:^2.0plus a local copy of this library resolvesbalancer+pools 2.0.2+telemetry 0.4.6. The same project with the pre-existing0.1pin fails onYou can only install one version of a package. CI installs with--ignore-platform-reqs, soext-protobufis not a factor there.Breaking changes
Requiring
^0.4.0is breaking for a consumer that pins telemetry to0.1. Nothing in this repository does, but I cannot see every consumer of this library.Related PRs and Issues
Needed by utopia-php/cdn#5, which declares every CDN provider that may hold a cached response for a domain as an option and filters down to the ones fronting it. A cache purge has to reach all of them — evicting one provider and leaving another serving a stale response is the same as not purging — so it needs the survivors, not a winner. This deletes the
CdnBalancersubclass it was carrying to work around the missing accessor.Checklist
composer lintcomposer checkcomposer test🤖 Generated with Claude Code