Skip to content

Commit c9c5536

Browse files
authored
Merge pull request #1709 from notaphplover/feat/update-game-page-to-subscribe-to-game-events
Update game page to subscribe to game events
2 parents 5a85c30 + 066e772 commit c9c5536

File tree

11 files changed

+239
-156
lines changed

11 files changed

+239
-156
lines changed

packages/backend/apps/game/backend-game-application/src/games/application/handlers/GameUpdatedEventHandler.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,14 @@ export class GameUpdatedEventHandler
161161

162162
async #sendGameTurnEndSignal(game: Game): Promise<void> {
163163
if (game.state.status !== GameStatus.active) {
164-
throw new AppError(
165-
AppErrorKind.unknown,
166-
'Unexpected non active game when sending game turn end signal',
167-
);
164+
this.#logger
165+
.warn(`Unexpected non active game when sending game turn end signal:
166+
167+
${JSON.stringify(game)}
168+
169+
No end turn signal will be delivered`);
170+
171+
return;
168172
}
169173

170174
if (this.#gameTurnEndSignalMessageSendOutputPort !== undefined) {

packages/backend/tools/backend-dev-apache-pulsar/docker-compose.yml

Lines changed: 11 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -2,98 +2,18 @@ networks:
22
pulsar:
33
driver: bridge
44
services:
5-
# Start zookeeper
6-
zookeeper:
5+
standalone:
76
image: apachepulsar/pulsar:3.3.2
8-
container_name: zookeeper
9-
restart: on-failure
10-
networks:
11-
- pulsar
12-
volumes:
13-
- ./data/zookeeper:/pulsar/data/zookeeper
14-
- ./scripts/zookeper_health:/pulsar/bin/zookeper_health
15-
environment:
16-
- metadataStoreUrl=zk:zookeeper:2181
17-
- PULSAR_MEM=-Xms256m -Xmx256m -XX:MaxDirectMemorySize=256m
18-
command: >
19-
bash -c "bin/apply-config-from-env.py conf/zookeeper.conf && \
20-
bin/generate-zookeeper-config.sh conf/zookeeper.conf && \
21-
exec bin/pulsar zookeeper"
22-
healthcheck:
23-
# The script is broken in the latest version, waiting for a new release
24-
# test: ["CMD", "bin/pulsar-zookeeper-ruok.sh"]
25-
test: ["CMD", "bin/zookeper_health"]
26-
interval: 10s
27-
timeout: 5s
28-
retries: 10
29-
30-
# Init cluster metadata
31-
pulsar-init:
32-
container_name: pulsar-init
33-
hostname: pulsar-init
34-
image: apachepulsar/pulsar:3.3.2
35-
networks:
36-
- pulsar
37-
command: >
38-
bin/pulsar initialize-cluster-metadata \
39-
--cluster cluster-a \
40-
--zookeeper zookeeper:2181 \
41-
--configuration-store zookeeper:2181 \
42-
--web-service-url http://broker:8080 \
43-
--broker-service-url pulsar://broker:6650
44-
depends_on:
45-
zookeeper:
46-
condition: service_healthy
47-
48-
# Start bookie
49-
bookie:
50-
image: apachepulsar/pulsar:3.3.2
51-
container_name: bookie
52-
restart: on-failure
53-
networks:
54-
- pulsar
55-
environment:
56-
- clusterName=cluster-a
57-
- zkServers=zookeeper:2181
58-
- metadataServiceUri=metadata-store:zk:zookeeper:2181
59-
# otherwise every time we run docker compose uo or down we fail to start due to Cookie
60-
# See: https://github.com/apache/bookkeeper/blob/405e72acf42bb1104296447ea8840d805094c787/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Cookie.java#L57-68
61-
- advertisedAddress=bookie
62-
- BOOKIE_MEM=-Xms512m -Xmx512m -XX:MaxDirectMemorySize=256m
63-
depends_on:
64-
zookeeper:
65-
condition: service_healthy
66-
pulsar-init:
67-
condition: service_completed_successfully
68-
# Map the local directory to the container to avoid bookie startup failure due to insufficient container disks.
69-
volumes:
70-
- ./data/bookkeeper:/pulsar/data/bookkeeper
71-
command: bash -c "bin/apply-config-from-env.py conf/bookkeeper.conf && exec bin/pulsar bookie"
72-
73-
# Start broker
74-
broker:
75-
image: apachepulsar/pulsar:3.3.2
76-
container_name: broker
77-
hostname: broker
78-
restart: on-failure
79-
networks:
80-
- pulsar
81-
environment:
82-
- metadataStoreUrl=zk:zookeeper:2181
83-
- zookeeperServers=zookeeper:2181
84-
- clusterName=cluster-a
85-
- managedLedgerDefaultEnsembleSize=1
86-
- managedLedgerDefaultWriteQuorum=1
87-
- managedLedgerDefaultAckQuorum=1
88-
- advertisedAddress=broker
89-
- advertisedListeners=external:pulsar://127.0.0.1:6650
90-
- PULSAR_MEM=-Xms512m -Xmx512m -XX:MaxDirectMemorySize=256m
91-
depends_on:
92-
zookeeper:
93-
condition: service_healthy
94-
bookie:
95-
condition: service_started
7+
command: bin/pulsar standalone
968
ports:
979
- "6650:6650"
9810
- "8080:8080"
99-
command: bash -c "bin/apply-config-from-env.py conf/broker.conf && exec bin/pulsar broker"
11+
volumes:
12+
- pulsardata:/pulsar/data
13+
- pulsarconf:/pulsar/conf
14+
15+
volumes:
16+
pulsardata:
17+
name: pulsardata
18+
pulsarconf:
19+
name: pulsarconf

packages/frontend/web-ui/src/game/helpers/getGameSlotIndex.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe(getGameSlotIndex.name, () => {
3535
});
3636

3737
it('should return expected result', () => {
38-
expect(result).toBeNull();
38+
expect(result).toBeUndefined();
3939
});
4040
});
4141
});
@@ -74,7 +74,7 @@ describe(getGameSlotIndex.name, () => {
7474
});
7575

7676
it('should return expected result', () => {
77-
expect(result).toBe('0');
77+
expect(result).toBe(0);
7878
});
7979
});
8080
});

packages/frontend/web-ui/src/game/helpers/getGameSlotIndex.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { models as apiModels } from '@cornie-js/api-models';
33
export function getGameSlotIndex(
44
game: apiModels.GameV1 | undefined,
55
user: apiModels.UserV1,
6-
): string | null {
6+
): number | undefined {
77
if (game === undefined) {
8-
return null;
8+
return undefined;
99
}
1010

1111
for (let i: number = 0; i < game.state.slots.length; ++i) {
@@ -15,9 +15,9 @@ export function getGameSlotIndex(
1515
| apiModels.FinishedGameSlotV1;
1616

1717
if (gameSlot.userId === user.id) {
18-
return i.toString();
18+
return i;
1919
}
2020
}
2121

22-
return null;
22+
return undefined;
2323
}

0 commit comments

Comments
 (0)