package grpc_init import ( "aps_crm/conf" "aps_crm/pkg/logx" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" ) var ( ProductInventoryServiceConn *grpc.ClientConn CrmApsGrpcServiceConn *grpc.ClientConn ) func InitCrmApsGrpcServiceConn() { var err error CrmApsGrpcServiceConn, err = grpc.Dial(conf.Conf.GrpcServiceAddr.Aps, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { logx.Errorf("grpc dial InitCrmApsGrpcServiceConn service error: %v", err.Error()) return } } func CloseCrmApsGrpcServiceConn() { if CrmApsGrpcServiceConn != nil { CrmApsGrpcServiceConn.Close() } } func InitProductInventoryServiceConn() { var err error ProductInventoryServiceConn, err = grpc.Dial(conf.Conf.GrpcServiceAddr.WMS, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { logx.Errorf("grpc dial product service error: %v", err.Error()) return } } func CloseProductInventoryServiceConn() { if ProductInventoryServiceConn != nil { ProductInventoryServiceConn.Close() } }