Skip to content

Commit a0e9005

Browse files
committed
use two http clients
1 parent 7d5e120 commit a0e9005

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>io.eigr.spawn</groupId>
55
<artifactId>spawn-java-std-sdk</artifactId>
66
<packaging>jar</packaging>
7-
<version>0.7.1</version>
7+
<version>0.8.2</version>
88
<name>spawn-java-std-sdk</name>
99
<url>http://maven.apache.org</url>
1010

src/main/java/io/eigr/spawn/api/Spawn.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ private void startServer() throws SpawnException {
149149
httpServer.start();
150150

151151
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
152-
log.info("Stopping Spawn HTTP Server with termination grace period {} ...", this.terminationGracePeriodSeconds);
152+
log.info("Stopping Spawn HTTP Server with termination grace period {}s ...", this.terminationGracePeriodSeconds);
153153
httpServer.stop(this.terminationGracePeriodSeconds);
154154
}));
155155
} catch (IOException ex) {

src/main/java/io/eigr/spawn/internal/transport/client/OkHttpSpawnClient.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public final class OkHttpSpawnClient implements SpawnClient {
2424
private final int proxyPort;
2525
private final OkHttpClient client;
2626

27+
private final OkHttpClient spawnClient;
28+
2729
public OkHttpSpawnClient(String system, String proxyHost, int proxyPort) {
2830
this.system = system;
2931
this.proxyHost = proxyHost;
@@ -36,6 +38,14 @@ public OkHttpSpawnClient(String system, String proxyHost, int proxyPort) {
3638
.retryOnConnectionFailure(true)
3739
.connectionPool(new ConnectionPool(256, 100, TimeUnit.SECONDS))
3840
.build();
41+
42+
this.spawnClient = new OkHttpClient.Builder()
43+
.connectTimeout(60, TimeUnit.SECONDS)
44+
.readTimeout(60, TimeUnit.SECONDS)
45+
.writeTimeout(60, TimeUnit.SECONDS)
46+
.callTimeout(200, TimeUnit.SECONDS)
47+
.connectionPool(new ConnectionPool(256, 100, TimeUnit.SECONDS))
48+
.build();
3949
}
4050

4151
@Override
@@ -63,7 +73,7 @@ public Protocol.SpawnResponse spawn(Protocol.SpawnRequest registration) throws A
6373
.url(makeSpawnURLFrom(registration.getActors(0).getSystem()))
6474
.post(body).build();
6575

66-
Call call = client.newCall(request);
76+
Call call = spawnClient.newCall(request);
6777
try (Response response = call.execute()) {
6878
assert response.body() != null;
6979
return io.eigr.functions.protocol.Protocol.SpawnResponse.parseFrom(

0 commit comments

Comments
 (0)