@@ -2,18 +2,20 @@ package main
22
33import (
44 "database/sql"
5- "google.golang.org/grpc/reflection"
6- "log"
5+ "fmt"
76 "net"
87 "time"
98
9+ "github.com/charmbracelet/log"
10+ "google.golang.org/grpc/reflection"
11+
1012 commonv1 "github.com/rtmelsov/adv-keeper/gen/go/proto/common/v1"
1113 filev1 "github.com/rtmelsov/adv-keeper/gen/go/proto/file/v1"
14+ "github.com/rtmelsov/adv-keeper/internal/authserver"
1215 db "github.com/rtmelsov/adv-keeper/internal/db"
13- "github.com/rtmelsov/adv-keeper/internal/file "
16+ "github.com/rtmelsov/adv-keeper/internal/fileserver "
1417 "github.com/rtmelsov/adv-keeper/internal/helpers"
1518 "github.com/rtmelsov/adv-keeper/internal/middleware"
16- "github.com/rtmelsov/adv-keeper/internal/server"
1719 "google.golang.org/grpc/keepalive"
1820
1921 _ "github.com/jackc/pgx/v5/stdlib"
@@ -30,7 +32,9 @@ func main() {
3032 if err != nil {
3133 log .Fatal (err )
3234 }
33-
35+ path := fmt .Sprintf ("file:/%s" , envs .MigrationsFilesDir )
36+ log .Info ("path" , "path" , path )
37+ helpers .RunMigrations (envs .DBDSN , path )
3438 // Подключение к Postgres
3539 dbx , err := sql .Open ("pgx" , envs .DBDSN )
3640 if err != nil {
@@ -41,6 +45,7 @@ func main() {
4145 q := db .New (dbx )
4246 s := grpc .NewServer (
4347 grpc .UnaryInterceptor (middleware .ServerInterceptor ),
48+ grpc .StreamInterceptor (middleware .StreamInterceptor ), // вот тут
4449 grpc .KeepaliveParams (keepalive.ServerParameters {
4550 MaxConnectionIdle : 0 ,
4651 MaxConnectionAge : 0 ,
@@ -49,12 +54,12 @@ func main() {
4954 Timeout : 20 * time .Second ,
5055 }),
5156 )
52- commonv1 .RegisterAuthServiceServer (s , server .New (q ))
53- filev1 .RegisterFileServiceServer (s , file .New (q ))
57+ commonv1 .RegisterAuthServiceServer (s , authserver .New (q ))
58+ filev1 .RegisterFileServiceServer (s , fileserver .New (q ))
5459
5560 reflection .Register (s )
5661
57- log .Println ("gRPC listening on" , lis .Addr ())
62+ log .Info ("gRPC listening on" , "add " , lis .Addr ())
5863 if err := s .Serve (lis ); err != nil {
5964 log .Fatal (err )
6065 }
0 commit comments