From 35ed0bf412f107bc6d8abcebf183861d2a24739d Mon Sep 17 00:00:00 2001
From: youngfreeFJS <471011042@qq.com>
Date: Mon, 6 Sep 2021 19:33:01 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9okHttpClient=20builder=20?=
=?UTF-8?q?timeout?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../lyrebird/client/LyrebirdClient.java | 20 ++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java b/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java
index 45840b4..58bfa36 100644
--- a/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java
+++ b/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java
@@ -10,11 +10,14 @@
import io.socket.client.IO;
import io.socket.client.Socket;
import java.net.URISyntaxException;
+import okhttp3.OkHttpClient;
+import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;
import java.io.IOException;
import java.lang.reflect.Method;
+import java.util.concurrent.TimeUnit;
public class LyrebirdClient {
private LyrebirdService lyrebirdService;
@@ -23,11 +26,22 @@ public class LyrebirdClient {
public LyrebirdClient(String lyrebirdRemoteAddress) {
ObjectMapper mapper = new ObjectMapper();
mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
- Retrofit retrofit = new Retrofit
+
+ OkHttpClient.Builder httpClient = new OkHttpClient.Builder()
+ .callTimeout(1, TimeUnit.MINUTES)
+ .connectTimeout(1,TimeUnit.MINUTES)
+ .readTimeout(1,TimeUnit.MINUTES)
+ .writeTimeout(1,TimeUnit.MINUTES);
+
+ Retrofit.Builder builder = new Retrofit
.Builder()
.baseUrl(lyrebirdRemoteAddress)
- .addConverterFactory(JacksonConverterFactory.create(mapper))
- .build();
+ .addConverterFactory(JacksonConverterFactory.create(mapper));
+
+ builder.client(httpClient.build());
+ Retrofit retrofit = builder.build();
+
+ // create service
lyrebirdService = retrofit.create(LyrebirdService.class);
}
From 4a92ad9d906e473ad056559aa741204d43cd7c26 Mon Sep 17 00:00:00 2001
From: youngfreeFJS <471011042@qq.com>
Date: Wed, 8 Sep 2021 11:30:04 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=89=88=E6=9C=AC?=
=?UTF-8?q?=E5=8F=B7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index dfda6f1..6624b3f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
com.github.meituan-dianping.lyrebird.sdk
lyrebird-java-client
- 1.1.5
+ 1.1.6
lyrebird-java-client
https://github.com/Meituan-Dianping/lyrebird-java-client
From 393a1b7f3975efe26bfe42a8858b1fdaa40323db Mon Sep 17 00:00:00 2001
From: youngfreeFJS <471011042@qq.com>
Date: Thu, 9 Sep 2021 11:11:55 +0800
Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=8F=82?=
=?UTF-8?q?=E6=95=B0=E5=8F=AF=E4=BC=A0=E9=80=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/com/meituan/lyrebird/Lyrebird.java | 21 ++++++++++++++++++-
.../lyrebird/client/LyrebirdClient.java | 21 ++++++++++++-------
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/meituan/lyrebird/Lyrebird.java b/src/main/java/com/meituan/lyrebird/Lyrebird.java
index 98adb07..30f8a6a 100644
--- a/src/main/java/com/meituan/lyrebird/Lyrebird.java
+++ b/src/main/java/com/meituan/lyrebird/Lyrebird.java
@@ -10,6 +10,7 @@
import com.meituan.lyrebird.client.api.*;
import java.net.URISyntaxException;
+import java.util.concurrent.TimeUnit;
public class Lyrebird {
private LyrebirdClient client;
@@ -20,7 +21,25 @@ public Lyrebird() {
}
public Lyrebird(String lyrebirdRemoteAddress) {
- client = new LyrebirdClient(lyrebirdRemoteAddress);
+ this(lyrebirdRemoteAddress,TimeUnit.SECONDS,0,10,10,0);
+ }
+
+ public Lyrebird(
+ String lyrebirdRemoteAddress,
+ TimeUnit timeUnit,
+ long callTimeout,
+ long connectTimeout,
+ long readTimeout,
+ long writeTimeout
+ ) {
+ client = new LyrebirdClient(
+ lyrebirdRemoteAddress,
+ timeUnit,
+ callTimeout,
+ connectTimeout,
+ readTimeout,
+ writeTimeout
+ );
}
/**
diff --git a/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java b/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java
index 58bfa36..d74a12b 100644
--- a/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java
+++ b/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java
@@ -23,22 +23,29 @@ public class LyrebirdClient {
private LyrebirdService lyrebirdService;
private Socket socket;
- public LyrebirdClient(String lyrebirdRemoteAddress) {
+ public LyrebirdClient(
+ String lyrebirdRemoteAddress,
+ TimeUnit timeUnit,
+ long callTimeout,
+ long connectTimeout,
+ long readTimeout,
+ long writeTimeout
+ ) {
ObjectMapper mapper = new ObjectMapper();
mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder()
- .callTimeout(1, TimeUnit.MINUTES)
- .connectTimeout(1,TimeUnit.MINUTES)
- .readTimeout(1,TimeUnit.MINUTES)
- .writeTimeout(1,TimeUnit.MINUTES);
+ .callTimeout(callTimeout, timeUnit)
+ .connectTimeout(connectTimeout,timeUnit)
+ .readTimeout(readTimeout,timeUnit)
+ .writeTimeout(writeTimeout,timeUnit);
Retrofit.Builder builder = new Retrofit
.Builder()
.baseUrl(lyrebirdRemoteAddress)
- .addConverterFactory(JacksonConverterFactory.create(mapper));
+ .addConverterFactory(JacksonConverterFactory.create(mapper))
+ .client(httpClient.build());
- builder.client(httpClient.build());
Retrofit retrofit = builder.build();
// create service
From 679188f4a019262b2c6ed47ad8074659812860d2 Mon Sep 17 00:00:00 2001
From: youngfreeFJS <471011042@qq.com>
Date: Thu, 9 Sep 2021 11:18:28 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E6=95=88?=
=?UTF-8?q?=E5=BC=95=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java b/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java
index d74a12b..9ff62d7 100644
--- a/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java
+++ b/src/main/java/com/meituan/lyrebird/client/LyrebirdClient.java
@@ -11,7 +11,6 @@
import io.socket.client.Socket;
import java.net.URISyntaxException;
import okhttp3.OkHttpClient;
-import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;