diff --git a/README.md b/README.md index fd3637f..00c841f 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,7 @@ python3 ./simulator.py 127.0.0.1:8080 We automate the testing of our services using GitHub Actions (CI/CD). You can view the test results at: -- . +- ### Manual Test diff --git a/api-gateway/Caddyfile b/api-gateway/Caddyfile index a945168..9704bf0 100644 --- a/api-gateway/Caddyfile +++ b/api-gateway/Caddyfile @@ -1,7 +1,8 @@ http://:8080 { - reverse_proxy /hrm/* http://hrm:9500 - reverse_proxy /player/* http://player:9000 - reverse_proxy /game/* http://game:9090 - reverse_proxy /challenge/* http://challenge:9001 - reverse_proxy /geo/* http://geo:9002 + reverse_proxy /hrm* http://hrm:9500 + reverse_proxy /player* http://player:9000 + reverse_proxy /game* http://game:9090 + reverse_proxy /challenge* http://challenge:9001 + reverse_proxy /badge* http://challenge:9001 + reverse_proxy /geo* http://geo:9002 } diff --git a/game-service/api/utils.go b/game-service/api/utils.go index 694f7e8..6aa13f8 100644 --- a/game-service/api/utils.go +++ b/game-service/api/utils.go @@ -6,6 +6,7 @@ import ( "encoding/json" "errors" "fmt" + "log" "time" "github.com/gin-gonic/gin" @@ -21,13 +22,15 @@ func getPlayerDTOBySessionID(sessionID, username string) (*dto.PlayerDTO, error) ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) defer cancel() + log.Printf("GET Session from `%s` for `%s`", sessionID, username) + cmd := _cache.HGet(ctx, fmt.Sprintf("spring:session:sessions:%s", sessionID), - fmt.Sprintf("sessionAttr:PLAYER_SESSION%s", username)) + fmt.Sprintf("sessionAttr:PLAYER_SESSION_%s", username)) data, err := cmd.Bytes() if err != nil { - return nil, err + return nil, fmt.Errorf("redis cmd returned error: %s", err) } res, err := jserial.ParseSerializedObjectMinimal(data) diff --git a/game-service/game/core.go b/game-service/game/core.go index c2f08af..2ca9c30 100644 --- a/game-service/game/core.go +++ b/game-service/game/core.go @@ -97,7 +97,7 @@ func (app *App) ProcessGameAction(player *dto.PlayerDTO, action, cType string, l } }{} if err := app.GetService("challenge-service", - fmt.Sprintf("/challenge/management?userHeartRate=%d&type=%s", ctx.GetHeartRate(), cType), &data); err != nil { + fmt.Sprintf("/challenge?userHeartRate=%d&type=%s", ctx.GetHeartRate(), cType), &data); err != nil { //return nil, fmt.Errorf("get init challenge failed: %v", err) data.Data.UserHeartRate = ((100-player.Age)/2 + player.Weight) + rand.Intn(40) - 20 diff --git a/game-service/game/rest.go b/game-service/game/rest.go index cbcf57b..e54f21f 100644 --- a/game-service/game/rest.go +++ b/game-service/game/rest.go @@ -29,7 +29,3 @@ func (app *App) GetService(service, path string, v any) error { return json.NewDecoder(res.Body).Decode(v) } - -func (app *App) PostService(service, path string, body any) { - -} diff --git a/simulator-script/simulator.py b/simulator-script/simulator.py index 4711bef..406f17d 100644 --- a/simulator-script/simulator.py +++ b/simulator-script/simulator.py @@ -48,7 +48,10 @@ def simulate(base: str): }) as r: print(f'>>> Starting game in Zone: MAC ({x}, {y})') pprint(data := r.json()) - shelters = data['data']['shelters'] + try: + shelters = data['data']['shelters'] + except KeyError: + shelters = [] time.sleep(1) for i in range(10): @@ -104,4 +107,7 @@ def main(): if __name__ == '__main__': - main() + try: + main() + except KeyboardInterrupt: + exit(0)