Add gRPC server implementation and database integration for marketplace and products

This commit is contained in:
2025-05-27 03:41:52 +03:00
parent 008f3df42d
commit b083cccc09
44 changed files with 2182 additions and 1201 deletions

36
internal/redis/client.go Normal file
View File

@@ -0,0 +1,36 @@
package redis
import (
"context"
"github.com/redis/rueidis"
"os"
)
var Client *rueidis.Client
func InitClient(ctx context.Context) error {
var err error
host := os.Getenv("REDIS_HOST")
port := os.Getenv("REDIS_PORT")
password := os.Getenv("REDIS_PASSWORD")
client, err := rueidis.NewClient(rueidis.ClientOption{
InitAddress: []string{host + ":" + port},
Password: password,
})
if err != nil {
return err
}
err = client.Do(ctx, client.B().Ping().Build()).Error()
if err != nil {
return err
}
Client = &client
return nil
}
func CloseClient() {
if Client != nil {
(*Client).Close()
}
}