Skip to content

Centralize type dispatch in ClientEvaluator, fix addApiHook singleton bypass, simplify TestFeatureProvider Hub#109

Merged
EtaCassiopeia merged 3 commits into
mainfrom
fix/deferred-refactors
May 12, 2026
Merged

Centralize type dispatch in ClientEvaluator, fix addApiHook singleton bypass, simplify TestFeatureProvider Hub#109
EtaCassiopeia merged 3 commits into
mainfrom
fix/deferred-refactors

Conversation

@EtaCassiopeia
Copy link
Copy Markdown
Owner

@EtaCassiopeia EtaCassiopeia commented Mar 31, 2026

Summary

ClientEvaluator: centralized type dispatch replaces repetitive string-match arms

evaluateFromClient had 6 identical case "Type" => evaluateViaTypeclass(key, default.asInstanceOf[Type], ...) arms. Added ClientEvaluator.evaluateStandard that centralizes the type-name → evaluator lookup, reducing the match to a single case Some(...) arm. Object and custom type paths remain as special cases.

addApiHook / clearApiHooks bypass isolated OpenFeatureAPI instances

These were static companion methods calling OpenFeatureAPI.getInstance() — the global singleton. When FeatureFlagRegistry creates clients with isolated API instances via OpenFeatureAPIFactory.create(), hooks added through the companion never reached those clients. Moved to FeatureFlags trait methods, implemented in FeatureFlagsLive using the injected api instance. Companion accessors now delegate through the service.

TestFeatureProvider: Ref[Hub] replaced with plain Hub

eventsHubRef: Ref[Hub[ProviderEvent]] was never updated to a new Hub — the Ref added unnecessary indirection on every event publish and stream subscription. Replaced with a direct eventsHub: Hub[ProviderEvent] field.

Not addressed (cross-compilation constraints)

  • implicitgiven/using: required for Scala 2.13 compatibility in shared source
  • CountDownLatch → ZIO Promise: Java SDK's initialize() requires actual thread blocking at the Java/ZIO boundary

@EtaCassiopeia EtaCassiopeia changed the title Refactor type dispatch, addApiHook isolation, and TestFeatureProvider Hub Centralize type dispatch in ClientEvaluator, fix addApiHook singleton bypass, simplify TestFeatureProvider Hub Mar 31, 2026
Base automatically changed from fix/codebase-review-remaining to fix/codebase-review-fixes May 12, 2026 23:19
Base automatically changed from fix/codebase-review-fixes to main May 12, 2026 23:33
@EtaCassiopeia EtaCassiopeia force-pushed the fix/deferred-refactors branch from f12c9a5 to 8816688 Compare May 12, 2026 23:35
@EtaCassiopeia EtaCassiopeia merged commit 767dd3e into main May 12, 2026
1 check passed
@EtaCassiopeia EtaCassiopeia deleted the fix/deferred-refactors branch May 12, 2026 23:43
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