Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala RestartSource.withBackoff永不结束_Scala_Akka_Akka Stream_Akka Http - Fatal编程技术网

Scala RestartSource.withBackoff永不结束

Scala RestartSource.withBackoff永不结束,scala,akka,akka-stream,akka-http,Scala,Akka,Akka Stream,Akka Http,我正在尝试使用Akka创建Http客户端,并使用重试策略,在该策略中我希望最大重试次数,然后返回错误。有这个代码吗 private def makeRequest[T](system: ActorSystem, host: String, unmarshallFunc: ResponseEntity => Future[Either[ServiceNowAccessExcep

我正在尝试使用Akka创建Http客户端,并使用重试策略,在该策略中我希望最大重试次数,然后返回错误。有这个代码吗

private def makeRequest[T](system: ActorSystem,
                             host: String,
                             unmarshallFunc: ResponseEntity => Future[Either[ServiceNowAccessException, T]]): Future[Either[ServiceNowAccessException, T]] = {

    implicit val mat: Materializer =  Materializer(system)

    RestartSource.withBackoff(
      minBackoff = 10 seconds,
      maxBackoff = 10 seconds,
      randomFactor = 0.2,
      maxRestarts = 2
    ) { () =>
      Source.future(Http()(system).singleRequest(HttpRequest(uri = host)))
        .mapAsync(parallelism = 1) {
          case HttpResponse(OK, _, entity, _) => unmarshallFunc(entity)
          case HttpResponse(InternalServerError, _, _, _) =>
            Future(Left(ServiceNowAccessException(InternalServerError.intValue)))
          case HttpResponse(statusCode, _, _, _) =>
            Future(Left(ServiceNowAccessException(statusCode.intValue())))
        }
    }.runWith(Sink.head)
  }
我无法在
maxRestarts
启动后强制执行错误,并且它一直试图连接

知道我的代码有什么问题吗


问候。

它经常重启吗?时间在这里很重要。从:<代码> Max RealEnter,重新启动的数量在分钟备份的时间范围内被覆盖到这个数量。< /代码>它也被弃用,您是否考虑用接受重新启动设置的版本替换它?