8
8
import dagger .Provides ;
9
9
import io .deephaven .client .impl .SessionImpl ;
10
10
import io .deephaven .client .impl .SessionImplConfig ;
11
- import io .deephaven .client .impl .SessionImplConfig .Builder ;
12
11
import io .deephaven .proto .DeephavenChannel ;
13
12
import io .deephaven .proto .DeephavenChannelImpl ;
14
13
import io .grpc .Channel ;
18
17
import javax .inject .Named ;
19
18
import java .util .concurrent .ScheduledExecutorService ;
20
19
20
+ /**
21
+ * Provides {@link Channel}, {@link DeephavenChannel}, {@link SessionImplConfig}, and {@link SessionImpl}.
22
+ */
21
23
@ Module
22
24
public interface SessionImplModule {
23
25
@@ -27,19 +29,29 @@ public interface SessionImplModule {
27
29
@ Binds
28
30
DeephavenChannel bindsDeephavenChannelImpl (DeephavenChannelImpl deephavenChannelImpl );
29
31
32
+ /**
33
+ * Delegates to {@link SessionImplConfig#of(DeephavenChannel, ScheduledExecutorService, String)}.
34
+ */
30
35
@ Provides
31
- static SessionImpl session (DeephavenChannel channel , ScheduledExecutorService scheduler ,
36
+ static SessionImplConfig providesSessionImplConfig (
37
+ DeephavenChannel channel ,
38
+ ScheduledExecutorService scheduler ,
32
39
@ Nullable @ Named ("authenticationTypeAndValue" ) String authenticationTypeAndValue ) {
33
- final Builder builder = SessionImplConfig .builder ()
34
- .executor (scheduler )
35
- .channel (channel );
36
- if (authenticationTypeAndValue != null ) {
37
- builder .authenticationTypeAndValue (authenticationTypeAndValue );
38
- }
39
- final SessionImplConfig config = builder .build ();
40
+ return SessionImplConfig .of (channel , scheduler , authenticationTypeAndValue );
41
+ }
42
+
43
+ /**
44
+ * Creates a session. Equivalent to {@link SessionImplConfig#createSession()}.
45
+ *
46
+ * @param config the config
47
+ * @return the session
48
+ */
49
+ @ Provides
50
+ static SessionImpl session (SessionImplConfig config ) {
40
51
try {
41
52
return config .createSession ();
42
53
} catch (InterruptedException e ) {
54
+ Thread .currentThread ().interrupt ();
43
55
throw new RuntimeException (e );
44
56
}
45
57
}
0 commit comments