@@ -65,7 +65,7 @@ public class PrometheusRSocketClient {
65
65
private volatile boolean requestedDisconnect = false ;
66
66
private RSocket sendingSocket ;
67
67
68
- private Duration timeout = Duration . ofSeconds ( 5 ) ;
68
+ private Duration timeout ;
69
69
70
70
/**
71
71
* Creates a {@link PrometheusRSocketClient}.
@@ -97,6 +97,7 @@ private PrometheusRSocketClient(MeterRegistryAndScrape<?> registryAndScrape,
97
97
Duration timeout ,
98
98
Runnable onKeyReceived ) {
99
99
this .registryAndScrape = registryAndScrape ;
100
+ this .timeout = timeout ;
100
101
101
102
RSocketConnector .create ()
102
103
.reconnect (new Retry () {
@@ -301,7 +302,7 @@ public static class Builder {
301
302
private Retry retry = Retry .backoff (Long .MAX_VALUE , Duration .ofSeconds (10 ))
302
303
.maxBackoff (Duration .ofMinutes (10 ));
303
304
304
- private Duration timeout ;
305
+ private Duration timeout = Duration . ofSeconds ( 5 ) ;
305
306
306
307
private Runnable onKeyReceived = () -> {
307
308
};
@@ -350,6 +351,17 @@ public Builder doOnKeyReceived(Runnable onKeyReceived) {
350
351
* @return the {@link PrometheusRSocketClient}
351
352
*/
352
353
public PrometheusRSocketClient connect () {
354
+ return connect (timeout );
355
+ }
356
+
357
+ /**
358
+ * Connects the {@link PrometheusRSocketClient}.
359
+ *
360
+ * @param timeout the timeout for the client to connect
361
+ *
362
+ * @return the {@link PrometheusRSocketClient}
363
+ */
364
+ public PrometheusRSocketClient connect (Duration timeout ) {
353
365
LOGGER .debug ("Connecting to RSocket Proxy..." );
354
366
return new PrometheusRSocketClient (
355
367
registryAndScrape ,
@@ -384,6 +396,7 @@ public PrometheusRSocketClient connectBlockingly(Duration timeout) {
384
396
registryAndScrape ,
385
397
clientTransport ,
386
398
retry ,
399
+ timeout ,
387
400
() -> {
388
401
LOGGER .info ("Connected to RSocket Proxy!" );
389
402
onKeyReceived .run ();
0 commit comments