Skip to content

Commit

Permalink
Remove redundant abstractions (#243)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
marein authored Nov 29, 2024
1 parent b4a66c5 commit ff16e66
Show file tree
Hide file tree
Showing 31 changed files with 111 additions and 736 deletions.
6 changes: 5 additions & 1 deletion assets/js/ConnectFour/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ customElements.define('connect-four-game', class extends HTMLElement {
}

_onPlayerMoved(event) {
this._game.appendMove(event.detail);
this._game.appendMove({
x: event.detail.x,
y: event.detail.y,
color: event.detail.color,
});
}

_onGameWon(event) {
Expand Down
4 changes: 0 additions & 4 deletions config/chat/services/chat.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
services:
chat.chat-controller:
class: Gaming\Chat\Presentation\Http\ChatController
arguments: ['@chat.command-bus', '@chat.query-bus']

chat.chat-gateway:
class: Gaming\Chat\Infrastructure\DoctrineChatGateway
arguments: ['@chat.doctrine-dbal', 'chat', 'message']
Expand Down
2 changes: 1 addition & 1 deletion config/chat/services/consumer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
factory: ['@gaming.message-broker.amqp-consumer-factory', 'create']
arguments:
- !service
class: Gaming\Chat\Infrastructure\Messaging\CommandMessageHandler
class: Gaming\Chat\Presentation\Messaging\CommandMessageHandler
arguments: ['@chat.command-bus']
- !service
class: Gaming\Common\MessageBroker\Integration\AmqpLib\QueueConsumer\ConsumeQueues
Expand Down
4 changes: 0 additions & 4 deletions config/connect-four/services/game.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
services:
connect-four.game-controller:
class: Gaming\ConnectFour\Port\Adapter\Http\GameController
arguments: ['@connect-four.command-bus', '@connect-four.query-bus']

connect-four.game-repository:
class: Gaming\ConnectFour\Port\Adapter\Persistence\Repository\DoctrineJsonGameRepository
arguments:
Expand Down
4 changes: 0 additions & 4 deletions config/identity/services/user.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
services:
identity.user-controller:
class: Gaming\Identity\Port\Adapter\Http\UserController
arguments: ['@identity.command-bus']

identity.user-repository:
class: Gaming\Identity\Port\Adapter\Persistence\Repository\DoctrineUserRepository
arguments: ['@identity.doctrine-orm']
Expand Down
2 changes: 1 addition & 1 deletion config/web-interface/services/console.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
Gaming\WebInterface\Presentation\Console\PublishRunningGamesCountToNchanCommand:
arguments: ['@web-interface.connect-four-service', '@web-interface.browser-notifier']
arguments: ['@connect-four.query-bus', '@web-interface.browser-notifier']
tags:
- name: console.command
command: web-interface:publish-running-games-count-to-nchan
Expand Down
8 changes: 4 additions & 4 deletions config/web-interface/services/controller.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
services:
web-interface.page-controller:
class: Gaming\WebInterface\Presentation\Http\PageController
arguments: ['@twig', '@web-interface.connect-four-service', '@web-interface.security']
arguments: ['@twig', '@connect-four.query-bus', '@web-interface.security']
tags: ['controller.service_arguments']

web-interface.signup-controller:
class: Gaming\WebInterface\Presentation\Http\SignupController
arguments:
- '@uri_signer'
- '@web-interface.security'
- '@web-interface.identity-service'
- '@identity.command-bus'
- '@gaming.form-violation-mapper'
calls: [[setContainer, ['@Psr\Container\ContainerInterface']]]
tags: ['controller.service_arguments', 'container.service_subscriber']
Expand All @@ -28,10 +28,10 @@ services:

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

web-interface.connect-four-controller:
class: Gaming\WebInterface\Presentation\Http\ConnectFourController
arguments: ['@web-interface.connect-four-service', '@web-interface.security']
arguments: ['@connect-four.command-bus', '@web-interface.security']
tags: ['controller.service_arguments']
12 changes: 0 additions & 12 deletions config/web-interface/services/integration.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
services:
web-interface.chat-service:
class: Gaming\WebInterface\Infrastructure\Integration\DirectControllerInvocationChatService
arguments: ['@chat.chat-controller']

web-interface.connect-four-service:
class: Gaming\WebInterface\Infrastructure\Integration\DirectControllerInvocationConnectFourService
arguments: ['@connect-four.game-controller']

web-interface.identity-service:
class: Gaming\WebInterface\Infrastructure\Integration\DirectControllerInvocationIdentityService
arguments: ['@identity.user-controller']

web-interface.nchan:
class: Marein\Nchan\Nchan
arguments:
Expand Down
2 changes: 1 addition & 1 deletion config/web-interface/services/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ services:

web-interface.security.arrival_authenticator:
class: Gaming\WebInterface\Infrastructure\Security\ArrivalAuthenticator
arguments: ['@web-interface.identity-service', '@security.token_storage']
arguments: ['@identity.command-bus', '@security.token_storage']
59 changes: 0 additions & 59 deletions src/Chat/Presentation/Http/ChatController.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Gaming\Chat\Infrastructure\Messaging;
namespace Gaming\Chat\Presentation\Messaging;

use Gaming\Chat\Application\Command\InitiateChatCommand;
use Gaming\Common\Bus\Bus;
Expand All @@ -26,7 +26,7 @@ public function handle(Message $message, Context $context): void
$chatId = $this->commandBus->handle(
new InitiateChatCommand(
$request->getIdempotencyKey(),
iterator_to_array($request->getAuthors())
[...$request->getAuthors()]
)
);

Expand Down
5 changes: 5 additions & 0 deletions src/ConnectFour/Application/Game/Query/Model/Game/Game.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public function id(): string
return $this->gameId;
}

public function chatId(): string
{
return $this->chatId;
}

public function finished(): bool
{
return $this->finished;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,9 @@

final class OpenGame
{
private string $gameId;

private string $playerId;

public function __construct(string $gameId, string $playerId)
{
$this->gameId = $gameId;
$this->playerId = $playerId;
}

public function gameId(): string
{
return $this->gameId;
}

public function playerId(): string
{
return $this->playerId;
public function __construct(
public readonly string $gameId,
public readonly string $playerId
) {
}
}
Loading

0 comments on commit ff16e66

Please sign in to comment.