Skip to content

Commit

Permalink
dev4: replaced auth service host:port string with env variables, move…
Browse files Browse the repository at this point in the history
…d auth config to main.go
  • Loading branch information
wonderf00l committed Dec 19, 2023
1 parent febce68 commit e3d1477
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
12 changes: 0 additions & 12 deletions cmd/app/config.go

This file was deleted.

7 changes: 7 additions & 0 deletions cmd/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"context"
"flag"
"fmt"
"os"

"github.com/go-park-mail-ru/2023_2_OND_team/internal/app"
"github.com/go-park-mail-ru/2023_2_OND_team/pkg/logger"
"github.com/joho/godotenv"
)

var (
Expand All @@ -27,6 +29,7 @@ var (
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html

func main() {
godotenv.Load()
flag.Parse()
ctxBase, cancel := context.WithCancel(context.Background())
defer cancel()
Expand All @@ -42,5 +45,9 @@ func main() {
}
defer log.Sync()

configFiles := app.ConfigFiles{
ServerConfigFile: "configs/config.yml",
AddrAuthServer: os.Getenv("AUTH_SERVICE_HOST") + ":" + os.Getenv("AUTH_SERVICE_PORT"), // "localhost:8085",
}
app.Run(ctxBase, log, configFiles)
}
6 changes: 2 additions & 4 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"os"
"time"

"github.com/joho/godotenv"
"github.com/microcosm-cc/bluemonday"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
Expand Down Expand Up @@ -47,8 +46,6 @@ var _timeoutForConnPG = 5 * time.Second
const uploadFiles = "upload/"

func Run(ctx context.Context, log *log.Logger, cfg ConfigFiles) {
godotenv.Load()

metrics := metrics.New("pinspire")
err := metrics.Registry()
if err != nil {
Expand All @@ -74,7 +71,8 @@ func Run(ctx context.Context, log *log.Logger, cfg ConfigFiles) {
}
defer connMessMS.Close()

connRealtime, err := grpc.Dial("localhost:8090", grpc.WithTransportCredentials(insecure.NewCredentials()))
// connRealtime, err := grpc.Dial("localhost:8090", grpc.WithTransportCredentials(insecure.NewCredentials()))
connRealtime, err := grpc.Dial(os.Getenv("REALTIME_SERVICE_HOST")+":"+os.Getenv("REALTIME_SERVICE_PORT"), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Error(err.Error())
return
Expand Down

0 comments on commit e3d1477

Please sign in to comment.