Class SpannerClients
java.lang.Object
io.github.flink.gcp.connector.spanner.SpannerClients
Builds the Spanner service handle both directions of this connector open.
One helper rather than one copy per direction, because the emulator-versus-credentials branch is exactly the code that reads green on a developer machine and red in CI: a handle built without the emulator host reaches for application default credentials, which a workstation has and a build agent does not.
Nothing else about the connection is configured. Spanner's own setEmulatorHost
switches the channel to plaintext and the credentials to none in one call, so this connector
never goes through the shared plaintext-channel helpers the other connectors need.
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.cloud.spanner.Spanneropen(DatabaseDestination database, com.google.cloud.spanner.SpannerOptions settings) Opens a handle from settings already assembled by the owning runtime component.static com.google.cloud.spanner.Spanneropen(DatabaseDestination database, EmulatorEndpoint emulatorEndpoint, com.google.auth.Credentials credentialsOverride) Opens a service handle for a database, with an optional runtime-loaded credential override.static com.google.cloud.spanner.SpannerOptionssettings(DatabaseDestination database, EmulatorEndpoint emulatorEndpoint) Builds the client settings for a database.static com.google.cloud.spanner.SpannerOptionssettings(DatabaseDestination database, EmulatorEndpoint emulatorEndpoint, com.google.auth.Credentials credentialsOverride) Builds client settings with an optional runtime-loaded credential override.
-
Method Details
-
settings
public static com.google.cloud.spanner.SpannerOptions settings(DatabaseDestination database, @Nullable EmulatorEndpoint emulatorEndpoint) Builds the client settings for a database.Separate from
open(DatabaseDestination, SpannerOptions)so that the mapping is testable without opening a channel.- Parameters:
database- the database the handle will reachemulatorEndpoint- the emulator to reach, ornullfor the real service- Returns:
- the settings
-
settings
public static com.google.cloud.spanner.SpannerOptions settings(DatabaseDestination database, @Nullable EmulatorEndpoint emulatorEndpoint, @Nullable com.google.auth.Credentials credentialsOverride) Builds client settings with an optional runtime-loaded credential override.- Parameters:
database- the database the handle will reachemulatorEndpoint- the emulator to reach, ornullfor the real servicecredentialsOverride- credentials loaded by the runtime component, ornullfor ADC- Returns:
- the settings
-
open
public static com.google.cloud.spanner.Spanner open(DatabaseDestination database, @Nullable EmulatorEndpoint emulatorEndpoint, @Nullable com.google.auth.Credentials credentialsOverride) throws IOException Opens a service handle for a database, with an optional runtime-loaded credential override.- Parameters:
database- the database to reachemulatorEndpoint- the emulator to reach, ornullfor the real servicecredentialsOverride- credentials loaded by the runtime component, ornullfor ADC- Returns:
- the handle, which the caller owns and must close
- Throws:
IOException- if the handle cannot be created
-
open
public static com.google.cloud.spanner.Spanner open(DatabaseDestination database, com.google.cloud.spanner.SpannerOptions settings) throws IOException Opens a handle from settings already assembled by the owning runtime component.- Parameters:
database- the database to reach, for the failure messagesettings- the settings to open the handle from- Returns:
- the handle, which the caller owns and must close
- Throws:
IOException- if the handle cannot be created
-