in cloud-spanner-r2dbc/src/main/java/com/google/cloud/spanner/r2dbc/SpannerConnectionConfiguration.java [194:223]
public SpannerOptions buildSpannerOptions() {
SpannerOptions.Builder optionsBuilder = SpannerOptions.newBuilder();
if (this.options.hasOption(ConnectionFactoryOptions.HOST)) {
int port = 443;
if (this.options.hasOption(ConnectionFactoryOptions.PORT)) {
port = (Integer) Objects.requireNonNull(
this.options.getValue(ConnectionFactoryOptions.PORT));
}
String host = String.format("http://%s:%d", this.options.getValue(ConnectionFactoryOptions.HOST), port);
optionsBuilder.setHost(host);
}
if (this.projectId != null) {
optionsBuilder.setProjectId(this.projectId);
}
if (this.credentials != null) {
optionsBuilder.setCredentials(this.credentials);
}
if (this.usePlainText) {
optionsBuilder.setChannelConfigurator(ManagedChannelBuilder::usePlaintext);
}
optionsBuilder.setHeaderProvider(() ->
Collections.singletonMap(USER_AGENT_KEY, USER_AGENT_LIBRARY_NAME + "/" + PACKAGE_VERSION));
// usePlainText is not currently used in the client library.
// TODO (GH-200): allow customizing emulator with optionsBuilder.setEmulatorHost()
return optionsBuilder.build();
}