Skip to content

Commit

Permalink
fix: moved packages
Browse files Browse the repository at this point in the history
  • Loading branch information
SShlykov committed Mar 21, 2024
1 parent acc3ecb commit b29a075
Show file tree
Hide file tree
Showing 23 changed files with 16 additions and 91 deletions.
5 changes: 1 addition & 4 deletions api_gateway/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ WORKDIR /app
COPY ../api_gateway ./api_gateway
COPY ../auth ./auth
COPY ../bookback ./bookback
COPY ../logger ./logger
COPY ../metrics ./metrics
COPY ../postgres ./postgres
COPY ../scripts ./scripts
COPY ../go_pkg ./go_pkg
COPY ../go.work ./go.work

RUN go build -o /app/main ./api_gateway/cmd/api_gateway
Expand Down
17 changes: 7 additions & 10 deletions api_gateway/cmd/api_gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
userService "github.com/SShlykov/zeitment/auth/pkg/grpc/user_v1"
loggerPkg "github.com/SShlykov/zeitment/logger"
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"google.golang.org/grpc"
"log"
Expand All @@ -16,11 +17,12 @@ var (
)

func main() {
logger := loggerPkg.SetupLogger("info")
proxyAddr := fmt.Sprintf(":%s", os.Getenv("PORT"))
HTTPProxy(proxyAddr)
HTTPProxy(proxyAddr, logger)
}

func HTTPProxy(proxyAddr string) {
func HTTPProxy(proxyAddr string, logger loggerPkg.Logger) {
grpcGwMux := runtime.NewServeMux()

//----------------------------------------------------------------
Expand All @@ -30,13 +32,13 @@ func HTTPProxy(proxyAddr string) {
//grpc.WithPerRPCCredentials(&reqData{}),
grpcUserConn, err := grpc.Dial(authServiceURL, grpc.WithInsecure())
if err != nil {
log.Fatalln("Filed to connect to User service", err)
logger.Error("Filed to connect to User service", loggerPkg.Err(err))
}
defer grpcUserConn.Close()

err = userService.RegisterUserServiceHandler(context.Background(), grpcGwMux, grpcUserConn)
if err != nil {
log.Fatalln("Filed to start HTTP server", err)
logger.Error("Filed to register User service", loggerPkg.Err(err))
}

//----------------------------------------------------------------
Expand All @@ -45,12 +47,7 @@ func HTTPProxy(proxyAddr string) {
mux := http.NewServeMux()

mux.Handle("/api/v1/", grpcGwMux)
mux.HandleFunc("/", helloWorld)

fmt.Println("starting HTTP server at " + proxyAddr)
logger.Info("starting HTTP server at " + proxyAddr)
log.Fatal(http.ListenAndServe(proxyAddr, mux))
}

func helloWorld(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte("Hello, world!"))
}
5 changes: 1 addition & 4 deletions auth/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ WORKDIR /app
COPY ../api_gateway ./api_gateway
COPY ../auth ./auth
COPY ../bookback ./bookback
COPY ../logger ./logger
COPY ../metrics ./metrics
COPY ../postgres ./postgres
COPY ../scripts ./scripts
COPY ../go_pkg ./go_pkg
COPY ../go.work ./go.work

RUN go build -o /app/main ./auth/cmd/auth
Expand Down
3 changes: 2 additions & 1 deletion auth/internal/domain/services/user_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func (uss *userServiceServer) SignUp(ctx context.Context, in *user_v1.SignUpRequ
user.PasswordHash = hashed
user.UpdateAfter = sql.Null[int64]{Valid: true, V: int64(30 * 24 * time.Hour)}

userID, err := uss.repo.Create(ctx, user)
var userID string
userID, err = uss.repo.Create(ctx, user)
if err != nil {
return nil, err
}
Expand Down
5 changes: 1 addition & 4 deletions bookback/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ WORKDIR /app
COPY ../api_gateway ./api_gateway
COPY ../auth ./auth
COPY ../bookback ./bookback
COPY ../logger ./logger
COPY ../metrics ./metrics
COPY ../postgres ./postgres
COPY ../scripts ./scripts
COPY ../go_pkg ./go_pkg
COPY ../go.work ./go.work

RUN go build -o /app/main ./bookback/cmd/bookback
Expand Down
2 changes: 1 addition & 1 deletion bookback/internal/bootstrap/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (app *App) Run() error {
logg := app.logger
logg.Info("starting book app", slog.String("at", app.web.Address))
logg.Debug("debug messages enabled")

go func() {
app.RunWebServer()
}()
Expand Down
6 changes: 3 additions & 3 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use (
./api_gateway
./auth
./bookback
./logger
./postgres
./metrics
./go_pkg/logger
./go_pkg/postgres
./go_pkg/metrics
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
64 changes: 0 additions & 64 deletions postgres/transaction/transaction.go

This file was deleted.

0 comments on commit b29a075

Please sign in to comment.