LastKnownGoodExperimentProvider
Rasuvaeff\Yii3AbTestingDb\LastKnownGoodExperimentProvider
Class · rasuvaeff/yii3-ab-testing-db · Source · implements ExperimentProvider
Serves the last successfully read experiment set when the source fails.
Opt-in, and never silent. A database outage otherwise takes the whole application down with it, because the registry is built on every request. But serving stale definitions is a trade, not a free win: a kill switch flipped during the outage will not take effect, so every fallback is reported through the injected logger at error level. A deployment that cannot see those logs should not enable this decorator.
The first read has nothing to fall back to and rethrows — starting up against a broken database must fail loudly rather than serve an empty experiment set, which would look like "no experiments configured" and silently send every visitor to their fallback variant.
Constructor
new LastKnownGoodExperimentProvider(
ExperimentProvider $provider,
Psr\Log\LoggerInterface $logger,
)Methods
getExperiments()
getExperiments(): arrayhasLastKnownGood()
hasLastKnownGood(): boolWhether a successful read exists to use as a fallback.
servedStaleOnLastRead()
servedStaleOnLastRead(): boolWhether the most recent read served stale definitions.