File tree Expand file tree Collapse file tree 4 files changed +34
-4
lines changed
Expand file tree Collapse file tree 4 files changed +34
-4
lines changed Original file line number Diff line number Diff line change @@ -56,4 +56,9 @@ public function markJobAsFailed($id);
5656 * Retry failed job
5757 */
5858 public function retryFailedJob ($ id , $ retryCount );
59+
60+ /**
61+ * Disconnect
62+ */
63+ public function disconnect ();
5964}
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ public function connect($connection)
4141 ]);
4242
4343 $ this ->config ['table ' ] = $ connection ['table ' ] ?? 'leaf_php_jobs ' ;
44+ $ this ->config ['schedule.table ' ] = $ connection ['schedule.table ' ] ?? 'leaf_php_schedules ' ;
4445
4546 return $ this ;
4647 }
@@ -72,7 +73,7 @@ public function popJobFromQueue($id)
7273 $ this ->db
7374 ->delete ($ this ->config ['table ' ])
7475 ->where ([
75- ' id ' => $ id ,
76+ " id " => $ id ,
7677 ])
7778 ->execute ();
7879
@@ -150,11 +151,11 @@ public function retryFailedJob($id, $retryCount)
150151 $ this ->db
151152 ->update ($ this ->config ['table ' ])
152153 ->params ([
153- ' status ' => ' pending ' ,
154- ' retry_count ' => (int ) $ retryCount + 1 ,
154+ " status " => " pending " ,
155+ " retry_count " => (int ) $ retryCount + 1 ,
155156 ])
156157 ->where ([
157- ' id ' => $ id ,
158+ " id " => $ id ,
158159 ])
159160 ->execute ();
160161
@@ -166,4 +167,12 @@ public function retryFailedJob($id, $retryCount)
166167
167168 return true ;
168169 }
170+
171+ /**
172+ * @inheritDoc
173+ */
174+ public function disconnect ()
175+ {
176+ $ this ->db ->close ();
177+ }
169178}
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ public function __construct()
2727 public function connect ($ connection )
2828 {
2929 $ this ->config ['table ' ] = $ connection ['table ' ] ?? 'leaf_php_jobs ' ;
30+ $ this ->config ['schedule.table ' ] = $ connection ['schedule.table ' ] ?? 'leaf_php_schedules ' ;
3031
3132 if (redis ()->ping ()) {
3233 $ this ->redis = redis ();
@@ -183,4 +184,12 @@ public static function v4()
183184 \mt_rand (0 , 0xffff )
184185 );
185186 }
187+
188+ /**
189+ * @inheritDoc
190+ */
191+ public function disconnect ()
192+ {
193+ $ this ->redis ->close ();
194+ }
186195}
Original file line number Diff line number Diff line change @@ -31,17 +31,24 @@ protected function handle()
3131 $ this ->writeln ("> Queue table not found. Creating queue table... " );
3232
3333 \Leaf \FS \File::copy (__DIR__ . '/stubs/schema.yml ' , DatabasePath ("{$ this ->queueConfig ['connections ' ][$ queue ]['table ' ]}.yml " ));
34+ \Leaf \FS \File::copy (__DIR__ . '/stubs/schedules.yml ' , DatabasePath ("{$ this ->queueConfig ['connections ' ][$ queue ]['schedules.table ' ]}.yml " ));
35+
3436 \Aloe \Core::run (
3537 "php leaf db:migrate {$ this ->queueConfig ['connections ' ][$ queue ]['table ' ]}" ,
3638 $ this ->output
3739 );
40+ \Aloe \Core::run (
41+ "php leaf db:migrate {$ this ->queueConfig ['connections ' ][$ queue ]['schedules.table ' ]}" ,
42+ $ this ->output
43+ );
3844 }
3945 } else {
4046 $ this ->writeln ('> Using redis connection for queue... ' );
4147 }
4248
4349 (new \Leaf \Worker ())
4450 ->queue ($ this ->queueConfig ['connections ' ][$ queue ])
51+ ->scheduler ($ this ->queueConfig ['connections ' ][$ queue ])
4552 ->run ();
4653
4754 return 0 ;
You can’t perform that action at this time.
0 commit comments