Skip to content

Commit a55ca7d

Browse files
committed
Attempt to fix some issues
Matching service still seems unable to talk to redis
1 parent 6309549 commit a55ca7d

File tree

10 files changed

+51
-22
lines changed

10 files changed

+51
-22
lines changed

compose.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ services:
6262
ports:
6363
- "9100:5672"
6464
- "9101:15672"
65+
healthcheck:
66+
test: rabbitmq-diagnostics -q ping
67+
interval: 30s
68+
timeout: 10s
69+
retries: 5
70+
start_period: 10s
6571

6672
matching-service:
6773
build: matching-service
@@ -74,9 +80,10 @@ services:
7480
- action: rebuild
7581
path: matching-service
7682
target: matching-service/app
83+
# TODO for some reason healthcheck doesnt really work, still ahve to manually start them
7784
depends_on:
78-
- rabbitmq
79-
- redis
85+
rabbitmq:
86+
condition: service_healthy
8087

8188
matching-service-api:
8289
build: matching-service-api
@@ -92,7 +99,8 @@ services:
9299
path: matching-service
93100
target: matching-service/app
94101
depends_on:
95-
- rabbitmq
102+
rabbitmq:
103+
condition: service_healthy
96104

97105
storage-blob-api:
98106
build: storage-blob-api

matching-service/.env.example

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
RABBIT_URI="amqp://grp14:grp14@localhost:9100/"
22

33
REDIS_URI="localhost:9190"
4+
5+
# dockerised
6+
7+
RABBIT_URI="amqp://grp14:grp14@rabbitmq/"
8+
9+
REDIS_URI="redis:9190"

matching-service/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23
1+
FROM golang:1.20
22

33
WORKDIR /matching-service
44

peerprep/.env.example

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
NEXT_PUBLIC_QUESTION_SERVICE=
2-
NEXT_PUBLIC_USER_SERVICE=
3-
NEXT_PUBLIC_MATCHING_SERVICE=
4-
NEXT_PUBLIC_STORAGE_BLOB=
1+
NEXT_PUBLIC_BASE_URL=http://host.docker.internal:80
2+
NEXT_PUBLIC_QUESTION_SERVICE=http://backend:9090
3+
NEXT_PUBLIC_USER_SERVICE=http://user-service:3001
54
# note NGINX will currently point to itself.
6-
NEXT_PUBLIC_NGINX=
7-
DEV_ENV=
5+
NEXT_PUBLIC_NGINX=http://localhost:3000
6+
DEV_ENV=not
7+
NEXT_PUBLIC_MATCHING_SERVICE=http://matching-service-api:9200
8+
NEXT_PUBLIC_STORAGE_BLOB=http://storage-blob-api:9300

peerprep/components/questionpage/Matchmaking.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,25 @@ const Matchmaking = () => {
5454
const { userid } = useUserInfo();
5555
const timeout = useRef<NodeJS.Timeout>();
5656

57+
const stopTimer = () => {
58+
// if user manually stopped it clear timeout
59+
if (timeout.current) {
60+
console.debug("Match request timeout stopped");
61+
clearTimeout(timeout.current);
62+
}
63+
};
64+
5765
const handleMatch = async () => {
5866
if (!isMatching) {
67+
setIsMatching(true);
68+
5969
// start 30s timeout
6070
timeout.current = setTimeout(() => {
6171
setIsMatching(false);
6272
console.log("Match request timed out after 30s");
6373
}, TIMEOUT_MILLISECONDS);
6474

65-
setIsMatching(true);
75+
// assemble the match request
6676
const matchRequest: MatchRequest = {
6777
userId: userid,
6878
difficulty: difficulty,
@@ -72,19 +82,17 @@ const Matchmaking = () => {
7282
console.log("Match attempted");
7383
console.debug(matchRequest);
7484

85+
// send match request
7586
const status = await findMatch(matchRequest);
7687
if (status.error) {
88+
stopTimer();
7789
console.log("Failed to find match. Cancel matching.");
7890
setIsMatching(false);
7991
return;
8092
}
8193
console.log(`Started finding match.`);
8294
} else {
83-
// if user manually stopped it clear timeout
84-
if (timeout.current) {
85-
clearTimeout(timeout.current);
86-
}
87-
95+
stopTimer();
8896
setIsMatching(false);
8997
console.log("User stopped matching");
9098
}

peerprep/components/questionpage/QuestionList.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const QuestionList: React.FC = () => {
3434
new Set(data.flatMap((question) => question.topicTags))
3535
).sort();
3636
setTopicsList(["all", ...uniqueTopics]);
37+
setTopics(["all", ...uniqueTopics]);
3738
};
3839

3940
fetchQuestions();

peerprep/middleware.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ function isSession(request: NextRequest): boolean {
1515
}
1616

1717
export function middleware(request: NextRequest) {
18-
// TODO DELETE THIS LATER
19-
if (process.env.NEXT_BYPASS_LOGIN === "yesplease") {
20-
return NextResponse.next();
21-
}
18+
// // UNCOMMENT AND ADD TO ENV IF JUST TESTING FRONTEND STUFF
19+
// if (process.env.NEXT_BYPASS_LOGIN === "yesplease") {
20+
// return NextResponse.next();
21+
// }
2222

2323
if (isNoSession(request)) {
2424
return NextResponse.redirect(new URL("/questions", request.url));

storage-blob-api/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
PORT=:9300
22
REDIS_URI="localhost:9190"
3+
4+
# dockerised
5+
PORT=:9300
6+
REDIS_URI="redis:6379"

storage-blob-api/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23
1+
FROM golang:1.2
22

33
WORKDIR /storage-blob-api
44

user-service/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ WORKDIR /user-service
44
# TODO: don't include the .env file in the COPY
55
# TODO: multistage build
66
COPY package*.json ./
7-
RUN npm install --verbose
7+
# why did it only work with --force
8+
RUN npm install --force --verbose
89
RUN npm rebuild bcrypt --build-from-source
910
COPY . .
1011
EXPOSE 3001

0 commit comments

Comments
 (0)