Skip to content

Commit

Permalink
Use longer timeout for Await
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial committed Mar 27, 2020
1 parent 1ffa340 commit 24ab0e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
val SONATYPE_VERSION = sys.env.getOrElse("SONATYPE_VERSION", "3.8.1")
val SONATYPE_VERSION = sys.env.getOrElse("SONATYPE_VERSION", "3.9.1")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % SONATYPE_VERSION)
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
Expand Down
13 changes: 7 additions & 6 deletions src/main/scala/xerial/sbt/sonatype/SonatypeClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import org.apache.http.impl.client.BasicCredentialsProvider
import org.sonatype.spice.zapper.ParametersBuilder
import org.sonatype.spice.zapper.client.hc4.Hc4ClientBuilder
import sbt.librarymanagement.ivy.{Credentials, DirectCredentials}
import wvlet.airframe.control.{ResultClass, Retry}
import wvlet.airframe.control.{Control, ResultClass, Retry}
import wvlet.airframe.http.finagle.Finagle
import wvlet.airframe.http.{HttpClient, HttpStatus}
import wvlet.log.LogSupport
Expand Down Expand Up @@ -61,6 +61,8 @@ class SonatypeClient(repositoryUrl: String,
}

private val clientConfig = Finagle.client
// airframe-http will retry the request several times within this timeout duration.
.withTimeout(Duration(10, TimeUnit.MINUTES))
.withRetryContext {
import wvlet.airframe.http.finagle._
// For individual REST calls, use a normal jittering
Expand All @@ -76,15 +78,14 @@ class SonatypeClient(repositoryUrl: String,
}

private val httpClient = clientConfig.newSyncClient(repoUri)
// Create stage is not idempotent, so we just need to wait for a long time

// Create stage is not idempotent, so we just need to wait for a long time without retry
private val httpClientForCreateStage =
clientConfig.noRetry
.withTimeout(Duration(5, TimeUnit.MINUTES))
.newSyncClient(repoUri)

override def close(): Unit = {
httpClient.close()
httpClientForCreateStage.close()
Control.closeResources(httpClient.close(), httpClientForCreateStage.close())
}

import xerial.sbt.sonatype.SonatypeClient._
Expand Down Expand Up @@ -128,7 +129,7 @@ class SonatypeClient(repositoryUrl: String,
private val monitor = new ActivityMonitor()

/**
* backoff retry (max 30 sec. / each http request) until the timeout reaches (upto 60 min by default)
* backoff retry (max 15 sec. / each http request) until the timeout reaches (upto 60 min by default)
*/
private val retryer = {
val maxInterval = 15000
Expand Down

0 comments on commit 24ab0e9

Please sign in to comment.