Skip to content

Commit 6d6c7d7

Browse files
authored
Merge pull request #1605 from bakaphp/feat-add-more-queues
feat: morequeues
2 parents 0a9d024 + 6941e57 commit 6d6c7d7

File tree

5 files changed

+435
-266
lines changed

5 files changed

+435
-266
lines changed

app/GraphQL/Social/Mutations/Messages/MessageManagementMutation.php

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

77
use Illuminate\Database\Eloquent\ModelNotFoundException;
88
use Illuminate\Support\Facades\Validator;
9+
use Illuminate\Validation\Rule;
910
use Kanvas\Apps\Models\Apps;
1011
use Kanvas\Auth\Exceptions\AuthenticationException;
1112
use Kanvas\Exceptions\ValidationException;
@@ -31,6 +32,22 @@ public function create(mixed $root, array $request): Message
3132
$company = $user->getCurrentCompany();
3233
$messageData = $request['input'];
3334

35+
$rules = [
36+
'system_modules_id' => 'nullable',
37+
'entity_id' => [
38+
'nullable',
39+
Rule::requiredIf(function () use ($messageData) {
40+
return array_key_exists('system_modules_id', $messageData) && ! $messageData['system_modules_id'] !== null;
41+
}),
42+
],
43+
];
44+
45+
$validator = Validator::make($messageData, $rules);
46+
47+
if ($validator->fails()) {
48+
throw new ValidationException($validator->messages()->__toString());
49+
}
50+
3451
try {
3552
$messageType = MessagesTypesRepository::getByVerb($messageData['message_verb'], $app);
3653
} catch (ModelNotFoundException $e) {
@@ -55,7 +72,7 @@ public function create(mixed $root, array $request): Message
5572
$action = new CreateMessageAction(
5673
$data,
5774
$systemModule,
58-
$messageData['entity_id']
75+
$messageData['entity_id'] ?? null
5976
);
6077
$message = $action->execute();
6178

@@ -147,7 +164,11 @@ public function detachTopicToMessage(mixed $root, array $request): Message
147164
public function interaction(mixed $root, array $request): Message
148165
{
149166
$message = Message::getById((int)$request['id']);
150-
$action = new CreateMessageAction($message, auth()->user(), ActivityTypeEnum::from($request['type']));
167+
$action = new CreateMessageAction(
168+
$message,
169+
auth()->user(),
170+
ActivityTypeEnum::from($request['type'])
171+
);
151172
$action->execute();
152173

153174
return $message;

docker-compose.1.x.yml

Lines changed: 208 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,136 +1,211 @@
11
services:
2-
php:
3-
container_name: php${APP_CONTAINER_NAME}
4-
build:
5-
context: .
6-
dockerfile: development.Dockerfile
7-
extra_hosts:
8-
- 'host.docker.internal:host-gateway'
9-
environment:
10-
WWWUSER: '${WWWUSER}'
11-
LARAVEL_SAIL: 1
12-
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
13-
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
14-
volumes:
15-
- '.:/var/www/html'
16-
- ./docker/docker-php-ext-opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
17-
- ./docker/php.ini:/usr/local/etc/php/conf.d/xz-custom.ini
18-
networks:
19-
- sail
20-
queue:
21-
container_name: queue
22-
restart: always
23-
build:
24-
context: .
25-
dockerfile: development.Dockerfile
26-
extra_hosts:
27-
- 'host.docker.internal:host-gateway'
28-
command: ["sh", "-c", "php artisan config:cache && php artisan queue:work --tries=3 --timeout=3750"]
29-
environment:
30-
WWWUSER: '${WWWUSER}'
31-
LARAVEL_SAIL: 1
32-
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
33-
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
34-
volumes:
35-
- '.:/var/www/html'
36-
- ./docker/docker-php-ext-opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
37-
- ./docker/php.ini:/usr/local/etc/php/conf.d/xz-custom.ini
38-
networks:
39-
- sail
40-
queue-social:
41-
container_name: queue-social
42-
restart: always
43-
build:
44-
context: .
45-
dockerfile: development.Dockerfile
46-
extra_hosts:
47-
- 'host.docker.internal:host-gateway'
48-
command: ["sh", "-c", "php artisan config:cache && php artisan queue:work --queue kanvas-social --tries=3 --timeout=3750"]
49-
environment:
50-
WWWUSER: '${WWWUSER}'
51-
LARAVEL_SAIL: 1
52-
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
53-
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
54-
volumes:
55-
- '.:/var/www/html'
56-
- ./docker/docker-php-ext-opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
57-
- ./docker/php.ini:/usr/local/etc/php/conf.d/xz-custom.ini
58-
networks:
59-
- sail
60-
queue-notifications:
61-
container_name: queue-notifications
62-
restart: always
63-
build:
64-
context: .
65-
dockerfile: development.Dockerfile
66-
extra_hosts:
67-
- 'host.docker.internal:host-gateway'
68-
command: ["sh", "-c", "php artisan config:cache && php artisan queue:work --queue notifications --tries=3 --timeout=3750"]
69-
environment:
70-
WWWUSER: '${WWWUSER}'
71-
LARAVEL_SAIL: 1
72-
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
73-
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
74-
volumes:
75-
- '.:/var/www/html'
76-
- ./docker/docker-php-ext-opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
77-
- ./docker/php.ini:/usr/local/etc/php/conf.d/xz-custom.ini
78-
networks:
79-
- sail
80-
laravel-scheduler:
81-
container_name: laravel-scheduler
82-
restart: always
83-
build:
84-
context: .
85-
dockerfile: development.Dockerfile
86-
extra_hosts:
87-
- 'host.docker.internal:host-gateway'
88-
command: ["sh", "-c", "php artisan config:cache && php artisan schedule:work"]
89-
environment:
90-
WWWUSER: '${WWWUSER}'
91-
LARAVEL_SAIL: 1
92-
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
93-
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
94-
volumes:
95-
- '.:/var/www/html'
96-
- ./docker/docker-php-ext-opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
97-
- ./docker/php.ini:/usr/local/etc/php/conf.d/xz-custom.ini
98-
networks:
99-
- sail
100-
nginx:
101-
image: nginx:latest
102-
container_name: nginx${APP_CONTAINER_NAME}
103-
ports:
104-
- "80:80"
105-
links:
106-
- php
107-
volumes:
108-
- '.:/var/www/html'
109-
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
110-
networks:
111-
- sail
112-
depends_on:
113-
- php
114-
healthcheck:
115-
test: ["CMD", "service", "nginx", "status"]
116-
retries: 3
117-
timeout: 5s
118-
redis:
119-
container_name: redis${APP_CONTAINER_NAME}
120-
image: 'redis:alpine'
121-
ports:
122-
- '${FORWARD_REDIS_PORT:-6379}:6379'
123-
volumes:
124-
- 'sail-redis:/data'
125-
networks:
126-
- sail
127-
healthcheck:
128-
test: [ "CMD", "redis-cli", "ping" ]
129-
retries: 3
130-
timeout: 5s
2+
php:
3+
container_name: php${APP_CONTAINER_NAME}
4+
build:
5+
context: .
6+
dockerfile: development.Dockerfile
7+
extra_hosts:
8+
- "host.docker.internal:host-gateway"
9+
environment:
10+
WWWUSER: "${WWWUSER}"
11+
LARAVEL_SAIL: 1
12+
XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
13+
XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
14+
volumes:
15+
- ".:/var/www/html"
16+
- ./docker/docker-php-ext-opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
17+
- ./docker/php.ini:/usr/local/etc/php/conf.d/xz-custom.ini
18+
networks:
19+
- sail
20+
21+
queue:
22+
container_name: queue
23+
restart: always
24+
build:
25+
context: .
26+
dockerfile: development.Dockerfile
27+
extra_hosts:
28+
- "host.docker.internal:host-gateway"
29+
command:
30+
[
31+
"sh",
32+
"-c",
33+
"php artisan config:cache && php artisan queue:work --tries=3 --timeout=3750",
34+
]
35+
environment:
36+
WWWUSER: "${WWWUSER}"
37+
LARAVEL_SAIL: 1
38+
XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
39+
XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
40+
volumes:
41+
- ".:/var/www/html"
42+
- ./docker/docker-php-ext-opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
43+
- ./docker/php.ini:/usr/local/etc/php/conf.d/xz-custom.ini
44+
networks:
45+
- sail
46+
47+
queue2:
48+
container_name: queue2
49+
restart: always
50+
build:
51+
context: .
52+
dockerfile: development.Dockerfile
53+
extra_hosts:
54+
- "host.docker.internal:host-gateway"
55+
command:
56+
[
57+
"sh",
58+
"-c",
59+
"php artisan config:cache && php artisan queue:work --tries=3 --timeout=3750",
60+
]
61+
environment:
62+
WWWUSER: "${WWWUSER}"
63+
LARAVEL_SAIL: 1
64+
XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
65+
XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
66+
volumes:
67+
- ".:/var/www/html"
68+
- ./docker/docker-php-ext-opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
69+
- ./docker/php.ini:/usr/local/etc/php/conf.d/xz-custom.ini
70+
networks:
71+
- sail
72+
73+
queue3:
74+
container_name: queue3
75+
restart: always
76+
build:
77+
context: .
78+
dockerfile: development.Dockerfile
79+
extra_hosts:
80+
- "host.docker.internal:host-gateway"
81+
command:
82+
[
83+
"sh",
84+
"-c",
85+
"php artisan config:cache && php artisan queue:work --tries=3 --timeout=3750",
86+
]
87+
environment:
88+
WWWUSER: "${WWWUSER}"
89+
LARAVEL_SAIL: 1
90+
XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
91+
XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
92+
volumes:
93+
- ".:/var/www/html"
94+
- ./docker/docker-php-ext-opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
95+
- ./docker/php.ini:/usr/local/etc/php/conf.d/xz-custom.ini
96+
networks:
97+
- sail
98+
99+
queue-social:
100+
container_name: queue-social
101+
restart: always
102+
build:
103+
context: .
104+
dockerfile: development.Dockerfile
105+
extra_hosts:
106+
- "host.docker.internal:host-gateway"
107+
command:
108+
[
109+
"sh",
110+
"-c",
111+
"php artisan config:cache && php artisan queue:work --queue kanvas-social --tries=3 --timeout=3750",
112+
]
113+
environment:
114+
WWWUSER: "${WWWUSER}"
115+
LARAVEL_SAIL: 1
116+
XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
117+
XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
118+
volumes:
119+
- ".:/var/www/html"
120+
- ./docker/docker-php-ext-opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
121+
- ./docker/php.ini:/usr/local/etc/php/conf.d/xz-custom.ini
122+
networks:
123+
- sail
124+
125+
queue-notifications:
126+
container_name: queue-notifications
127+
restart: always
128+
build:
129+
context: .
130+
dockerfile: development.Dockerfile
131+
extra_hosts:
132+
- "host.docker.internal:host-gateway"
133+
command:
134+
[
135+
"sh",
136+
"-c",
137+
"php artisan config:cache && php artisan queue:work --queue notifications --tries=3 --timeout=3750",
138+
]
139+
environment:
140+
WWWUSER: "${WWWUSER}"
141+
LARAVEL_SAIL: 1
142+
XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
143+
XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
144+
volumes:
145+
- ".:/var/www/html"
146+
- ./docker/docker-php-ext-opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
147+
- ./docker/php.ini:/usr/local/etc/php/conf.d/xz-custom.ini
148+
networks:
149+
- sail
150+
151+
laravel-scheduler:
152+
container_name: laravel-scheduler
153+
restart: always
154+
build:
155+
context: .
156+
dockerfile: development.Dockerfile
157+
extra_hosts:
158+
- "host.docker.internal:host-gateway"
159+
command:
160+
["sh", "-c", "php artisan config:cache && php artisan schedule:work"]
161+
environment:
162+
WWWUSER: "${WWWUSER}"
163+
LARAVEL_SAIL: 1
164+
XDEBUG_MODE: "${SAIL_XDEBUG_MODE:-off}"
165+
XDEBUG_CONFIG: "${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}"
166+
volumes:
167+
- ".:/var/www/html"
168+
- ./docker/docker-php-ext-opcache.ini:/usr/local/etc/php/conf.d/docker-php-ext-opcache.ini
169+
- ./docker/php.ini:/usr/local/etc/php/conf.d/xz-custom.ini
170+
networks:
171+
- sail
172+
173+
nginx:
174+
image: nginx:latest
175+
container_name: nginx${APP_CONTAINER_NAME}
176+
ports:
177+
- "80:80"
178+
links:
179+
- php
180+
volumes:
181+
- ".:/var/www/html"
182+
- ./docker/nginx.conf:/etc/nginx/conf.d/default.conf
183+
networks:
184+
- sail
185+
depends_on:
186+
- php
187+
healthcheck:
188+
test: ["CMD", "service", "nginx", "status"]
189+
retries: 3
190+
timeout: 5s
191+
192+
redis:
193+
container_name: redis${APP_CONTAINER_NAME}
194+
image: "redis:alpine"
195+
ports:
196+
- "${FORWARD_REDIS_PORT:-6379}:6379"
197+
volumes:
198+
- "sail-redis:/data"
199+
networks:
200+
- sail
201+
healthcheck:
202+
test: ["CMD", "redis-cli", "ping"]
203+
retries: 3
204+
timeout: 5s
205+
131206
networks:
132-
sail:
133-
driver: bridge
207+
sail:
208+
driver: bridge
134209
volumes:
135-
sail-redis:
136-
driver: local
210+
sail-redis:
211+
driver: local

0 commit comments

Comments
 (0)