File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed
Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 1414 |
1515 */
1616
17- 'queue ' => env ('METRICS_QUEUE ' , false ),
17+ 'queue ' => env ('METRICS_QUEUE ' , false ) ? [
18+ 'connection ' => env ('QUEUE_CONNECTION ' , 'sync ' ),
19+ 'queue ' => null ,
20+ ] : false ,
1821];
Original file line number Diff line number Diff line change @@ -45,9 +45,11 @@ public function commit(): void
4545 }
4646
4747 if ($ queue = config ('metrics.queue ' )) {
48- CommitMetrics::dispatch ($ metrics , $ queue );
48+ CommitMetrics::dispatch ($ metrics )
49+ ->onQueue ($ queue ['queue ' ] ?? null )
50+ ->onConnection ($ queue ['connection ' ] ?? null );
4951 } else {
50- (new CommitMetrics ($ metrics, $ queue ))->handle ();
52+ (new CommitMetrics ($ metrics ))->handle ();
5153 }
5254
5355 $ this ->repository ->flush ();
Original file line number Diff line number Diff line change 66use Illuminate \Bus \Queueable ;
77use Illuminate \Contracts \Queue \ShouldQueue ;
88use Illuminate \Foundation \Bus \Dispatchable ;
9+ use Illuminate \Queue \InteractsWithQueue ;
910use Illuminate \Support \Collection ;
1011
1112class CommitMetrics implements ShouldQueue
1213{
13- use Dispatchable, Queueable;
14+ use Dispatchable, InteractsWithQueue, Queueable;
1415
1516 /**
1617 * Constructor.
1718 */
1819 public function __construct (
1920 public array $ metrics ,
20- public bool $ shouldQueue ,
2121 ) {}
2222
2323 /**
@@ -38,8 +38,10 @@ public function handle(): void
3838 ]));
3939 })
4040 ->each (function (Collection $ metrics ) {
41- if ($ this ->shouldQueue ) {
42- RecordMetric::dispatch ($ metrics );
41+ if (isset ($ this ->job )) {
42+ RecordMetric::dispatch ($ metrics )
43+ ->onQueue ($ this ->queue )
44+ ->onConnection ($ this ->connection );
4345 } else {
4446 (new RecordMetric ($ metrics ))->handle ();
4547 }
You can’t perform that action at this time.
0 commit comments