You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/04/17 08:02:00 UTC

[jira] [Work logged] (BEAM-9571) Add withMongoClientProvider to MongoDbIO

     [ https://issues.apache.org/jira/browse/BEAM-9571?focusedWorklogId=423983&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-423983 ]

ASF GitHub Bot logged work on BEAM-9571:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 17/Apr/20 08:01
            Start Date: 17/Apr/20 08:01
    Worklog Time Spent: 10m 
      Work Description: alexvanboxel commented on pull request #11258: [BEAM-9571] Add withMongoClientProvider to MongoDbIO
URL: https://github.com/apache/beam/pull/11258#discussion_r410057736
 
 

 ##########
 File path: sdks/java/io/mongodb/src/main/java/org/apache/beam/sdk/io/mongodb/MongoDbIO.java
 ##########
 @@ -843,22 +843,39 @@ private MongoClient createClient(Read spec) {
      */
     public Write withUri(String uri) {
       checkArgument(uri != null, "uri can not be null");
-      return builder().setUri(uri).build();
+      Write spec = toBuilder().setUri(uri).build();
+      return withMongoClientProvider(
+              DefaultMongoClientProvider.of(
+                  spec.uri(),
+                  spec.maxConnectionIdleTime(),
+                  spec.sslEnabled(),
+                  spec.sslInvalidHostNameAllowed(),
+                  spec.ignoreSSLCertificate()))
+          .toBuilder()
+          .setUri(uri)
+          .build();
     }
 
     /** Sets the maximum idle time for a pooled connection. */
     public Write withMaxConnectionIdleTime(int maxConnectionIdleTime) {
-      return builder().setMaxConnectionIdleTime(maxConnectionIdleTime).build();
+      return toBuilder().setMaxConnectionIdleTime(maxConnectionIdleTime).build();
     }
 
     /** Enable ssl for connection. */
     public Write withSSLEnabled(boolean sslEnabled) {
-      return builder().setSslEnabled(sslEnabled).build();
+      return toBuilder().setSslEnabled(sslEnabled).build();
     }
 
     /** Enable invalidHostNameAllowed for ssl for connection. */
     public Write withSSLInvalidHostNameAllowed(boolean invalidHostNameAllowed) {
-      return builder().setSslInvalidHostNameAllowed(invalidHostNameAllowed).build();
+      return toBuilder().setSslInvalidHostNameAllowed(invalidHostNameAllowed).build();
+    }
+
+    /** Sets a MongoClient provider. */
+    public Write withMongoClientProvider(
 
 Review comment:
   Maybe we should rename this to withClientProvider, the we can use this pattern in other IO's and make it as part of a IO style guide to make them more consistent. WDYT?
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 423983)
    Time Spent: 1h 40m  (was: 1.5h)

> Add withMongoClientProvider to MongoDbIO
> ----------------------------------------
>
>                 Key: BEAM-9571
>                 URL: https://issues.apache.org/jira/browse/BEAM-9571
>             Project: Beam
>          Issue Type: Improvement
>          Components: io-java-mongodb
>            Reporter: Ismaël Mejía
>            Assignee: Ismaël Mejía
>            Priority: Minor
>             Fix For: 2.22.0
>
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> Users of MongoDB may want to provide more details or configure advanced parameteres like SSL validations explicitly. We can offer a method `.withMongoClientProvider` that provides clients as needed as we do in other IOs.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)