forked from ebhomengo/niki
25 lines
459 B
Go
25 lines
459 B
Go
package grpc
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"google.golang.org/grpc"
|
|
"google.golang.org/grpc/credentials/insecure"
|
|
)
|
|
|
|
type Config struct {
|
|
Host string `koanf:"host"`
|
|
Port int `koanf:"port"`
|
|
}
|
|
|
|
func NewClient(cfg Config) (*grpc.ClientConn, error) {
|
|
address := fmt.Sprintf("%s:%d", cfg.Host, cfg.Port)
|
|
grpcConn, err := grpc.NewClient(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
|
|
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return grpcConn, nil
|
|
}
|