Skip to content

Commit 486a2d6

Browse files
committed
Refactoring queue system
1 parent 9d45946 commit 486a2d6

48 files changed

Lines changed: 330 additions & 455 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424

2525
## 5.1.2 - 2023-09-17
2626

27-
Fix `db_seed` helper
27+
Fix `app_db_seed` helper
2828

2929
Ref
3030

@@ -60,16 +60,15 @@ Reference #248
6060

6161
## 5.0.8 - 2023-05-24
6262

63-
Release 5.0.8
64-
63+
Release **5.0.8**
6564
Fixes test case errors
6665

6766
Reference #243
6867
From #242
6968

7069
## 5.0.7 - 2023-05-24
7170

72-
Release 5.0.7
71+
Release **5.0.7**
7372

7473
- Fixes the database relationship
7574
- Fixes the HTTP client
@@ -81,7 +80,7 @@ Fixes #240
8180

8281
## 5.0.6 - 2023-05-22
8382

84-
Release 5.0.6
83+
Release **5.0.6**
8584

8685
- Fixes get last insert id for pgsql
8786
- Add data validation custom message parser
@@ -95,7 +94,7 @@ References
9594

9695
## 5.0.5 - 2023-05-20
9796

98-
Release 5.0.5
97+
Release **5.0.5**
9998

10099
- Fix migration status table definition
101100
- Fix enum creation for pgsql
@@ -104,7 +103,7 @@ Reference #232
104103

105104
## 5.0.4 - 2023-05-19
106105

107-
Release 5.0.4
106+
Release **5.0.4**
108107

109108
- Fixes HTTP Client
110109
- Add variable binding to the env loader
@@ -124,7 +123,7 @@ Add many fixes
124123

125124
## 5.0.2 - 2023-05-16
126125

127-
Release for 5.0.2
126+
Release **5.0.2**
128127

129128
- Fix action dependency injector
130129
- Add the base error handler

docker-compose.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,3 +127,39 @@ services:
127127
interval: 10s
128128
timeout: 5s
129129
retries: 5
130+
rabbitmq:
131+
container_name: bowphp_rabbitmq
132+
image: rabbitmq:3.11-management
133+
restart: unless-stopped
134+
ports:
135+
- "5672:5672"
136+
- "15672:15672"
137+
environment:
138+
RABBITMQ_DEFAULT_USER: guest
139+
RABBITMQ_DEFAULT_PASS: guest
140+
networks:
141+
- bowphp_network
142+
healthcheck:
143+
test: ["CMD", "rabbitmq-diagnostics", "ping"]
144+
interval: 10s
145+
timeout: 5s
146+
retries: 5
147+
minio:
148+
container_name: bowphp_minio
149+
image: minio/minio
150+
restart: unless-stopped
151+
ports:
152+
- "9000:9000"
153+
- "9001:9001"
154+
environment:
155+
MINIO_ROOT_USER: minioadmin
156+
MINIO_ROOT_PASSWORD: minioadmin
157+
command: server /data --console-address ":9001"
158+
networks:
159+
- bowphp_network
160+
healthcheck:
161+
test: ["CMD", "mc", "alias", "set", "local", "http://localhost:9000", "minioadmin", "minioadmin"]
162+
interval: 10s
163+
timeout: 5s
164+
retries: 5
165+

