Fix #59: inject the cache store into LocalSimulatorDriver and read task_ttl from its own config - #106
Open
corgab wants to merge 2 commits into
Open
Fix #59: inject the cache store into LocalSimulatorDriver and read task_ttl from its own config#106corgab wants to merge 2 commits into
corgab wants to merge 2 commits into
Conversation
…nd read task_ttl from its own config LocalSimulatorDriver was the only driver reaching Laravel directly: the Cache facade for the dispatched results and the global config() helper for their retention. It now takes a cache repository through its constructor, next to the PythonExecutor, and reads the retention from its own config array as `task_ttl`, so the option moves from the top-level aether.local_task_ttl to aether.drivers.local.task_ttl (same env var). The unit test no longer needs a facade root or a bare container: an in-memory repository is injected, and a mocked one pins the TTL passed to put() for a configured, string, absent, zero and garbage value. Closes #59
…default createLocalDriver() copies a top-level aether.local_task_ttl into the driver config when drivers.local.task_ttl is absent, so a config file published before the key moved keeps its retention. The shipped default now points at LocalSimulatorDriver::DEFAULT_TASK_TTL, and the constructor docblock notes that the injected store is fixed for the driver's lifetime.
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.
Summary
LocalSimulatorDriverwas the only driver reaching Laravel directly: theCachefacade for the dispatched results and the globalconfig()helper for their retention. Every other driver reads its options from the injected config array and touches the framework only through injected collaborators. This PR brings the local driver in line, as the issue proposes.Plan
Illuminate\Contracts\Cache\Repository), next to thePythonExecutor, and use it insubmitCircuit()/checkTask().task_ttl, which moves the option from the top-levelaether.local_task_ttltoaether.drivers.local.task_ttl. The env varAETHER_LOCAL_TASK_TTLis unchanged, and the manager keeps honouring the old key from an already published config file.put().Changes
src/Drivers/LocalSimulatorDriver.php: constructor(PythonExecutor $bridge, array $config, CacheRepository $cache);Cache::put()/Cache::get()become$this->cache->...;taskTtl()readstask_ttlwith aDEFAULT_TASK_TTL = 3600fallback for a blank, non-numeric or non-positive value. The constructor docblock notes that the injected store is fixed for the driver's lifetime (it is rebuilt afterQuantum::forgetDrivers()), where the facade re-resolved the default store on every call.src/QuantumManager.php:createLocalDriver()resolves the cache contract from the container, and copies a legacy top-levelaether.local_task_ttlinto the driver config whentask_ttlis absent (an explicittask_ttlalways wins).config/aether.php: the "Local Task Retention" block moves underdrivers.localastask_ttl, comment included; its default referencesLocalSimulatorDriver::DEFAULT_TASK_TTLso the value lives in one place.README.md: the local->dispatch()paragraph names the option and its default.tests/Unit/Drivers/LocalSimulatorDriverTest.php: theCache::swap()and bare-container setup are gone; the driver is built with anArrayStorerepository. New dataset test: a configured, string-from-env, absent, zero and garbagetask_ttleach produce the expectedput()TTL.tests/Feature/ServiceProviderTest.php: shipped default, legacy-key fallback, explicit key precedence.tests/Feature/LifecycleEventsTest.php,tests/Feature/AsynchronousExecutionTest.php: hand-built local drivers pass the app's cache repository.Upgrade notes
LocalSimulatorDriver::__construct()takes a third argument, the cache repository. Code that builds the driver by hand (aQuantum::extend('local', ...)closure, a subclass) passesapp(\Illuminate\Contracts\Cache\Repository::class)or any repository of its choice.aether.local_task_ttlis nowaether.drivers.local.task_ttl. A published config file with the old key keeps working through the manager's fallback; move the key when you next republish.Overlap
#104 (#57) adds
AetherConfig::localTaskTtl()over the old top-level key and has the driver read through it. If this PR merges first, that method and the driver change in #104 can be dropped; if #104 merges first, this PR's version oftaskTtl()and the moved config key win. #103 (#66) types the driver config;task_ttlcan joinDriverConfigthere as a positive integer.Tests
vendor/bin/pint --testpasses.vendor/bin/pest --compact: 799 tests, 1 skipped (791 before: +8).Closes #59