Skip to content

Commit bb68806

Browse files
committed
Fix matching service and storage blob connection issues + compose.yaml
1 parent 90717b7 commit bb68806

File tree

7 files changed

+25
-8
lines changed

7 files changed

+25
-8
lines changed

backend/transport/question_http_requests.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func SetAllEndpoints(router *gin.Engine, db *database.QuestionDB, logger *common
2525
// enable CORS for the frontend
2626
func SetCors(router *gin.Engine, origin string) {
2727
router.Use(cors.New(cors.Config{
28-
AllowOrigins: []string{origin, "http://localhost"},
28+
AllowOrigins: []string{"http://host.docker.internal", origin},
2929
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
3030
AllowHeaders: []string{"Origin", "Content-Type", "Content-Length", "Authorization"},
3131
ExposeHeaders: []string{"Content-Length"},

compose.yaml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,15 @@ services:
6363
- "9100:5672"
6464
- "9101:15672"
6565
healthcheck:
66-
test: rabbitmq-diagnostics -q ping
66+
test:
67+
[
68+
"CMD-SHELL",
69+
"rabbitmq-diagnostics -q ping && rabbitmq-diagnostics -q check_running && rabbitmq-diagnostics -q check_local_alarms",
70+
]
6771
interval: 30s
6872
timeout: 10s
6973
retries: 5
70-
start_period: 10s
74+
start_period: 30s
7175

7276
matching-service:
7377
build: matching-service
@@ -80,7 +84,7 @@ services:
8084
- action: rebuild
8185
path: matching-service
8286
target: matching-service/app
83-
# TODO for some reason healthcheck doesnt really work, still ahve to manually start them
87+
# TODO for some reason healthcheck doesnt really work, still ahve to manually start MS and MS-api
8488
depends_on:
8589
rabbitmq:
8690
condition: service_healthy

matching-service-api/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
PORT=
1+
PORT=9200
22
RABBIT_URI=
33
CORS_ORIGIN=
44

matching-service/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ RABBIT_URI=
22

33
REDIS_URI=
44

5+
BACKEND_MATCH_URI="[BACKEND_URI]/match"

matching-service/transport/request_questions.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"bytes"
77
"encoding/json"
88
"fmt"
9+
"os"
910
"io"
1011
"matching-service/models"
1112
"net/http"
@@ -23,7 +24,13 @@ func FindSuitableQuestionId(topicTags []string, difficulty string, target *model
2324
return fmt.Errorf("failed to convert outgoing req to JSON: %s", err.Error())
2425
}
2526

26-
req, err := http.NewRequest("POST", "http://localhost:9090/match", bytes.NewBuffer(reqBody))
27+
URI := os.Getenv("BACKEND_MATCH_URI")
28+
29+
if URI == "" {
30+
URI = "http://localhost:9090/match"
31+
}
32+
33+
req, err := http.NewRequest("POST", URI, bytes.NewBuffer(reqBody))
2734

2835
if err != nil {
2936
return fmt.Errorf("failed to make request: %s", err.Error())

peerprep/components/questionpage/Matchmaking.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,16 @@ const Matchmaking = () => {
104104
// for now 404 means no match found so dont stop matching on error, let request timeout
105105
return;
106106
}
107+
stopTimer();
107108
setIsMatching(false);
108109
// TODO: iron out what is in a match response and sync up with collab service rooms
109110
const matchRes: MatchResponse = res as MatchResponse;
110111
console.log("Match found!");
111-
console.debug(matchRes);
112+
// display in a popup for now
113+
const message = `Room ID: ${matchRes.data.roomId}
114+
User1: ${matchRes.data.user1}
115+
User2: ${matchRes.data.user2}`;
116+
window.alert(message);
112117
};
113118

114119
usePeriodicCallback(queryResource, QUERY_INTERVAL_MILLISECONDS, isMatching);

storage-blob-api/.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
PORT=
1+
PORT=9300
22
REDIS_URI=
33

0 commit comments

Comments
 (0)