src/Console/Command.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Bow\Console\Command\Generator\GenerateServiceCommand;
2121
use Bow\Console\Command\Generator\GenerateSessionCommand;
2222
use Bow\Console\Command\Generator\GenerateAppEventCommand;
23-
use Bow\Console\Command\Generator\GenerateProducerCommand;
23+
use Bow\Console\Command\Generator\GenerateWorkerCommand;
2424
use Bow\Console\Command\Generator\GenerateExceptionCommand;
2525
use Bow\Console\Command\Generator\GenerateMessagingCommand;
2626
use Bow\Console\Command\Generator\GenerateMigrationCommand;
@@ -57,7 +57,7 @@ class Command extends AbstractCommand
5757
"add:validation" => GenerateValidationCommand::class,
5858
"add:event" => GenerateAppEventCommand::class,
5959
"add:listener" => GenerateEventListenerCommand::class,
60-
"add:producer" => GenerateProducerCommand::class,
60+
"add:producer" => GenerateWorkerCommand::class,
6161
"add:command" => GenerateConsoleCommand::class,
6262
"add:message" => GenerateMessagingCommand::class,
6363
"run:console" => ReplCommand::class,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Bow\Console\Command\Generator;
6+
7+
use Bow\Console\AbstractCommand;
8+
use Bow\Console\Color;
9+
use Bow\Console\Generator;
10+
11+
class GenerateJobCommand extends AbstractCommand
12+
{
13+
/**
14+
* Add job
15+
*
16+
* @param string $job
17+
* @return void
18+
*/
19+
public function run(string $job): void
20+
{
21+
$generator = new Generator(
22+
$this->setting->getJobDirectory(),
23+
$job
24+
);
25+
26+
if ($generator->fileExists()) {
27+
echo Color::red("The job already exists");
28+
exit(1);
29+
}
30+
31+
$generator->write('job', [
32+
'baseNamespace' => $this->namespaces['job'] ?? 'App\\Jobs'
33+
]);
34+
35+
echo Color::green("The job has been well created.");
36+
exit(0);
37+
}
38+
}

src/Console/Command/Generator/GenerateProducerCommand.php

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/Console/Command/MigrationCommand.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
namespace Bow\Console\Command;
66

77
use Exception;
8-
use ErrorException;
9-
use Bow\Support\Str;
108
use Bow\Console\Color;
119
use Bow\Database\Database;
1210
use Bow\Database\QueryBuilder;
@@ -381,6 +379,6 @@ private function getMigrationTable(): QueryBuilder
381379
{
382380
$migration_status_table = config('database.migration', 'migrations');
383381

384-
return db_table($migration_status_table);
382+
return app_db_table($migration_status_table);
385383
}
386384
}

