14
14
import java .util .concurrent .ExecutorService ;
15
15
import java .util .concurrent .Executors ;
16
16
import java .util .concurrent .Future ;
17
+ import java .util .concurrent .TimeUnit ;
17
18
18
19
/** SharedInformerFactory class constructs and caches informers for api types. */
19
20
public class SharedInformerFactory {
@@ -24,9 +25,16 @@ public class SharedInformerFactory {
24
25
25
26
private ExecutorService informerExecutor ;
26
27
28
+ private ApiClient apiClient ;
29
+
27
30
/** Constructor w/ default thread pool. */
28
31
public SharedInformerFactory () {
29
- this (Executors .newCachedThreadPool ());
32
+ this (Configuration .getDefaultApiClient (), Executors .newCachedThreadPool ());
33
+ }
34
+
35
+ /** Constructor w/ api client specified and default thread pool. */
36
+ public SharedInformerFactory (ApiClient apiClient ) {
37
+ this (apiClient , Executors .newCachedThreadPool ());
30
38
}
31
39
32
40
/**
@@ -35,6 +43,17 @@ public SharedInformerFactory() {
35
43
* @param threadPool specified thread pool
36
44
*/
37
45
public SharedInformerFactory (ExecutorService threadPool ) {
46
+ this (Configuration .getDefaultApiClient (), threadPool );
47
+ }
48
+
49
+ /**
50
+ * Constructor w/ api client and thread pool specified.
51
+ *
52
+ * @param client specific api client
53
+ * @param threadPool specified thread pool
54
+ */
55
+ public SharedInformerFactory (ApiClient client , ExecutorService threadPool ) {
56
+ apiClient = client ;
38
57
informerExecutor = threadPool ;
39
58
informers = new HashMap <>();
40
59
startedInformers = new HashMap <>();
@@ -87,7 +106,8 @@ private <ApiType, ApiListType> ListerWatcher<ApiType, ApiListType> listerWatcher
87
106
CallGenerator callGenerator ,
88
107
Class <ApiType > apiTypeClass ,
89
108
Class <ApiListType > apiListTypeClass ) {
90
- ApiClient apiClient = Configuration .getDefaultApiClient ();
109
+ // set read timeout zero to ensure client doesn't time out
110
+ apiClient .getHttpClient ().setReadTimeout (0 , TimeUnit .MILLISECONDS );
91
111
return new ListerWatcher <ApiType , ApiListType >() {
92
112
@ Override
93
113
public ApiListType list (CallGeneratorParams params ) throws ApiException {
0 commit comments