Skip to content

Commit ff16e66

Browse files
authored
Remove redundant abstractions (#243)
WebInterface now invokes the application layers directly. That's okay, because the bus interface already abstracts the other contexts, so there is no reason to put another layer in between, especially because the type information would be lost through this additional layer. Also, when moving a context to its own service, message types and clients will be generated from definition files. That also makes the current abstractions even more redundant. Additionally, fix a frontend bug introduced by #232, which causes moves to be applied twice.
1 parent b4a66c5 commit ff16e66

File tree

31 files changed

+111
-736
lines changed

31 files changed

+111
-736
lines changed

assets/js/ConnectFour/Game.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ customElements.define('connect-four-game', class extends HTMLElement {
122122
}
123123

124124
_onPlayerMoved(event) {
125-
this._game.appendMove(event.detail);
125+
this._game.appendMove({
126+
x: event.detail.x,
127+
y: event.detail.y,
128+
color: event.detail.color,
129+
});
126130
}
127131

128132
_onGameWon(event) {

config/chat/services/chat.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
services:
2-
chat.chat-controller:
3-
class: Gaming\Chat\Presentation\Http\ChatController
4-
arguments: ['@chat.command-bus', '@chat.query-bus']
5-
62
chat.chat-gateway:
73
class: Gaming\Chat\Infrastructure\DoctrineChatGateway
84
arguments: ['@chat.doctrine-dbal', 'chat', 'message']

config/chat/services/consumer.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
factory: ['@gaming.message-broker.amqp-consumer-factory', 'create']
1010
arguments:
1111
- !service
12-
class: Gaming\Chat\Infrastructure\Messaging\CommandMessageHandler
12+
class: Gaming\Chat\Presentation\Messaging\CommandMessageHandler
1313
arguments: ['@chat.command-bus']
1414
- !service
1515
class: Gaming\Common\MessageBroker\Integration\AmqpLib\QueueConsumer\ConsumeQueues

config/connect-four/services/game.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
services:
2-
connect-four.game-controller:
3-
class: Gaming\ConnectFour\Port\Adapter\Http\GameController
4-
arguments: ['@connect-four.command-bus', '@connect-four.query-bus']
5-
62
connect-four.game-repository:
73
class: Gaming\ConnectFour\Port\Adapter\Persistence\Repository\DoctrineJsonGameRepository
84
arguments:

config/identity/services/user.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
services:
2-
identity.user-controller:
3-
class: Gaming\Identity\Port\Adapter\Http\UserController
4-
arguments: ['@identity.command-bus']
5-
62
identity.user-repository:
73
class: Gaming\Identity\Port\Adapter\Persistence\Repository\DoctrineUserRepository
84
arguments: ['@identity.doctrine-orm']

config/web-interface/services/console.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
Gaming\WebInterface\Presentation\Console\PublishRunningGamesCountToNchanCommand:
3-
arguments: ['@web-interface.connect-four-service', '@web-interface.browser-notifier']
3+
arguments: ['@connect-four.query-bus', '@web-interface.browser-notifier']
44
tags:
55
- name: console.command
66
command: web-interface:publish-running-games-count-to-nchan

config/web-interface/services/controller.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
services:
22
web-interface.page-controller:
33
class: Gaming\WebInterface\Presentation\Http\PageController
4-
arguments: ['@twig', '@web-interface.connect-four-service', '@web-interface.security']
4+
arguments: ['@twig', '@connect-four.query-bus', '@web-interface.security']
55
tags: ['controller.service_arguments']
66

77
web-interface.signup-controller:
88
class: Gaming\WebInterface\Presentation\Http\SignupController
99
arguments:
1010
- '@uri_signer'
1111
- '@web-interface.security'
12-
- '@web-interface.identity-service'
12+
- '@identity.command-bus'
1313
- '@gaming.form-violation-mapper'
1414
calls: [[setContainer, ['@Psr\Container\ContainerInterface']]]
1515
tags: ['controller.service_arguments', 'container.service_subscriber']
@@ -28,10 +28,10 @@ services:
2828

2929
web-interface.chat-controller:
3030
class: Gaming\WebInterface\Presentation\Http\ChatController
31-
arguments: ['@web-interface.chat-service', '@web-interface.security']
31+
arguments: ['@chat.command-bus', '@chat.query-bus', '@web-interface.security']
3232
tags: ['controller.service_arguments']
3333

3434
web-interface.connect-four-controller:
3535
class: Gaming\WebInterface\Presentation\Http\ConnectFourController
36-
arguments: ['@web-interface.connect-four-service', '@web-interface.security']
36+
arguments: ['@connect-four.command-bus', '@web-interface.security']
3737
tags: ['controller.service_arguments']

config/web-interface/services/integration.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
services:
2-
web-interface.chat-service:
3-
class: Gaming\WebInterface\Infrastructure\Integration\DirectControllerInvocationChatService
4-
arguments: ['@chat.chat-controller']
5-
6-
web-interface.connect-four-service:
7-
class: Gaming\WebInterface\Infrastructure\Integration\DirectControllerInvocationConnectFourService
8-
arguments: ['@connect-four.game-controller']
9-
10-
web-interface.identity-service:
11-
class: Gaming\WebInterface\Infrastructure\Integration\DirectControllerInvocationIdentityService
12-
arguments: ['@identity.user-controller']
13-
142
web-interface.nchan:
153
class: Marein\Nchan\Nchan
164
arguments:

config/web-interface/services/security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ services:
99

1010
web-interface.security.arrival_authenticator:
1111
class: Gaming\WebInterface\Infrastructure\Security\ArrivalAuthenticator
12-
arguments: ['@web-interface.identity-service', '@security.token_storage']
12+
arguments: ['@identity.command-bus', '@security.token_storage']

src/Chat/Presentation/Http/ChatController.php

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

src/Chat/Infrastructure/Messaging/CommandMessageHandler.php renamed to src/Chat/Presentation/Messaging/CommandMessageHandler.php

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

33
declare(strict_types=1);
44

5-
namespace Gaming\Chat\Infrastructure\Messaging;
5+
namespace Gaming\Chat\Presentation\Messaging;
66

77
use Gaming\Chat\Application\Command\InitiateChatCommand;
88
use Gaming\Common\Bus\Bus;
@@ -26,7 +26,7 @@ public function handle(Message $message, Context $context): void
2626
$chatId = $this->commandBus->handle(
2727
new InitiateChatCommand(
2828
$request->getIdempotencyKey(),
29-
iterator_to_array($request->getAuthors())
29+
[...$request->getAuthors()]
3030
)
3131
);
3232

src/ConnectFour/Application/Game/Query/Model/Game/Game.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public function id(): string
5656
return $this->gameId;
5757
}
5858

59+
public function chatId(): string
60+
{
61+
return $this->chatId;
62+
}
63+
5964
public function finished(): bool
6065
{
6166
return $this->finished;

src/ConnectFour/Application/Game/Query/Model/OpenGames/OpenGame.php

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,9 @@
66

77
final class OpenGame
88
{
9-
private string $gameId;
10-
11-
private string $playerId;
12-
13-
public function __construct(string $gameId, string $playerId)
14-
{
15-
$this->gameId = $gameId;
16-
$this->playerId = $playerId;
17-
}
18-
19-
public function gameId(): string
20-
{
21-
return $this->gameId;
22-
}
23-
24-
public function playerId(): string
25-
{
26-
return $this->playerId;
9+
public function __construct(
10+
public readonly string $gameId,
11+
public readonly string $playerId
12+
) {
2713
}
2814
}

0 commit comments

Comments
 (0)