Skip to content
This repository was archived by the owner on Jan 29, 2024. It is now read-only.

Commit cbfdba1

Browse files
committed
The process of processing data before sending it to the queue. Here we analyze the data and Supplement it with information from the heap.
1 parent 8bbcc46 commit cbfdba1

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/Commands/BulkWrite.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Bavix\Entry\Commands;
44

5+
use Bavix\LaravelClickHouse\Database\Eloquent\Model as Entry;
56
use Bavix\Entry\Services\BulkService;
67
use Bavix\Entry\Jobs\BulkWriter;
78
use Illuminate\Console\Command;
@@ -36,6 +37,7 @@ public function handle(): void
3637
$lock->block(1);
3738
// Lock acquired after waiting maximum of second...
3839
$batchSize = \config('entry.batchSize', 10000);
40+
$queueName = \config('entry.queueName', 'default');
3941
$keys = app(BulkService::class)->keys();
4042
foreach ($keys as $key) {
4143
[$bulkName, $class] = \explode(':', $key, 2);
@@ -47,10 +49,13 @@ public function handle(): void
4749
$bulkData[$itemKey] = \json_decode($itemValue, true);
4850
}
4951

50-
$queueName = \config('entry.queueName', 'default');
51-
$job = new BulkWriter(new $class, $bulkData);
52-
$job->onQueue($queueName);
53-
\dispatch($job);
52+
$modelEntry = new $class;
53+
$bulkData = $this->bulkHandling($modelEntry, $bulkData);
54+
if ($bulkData) {
55+
$job = new BulkWriter($modelEntry, $bulkData);
56+
$job->onQueue($queueName);
57+
\dispatch($job);
58+
}
5459
}
5560
}
5661
} catch (LockTimeoutException $timeoutException) {
@@ -60,4 +65,17 @@ public function handle(): void
6065
}
6166
}
6267

68+
/**
69+
* The process of processing data before sending it to the queue.
70+
* Here we analyze the data and Supplement it with information from the heap.
71+
*
72+
* @param Entry $entry
73+
* @param array $bulk
74+
* @return array
75+
*/
76+
protected function bulkHandling(Entry $entry, array $bulk): array
77+
{
78+
return $bulk;
79+
}
80+
6381
}

0 commit comments

Comments
 (0)