package grpc import ( "context" "errors" "finclip-app-manager/infrastructure/config" pb "finclip-app-manager/infrastructure/protobuf/golang" ) func GetDomainInfo(ctx context.Context, appId string) (*pb.GetAllDomainInternalRsp_DATA, error) { var rsp *pb.GetAllDomainInternalRsp var err error for i := 0; i < 2; i++ { conn, err1 := GetGrpcConnManager().GetConn(config.GetConfig().ConsulAddr, "mop-domain-manager", "tag="+config.GetConfig().ConsulTag) if err1 != nil { err = err1 continue } c := pb.NewMopDomainManagerClient(conn) var req pb.GetAllDomainInternalReq req.AppId = appId rsp, err = c.GetAllDomainInternal(ctx, &req) if err != nil { log.Errorf("err=%s", err.Error()) continue } else { err = nil break } } if err != nil { return nil, err } if rsp.Result.Httpcode != 200 { return nil, errors.New(rsp.Result.Error) } return rsp.Data, nil } func GetDomainInfoV2(ctx context.Context, organId string) (*pb.GetAllDomainInternalV2Rsp_DATA, error) { var rsp *pb.GetAllDomainInternalV2Rsp var err error for i := 0; i < 2; i++ { conn, err1 := GetGrpcConnManager().GetConn(config.GetConfig().ConsulAddr, "mop-domain-manager", "tag="+config.GetConfig().ConsulTag) if err1 != nil { err = err1 continue } c := pb.NewMopDomainManagerClient(conn) var req pb.GetAllDomainInternalV2Req req.OrganId = organId rsp, err = c.GetAllDomainInternalV2(ctx, &req) if err != nil { log.Errorf("err=%s", err.Error()) continue } else { err = nil break } } if err != nil { return nil, err } if rsp.Result.Httpcode != 200 { return nil, errors.New(rsp.Result.Error) } return rsp.Data, nil }