2024-01-17 18:50:50 +00:00
|
|
|
package initialize
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2024-11-22 11:22:08 +00:00
|
|
|
"gitea.pena/PenaSide/codeword/internal/proto/discount"
|
2024-01-17 18:50:50 +00:00
|
|
|
"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(),
|
2024-03-03 10:49:46 +00:00
|
|
|
//grpc.WithBlock(),
|
2024-01-17 18:50:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
conn, err := grpc.DialContext(ctx, address, options...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
discountClient := discount.NewDiscountServiceClient(conn)
|
|
|
|
return discountClient, nil
|
|
|
|
}
|