验证生产自动重算由受限任务容器处理
This commit is contained in:
parent
1c8ee6b047
commit
1e583a660d
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'batch_worker_enabled' => (bool) env('FINANCE_BATCH_WORKER_ENABLED', false),
|
||||
// Connection records supply addresses and credentials, never these defaults.
|
||||
'defaults' => ['enabled' => false, 'connection' => ['connect_timeout' => 5, 'query_timeout' => 15]],
|
||||
'sync' => [
|
||||
|
||||
@ -102,10 +102,15 @@ class AccountMappingResyncDispatcher
|
||||
public function spawnWorker(): void
|
||||
{
|
||||
// Production cron consumes the durable queue in the resource-limited batch profile.
|
||||
if (filter_var(env('FINANCE_BATCH_WORKER_ENABLED', false), FILTER_VALIDATE_BOOL)) {
|
||||
if (config('upstream_pipeline.batch_worker_enabled', false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->launchWorker();
|
||||
}
|
||||
|
||||
protected function launchWorker(): void
|
||||
{
|
||||
try {
|
||||
$php = escapeshellarg(PHP_BINARY ?: 'php');
|
||||
$command = 'cd ' . escapeshellarg(base_path())
|
||||
|
||||
@ -8,6 +8,36 @@ use Tests\TestCase;
|
||||
|
||||
class AccountMappingResyncDispatcherTest extends TestCase
|
||||
{
|
||||
public function test_production_leaves_queue_processing_to_the_limited_batch_worker(): void
|
||||
{
|
||||
config(['upstream_pipeline.batch_worker_enabled' => true]);
|
||||
$dispatcher = $this->recordingDispatcher();
|
||||
$dispatcher->spawnWorker();
|
||||
|
||||
$this->assertSame(0, $dispatcher->launches);
|
||||
}
|
||||
|
||||
public function test_local_development_still_launches_an_immediate_worker(): void
|
||||
{
|
||||
config(['upstream_pipeline.batch_worker_enabled' => false]);
|
||||
$dispatcher = $this->recordingDispatcher();
|
||||
$dispatcher->spawnWorker();
|
||||
|
||||
$this->assertSame(1, $dispatcher->launches);
|
||||
}
|
||||
|
||||
private function recordingDispatcher(): AccountMappingResyncDispatcher
|
||||
{
|
||||
return new class extends AccountMappingResyncDispatcher {
|
||||
public int $launches = 0;
|
||||
|
||||
protected function launchWorker(): void
|
||||
{
|
||||
$this->launches++;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public function test_all_taobao_family_platforms_trigger_the_matching_receipt_sources(): void
|
||||
{
|
||||
$reflection = new ReflectionClass(AccountMappingResyncDispatcher::class);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user