Skip to content

Commit

Permalink
Release/return correct logger (#46)
Browse files Browse the repository at this point in the history
* release: return correct logger

* fix router

* grafana fix

* more easy json

* more tests: 65.3

* update middleware

* fx

* fx

* Final routes and room

* fix prometheus

* fx

* mb this

* mb this

* idk
  • Loading branch information
UnicoYal authored Dec 16, 2024
1 parent 45713ff commit fa6cb42
Show file tree
Hide file tree
Showing 38 changed files with 4,045 additions and 575 deletions.
39 changes: 22 additions & 17 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- main
- very-final-branch
- release/return-correct-logger
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -44,26 +44,26 @@ jobs:
echo "Test coverage is below 60%! Current coverage: $COVERAGE%"
exit 1
fi
# linter:
# name: lint
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-go@v4
# with:
# go-version: '1.22.0'
# cache: false
# - name: golangci-lint
# uses: golangci/golangci-lint-action@v3
# with:
# version: v1.53
# args: --timeout=30m --config=./.golangci.pipeline.yml --issues-exit-code=0
linter:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.22.0'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.53
args: --timeout=30m --config=./.golangci.pipeline.yml --issues-exit-code=0

build-and-push:
runs-on: ubuntu-latest
# needs:
# - linter
# - test
# - linter
# - test

steps:
- name: Checkout code
Expand Down Expand Up @@ -148,6 +148,7 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push facade
if: steps.check_facade.outputs.changed == 'true'
uses: docker/build-push-action@v4
with:
context: .
Expand All @@ -156,6 +157,7 @@ jobs:
tags: ${{ secrets.DOCKER_USERNAME }}/facade_app:latest

- name: Build and push user_service
if: steps.check_user_service.outputs.changed == 'true'
uses: docker/build-push-action@v4
with:
context: .
Expand All @@ -164,6 +166,7 @@ jobs:
tags: ${{ secrets.DOCKER_USERNAME }}/user_app:latest

- name: Build and push movie_service
if: steps.check_movie_service.outputs.changed == 'true'
uses: docker/build-push-action@v4
with:
context: .
Expand All @@ -172,6 +175,7 @@ jobs:
tags: ${{ secrets.DOCKER_USERNAME }}/movie_app:latest

- name: Build and push payment_service
if: steps.check_payment_service.outputs.changed == 'true'
uses: docker/build-push-action@v4
with:
context: .
Expand All @@ -180,6 +184,7 @@ jobs:
tags: ${{ secrets.DOCKER_USERNAME }}/payment_app:latest

- name: Build and push auth_service
if: steps.check_auth_service.outputs.changed == 'true'
uses: docker/build-push-action@v4
with:
context: .
Expand Down
32 changes: 17 additions & 15 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ services:
environment:
- GF_SECURITY_ADMIN_USER=${GF_SECURITY_ADMIN_USER}
- GF_SECURITY_ADMIN_PASSWORD=${GF_SECURITY_ADMIN_PASSWORD}
- GF_SERVER_ROOT_URL=https://cassette-world.ru/grafana/
- GF_SERVER_SERVE_FROM_SUB_PATH=true
volumes:
- grafana-data:/var/lib/grafana
restart: "always"
Expand All @@ -52,21 +54,21 @@ services:
- /sys:/host/sys:ro
- /:/rootfs:ro

watchtower:
image: containrrr/watchtower:latest
container_name: watchtower
environment:
- TZ=Europe/London
- WATCHTOWER_CLEANUP=true
- WATCHTOWER_ROLLING_RESTART=true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: unless-stopped
command: --interval 30 facade_app user_app payment_app movie_app auth_app
networks:
- cassette-world
depends_on:
- facade_app
watchtower:
image: containrrr/watchtower:latest
container_name: watchtower
environment:
- TZ=Europe/London
- WATCHTOWER_CLEANUP=true
- WATCHTOWER_ROLLING_RESTART=true
volumes:
- /var/run/docker.sock:/var/run/docker.sock
restart: unless-stopped
command: --interval 30 facade_app user_app payment_app movie_app auth_app
networks:
- cassette-world
depends_on:
- facade_app

facade_redis:
image: 'redis:latest'
Expand Down
3 changes: 3 additions & 0 deletions easyjson.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
internal/app/models/easy.go
internal/app/api/struct.go
internal/app/errors/errors.go
internal/app/room/model/model.go
internal/db/script_elastic/models/models.go
movie_service/internal/movie/models/easy.go
4 changes: 4 additions & 0 deletions exclude_from_coverage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ github.com/go-park-mail-ru/2024_2_GOATS/internal/db/script_elastic
github.com/go-park-mail-ru/2024_2_GOATS/internal/app/models/easy_easyjson.go
github.com/go-park-mail-ru/2024_2_GOATS/internal/app/api/struct_easyjson.go
github.com/go-park-mail-ru/2024_2_GOATS/internal/app/errors/errors_easyjson.go
github.com/go-park-mail-ru/2024_2_GOATS/internal/app/errors/errors_easyjson.go
github.com/go-park-mail-ru/2024_2_GOATS/internal/app/room/model/model_easyjson.go
github.com/go-park-mail-ru/2024_2_GOATS/internal/db/script_elastic/models/models_easyjson.go
github.com/go-park-mail-ru/2024_2_GOATS/movie_service/internal/movie/models/easy_easyjson.go
1 change: 0 additions & 1 deletion internal/app/api/handlers/implementation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type MovieHandlerInterface interface {
SearchActors(w http.ResponseWriter, r *http.Request)
GetUserRating(w http.ResponseWriter, r *http.Request)
AddOrUpdateRating(w http.ResponseWriter, r *http.Request)
DeleteRating(w http.ResponseWriter, r *http.Request)
}

// AuthHandlerInterface defines auth_handler methods
Expand Down
10 changes: 6 additions & 4 deletions internal/app/api/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func Response(ctx context.Context, w http.ResponseWriter, code int, obj interfac
}

// DecodeBody decodes http request body
func DecodeBody(w http.ResponseWriter, r *http.Request, obj interface{}) {
func DecodeBody(w http.ResponseWriter, r *http.Request, obj interface{}) bool {
logger := log.Ctx(r.Context())

unmarshaler, ok := obj.(easyjson.Unmarshaler)
Expand All @@ -75,21 +75,23 @@ func DecodeBody(w http.ResponseWriter, r *http.Request, obj interface{}) {
logger.Error().Err(err).Msg("cannot parse request")
Response(r.Context(), w, http.StatusBadRequest, fmt.Errorf("cannot parse request: %w", err))
}
return
return false
}

body, err := io.ReadAll(r.Body)
if err != nil {
logger.Error().Err(err).Msg("cannot read request body")
Response(r.Context(), w, http.StatusInternalServerError, fmt.Errorf("cannot read request body: %w", err))
return
return false
}

if err := easyjson.Unmarshal(body, unmarshaler); err != nil {
logger.Error().Err(err).Msg("cannot parse request")
Response(r.Context(), w, http.StatusBadRequest, fmt.Errorf("cannot parse request: %w", err))
return
return false
}

return true
}

// PreparedDefaultError is a prepared default http error
Expand Down
32 changes: 32 additions & 0 deletions internal/app/api/struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,35 @@ type SubscribeRequest struct {
type SubscribeResponse struct {
SubscriptionIDP string `json:"subscription_idp"`
}

// MovieSearchData json struct
type MovieSearchData struct {
ID int `json:"id"`
Title string `json:"title"`
CardURL string `json:"card_url"`
AlbumURL string `json:"album_url"`
Rating string `json:"rating"`
ReleaseDate string `json:"release_date"`
MovieType string `json:"movie_type"`
Country string `json:"country"`
}

// MovieSearchList type
// easyjson:json
type MovieSearchList []MovieSearchData

// ActorSearchData json struct
type ActorSearchData struct {
ID int `json:"id"`
FullName string `json:"full_name"`
PhotoURL string `json:"photo_url"`
Country string `json:"country"`
}

// ActorSearchList type
// easyjson:json
type ActorSearchList []ActorSearchData

type AddOrUpdateRatingReq struct {
Rating int `json:"rating"`
}
Loading

0 comments on commit fa6cb42

Please sign in to comment.