package grpc

import (
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
	"log/slog"
)

func ConnectGRPCServer(host string) *grpc.ClientConn {
	conn, err := grpc.Dial(host+":50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		slog.Error("could not connect to grpc server", "error", err)
	}
	return conn
}

func CloseGRPCServer(conn *grpc.ClientConn) {
	err := conn.Close()
	if err != nil {
		slog.Error("could not close connection", "error", err)
	}
}