src/Console/Console.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Console
6060
'service',
6161
'exception',
6262
'event',
63-
'producer',
63+
'job',
6464
'command',
6565
'listener',
6666
'message'
@@ -519,13 +519,13 @@ private function help(?string $command = null): int
519519
\033[0;33mgenerate:session-table\033[00m For generate the preset table for session
520520
\033[0;33mgenerate:cache-table\033[00m For generate the preset table for cache
521521
\033[0;33mgenerate:queue-table\033[00m For generate the preset table for queue
522-
\033[0;33mgenerate:notification-table\033[00m For generate the preset table for notification
522+
\033[0;33mgenerate:notification-table\033[00m For generate the preset table for notification
523523
\033[0;33mgenerate:key\033[00m Create new app key
524-
\033[0;33mflush:worker\033[00m Flush all queues
524+
\033[0;33mflush:worker\033[00m Flush all queues
525525
526526
\033[0;32mADD\033[00m Create a user class
527527
\033[0;33madd:middleware\033[00m Create new middleware
528-
\033[0;33madd:configuration\033[00m Create new configuration
528+
\033[0;33madd:configuration\033[00m Create new configuration
529529
\033[0;33madd:service\033[00m Create new service
530530
\033[0;33madd:exception\033[00m Create new exception
531531
\033[0;33madd:controller\033[00m Create new controller
@@ -535,7 +535,7 @@ private function help(?string $command = null): int
535535
\033[0;33madd:migration\033[00m Create a new migration
536536
\033[0;33madd:event\033[00m Create a new event
537537
\033[0;33madd:listener\033[00m Create a new event listener
538-
\033[0;33madd:producer\033[00m Create a new producer
538+
\033[0;33madd:job\033[00m Create a new job
539539
\033[0;33madd:command\033[00m Create a new bow console command
540540
\033[0;33madd:message\033[00m Create a new bow messaging
541541
@@ -580,15 +580,15 @@ private function help(?string $command = null): int
580580
581581
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:controller name [option] For create a new controller
582582
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:middleware name For create a new middleware
583-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:configuration name For create a new configuration
583+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:configuration name For create a new configuration
584584
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:service name For create a new service
585585
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:exception name For create a new exception
586586
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:model name [option] For create a new model
587587
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:validation name For create a new validation
588588
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:seeder name [--seed=n] For create a new seeder
589589
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:migration name For create a new migration
590590
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:event name For create a new event listener
591-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:producer name For create a new queue producer
591+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:job name For create a new queue job
592592
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:command name For create a new bow console command
593593
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add:message name For create a new bow messaging
594594
\033[0;33m$\033[00m php \033[0;34mbow\033[00m add help For display this
@@ -635,9 +635,9 @@ private function help(?string $command = null): int
635635
run:console [--include=filename.php] [--prompt=prompt_name]
636636
run:worker [--queue=default] [--connexion=beanstalkd,sqs,redis,database] [--tries=duration] [--sleep=duration] [--timeout=duration]
637637
638-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m run:console\033[00m Show psysh php REPL
638+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m run:console\033[00m Show psysh php REPL for debug you code
639639
\033[0;33m$\033[00m php \033[0;34mbow\033[00m run:server\033[00m [option] Start local development server
640-
\033[0;33m$\033[00m php \033[0;34mbow\033[00m run:worker\033[00m [option] Start worker/consumer for handle the producer
640+
\033[0;33m$\033[00m php \033[0;34mbow\033[00m run:worker\033[00m [option] Start workerr for handle the queue jobs
641641
642642
U; // phpcs:enable
643643
break;

src/Console/Setting.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,11 @@ class Setting
137137
private string $service_directory;
138138

139139
/**
140-
* The producer directory
140+
* The job directory
141141
*
142142
* @var string
143143
*/
144-
private string $producer_directory;
145-
144+
private string $job_directory;
146145
/**
147146
* The command directory
148147
*
@@ -403,24 +402,24 @@ public function setServiceDirectory(string $service_directory): void
403402
}
404403

405404
/**
406-
* Get the producer directory
405+
* Get the job directory
407406
*
408407
* @return string
409408
*/
410-
public function getProducerDirectory(): string
409+
public function getJobDirectory(): string
411410
{
412-
return $this->producer_directory;
411+
return $this->job_directory;
413412
}
414413

415414
/**
416-
* Set the producer directory
415+
* Set the job directory
417416
*
418-
* @param string $producer_directory
417+
* @param string $job_directory
419418
* @return void
420419
*/
421-
public function setProducerDirectory(string $producer_directory): void
420+
public function setJobDirectory(string $job_directory): void
422421
{
423-
$this->producer_directory = $producer_directory;
422+
$this->job_directory = $job_directory;
424423
}
425424

426425
/**
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace {baseNamespace}{namespace};
44

5-
use Bow\Queue\ProducerService;
5+
use Bow\Queue\QueueJob;
66

7-
class {className} extends ProducerService
7+
class {className} extends QueueJob
88
{
99
/**
1010
* {className} constructor
@@ -17,7 +17,7 @@ class {className} extends ProducerService
1717
}
1818

1919
/**
20-
* Handle producer
20+
* Handle job action
2121
*
2222
* @return void
2323
*/

src/Database/Collection.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,6 @@ public function toArray(): array
5757
return $arr;
5858
}
5959

60-
/**
61-
* Allows you to delete all the selected recordings
62-
*
63-
* @return void
64-
*/
65-
public function dropAll(): void
66-
{
67-
$this->each(
68-
function (Model $model) {
69-
$model->delete();
70-
}
71-
);
72-
}
73-
7460
/**
7561
* @inheritdoc
7662
*/

0 commit comments

Comments
 (0)