in internal/task/task.go [103:126]
func getGRPCConn() (*grpc.ClientConn, error) {
namingClient := selector.Get(pconfig.GlobalConfig().Server.Name)
if namingClient == nil {
return nil, fmt.Errorf("naming client is not registered.please register it")
}
instance, err := namingClient.Select(config.Get().Catalog.ServerName)
if err != nil {
return nil, err
}
if instance == nil {
return nil, fmt.Errorf("catalog client is not running.please check it")
}
host, port, err := net.SplitHostPort(instance.Address)
if err != nil {
return nil, err
}
addr := fmt.Sprintf("%v:%v", host, port)
conn, err := grpc.Dial(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, err
}
log.Get(constants.LogSchedule).Infof("success make grpc conn with:%s", addr)
return conn, nil
}