27 lines
550 B
Go
27 lines
550 B
Go
package initialize
|
|
|
|
import (
|
|
"codeword/internal/proto/discount"
|
|
"context"
|
|
"google.golang.org/grpc"
|
|
"time"
|
|
)
|
|
|
|
func DiscountGRPCClient(address string) (discount.DiscountServiceClient, error) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
|
|
defer cancel()
|
|
|
|
options := []grpc.DialOption{
|
|
grpc.WithInsecure(),
|
|
//grpc.WithBlock(),
|
|
}
|
|
|
|
conn, err := grpc.DialContext(ctx, address, options...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
discountClient := discount.NewDiscountServiceClient(conn)
|
|
return discountClient, nil
|
|
}
|