[
https://issues.apache.org/jira/browse/BEAM-8169?focusedWorklogId=308372&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-308372
]
ASF GitHub Bot logged work on BEAM-8169:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Sep/19 17:57
Start Date: 07/Sep/19 17:57
Worklog Time Spent: 10m
Work Description: kennknowles commented on pull request #9511:
[BEAM-8169] DataCatalogTableProvider to use GCP credentials from PipelineOptions
URL: https://github.com/apache/beam/pull/9511#discussion_r321977873
##########
File path:
sdks/java/extensions/sql/datacatalog/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/datacatalog/DataCatalogClientAdapter.java
##########
@@ -31,63 +30,51 @@
import io.grpc.ManagedChannelBuilder;
import io.grpc.MethodDescriptor;
import io.grpc.auth.MoreCallCredentials;
-import java.io.IOException;
+import java.util.function.Supplier;
import javax.annotation.Nullable;
+import org.apache.beam.sdk.extensions.gcp.options.GcpOptions;
import org.apache.beam.sdk.extensions.sql.meta.Table;
/** Wraps DataCatalog GRPC client and exposes simplified APIS for Data Catalog
Table Provider. */
class DataCatalogClientAdapter {
- private DataCatalogBlockingStub dcClient;
+ private DataCatalogPipelineOptions options;
- private DataCatalogClientAdapter(DataCatalogBlockingStub dcClient) {
- this.dcClient = dcClient;
+ private Supplier<DataCatalogBlockingStub> dcClient = () ->
newClient(options);
+
+ private DataCatalogClientAdapter(DataCatalogPipelineOptions options) {
+ this.options = options;
}
/** Prod endpoint (default set in pipeline options):
datacatalog.googleapis.com. */
- public static DataCatalogClientAdapter withDefaultCredentials(String
endpoint)
- throws IOException {
- return new DataCatalogClientAdapter(newClient(endpoint));
+ public static DataCatalogClientAdapter
withOptions(DataCatalogPipelineOptions options) {
+ return new DataCatalogClientAdapter(options);
}
- private static DataCatalogBlockingStub newClient(String endpoint) throws
IOException {
+ private DataCatalogBlockingStub newClient(DataCatalogPipelineOptions
options) {
Review comment:
Actually, I think the client and the adapter should have the same lifetime
if the client is an internal detail. And each new `DataCatalogClientAdapter`
could have different pipeline options, so you would need to manage multiple
underlying clients.
I tried the alternative of injecting a client, so the caller could own the
configuration and lifecycle. And that made this class pretty pointless, so I
just inlined the whole class and some other trivial methods.
----------------------------------------------------------------
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:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 308372)
Time Spent: 1h 20m (was: 1h 10m)
> DataCatalogTableProvider should use credentials from PipelineOptions
> --------------------------------------------------------------------
>
> Key: BEAM-8169
> URL: https://issues.apache.org/jira/browse/BEAM-8169
> Project: Beam
> Issue Type: Bug
> Components: dsl-sql
> Reporter: Kenneth Knowles
> Assignee: Kenneth Knowles
> Priority: Major
> Time Spent: 1h 20m
> Remaining Estimate: 0h
>
> Currently it is hardcoded to the default credentials, but the use should be
> in control via PipelineOptions. This is also the mechanism for injecting
> mock/test credentials.
--
This message was sent by Atlassian Jira
(v8.3.2#803003)