Skip to content

Commit

Permalink
Allow use virtual threads in Wave client
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Jul 26, 2023
1 parent 077ed5d commit dd32f80
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions plugins/nf-wave/src/main/io/seqera/wave/plugin/WaveClient.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import java.time.Duration
import java.time.OffsetDateTime
import java.time.temporal.ChronoUnit
import java.util.concurrent.Callable
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit
import java.util.function.Predicate

Expand Down Expand Up @@ -56,6 +57,7 @@ import nextflow.processor.Architecture
import nextflow.processor.TaskRun
import nextflow.script.bundle.ResourcesBundle
import nextflow.util.SysHelper
import nextflow.util.Threads
import org.slf4j.Logger
import org.slf4j.LoggerFactory
/**
Expand Down Expand Up @@ -127,12 +129,20 @@ class WaveClient {
// the cookie manager
cookieManager = new CookieManager()
// create http client
this.httpClient = HttpClient.newBuilder()
this.httpClient = newHttpClient()
}

protected HttpClient newHttpClient() {
final builder = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_1_1)
.followRedirects(HttpClient.Redirect.NEVER)
.cookieHandler(cookieManager)
.connectTimeout(config.httpOpts().connectTimeout())
.build()
// use virtual threads executor if enabled
if( Threads.useVirtual() )
builder.executor(Executors.newVirtualThreadPerTaskExecutor())
// build and return the new client
return builder.build()
}

WaveConfig config() { return config }
Expand Down

0 comments on commit dd32f80

Please sign in to comment.