Class SpannerClients

java.lang.Object
io.github.flink.gcp.connector.spanner.SpannerClients

@Internal public final class SpannerClients extends Object
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 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 reach
      emulatorEndpoint - the emulator to reach, or null for 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 reach
      emulatorEndpoint - the emulator to reach, or null for the real service
      credentialsOverride - credentials loaded by the runtime component, or null for 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 reach
      emulatorEndpoint - the emulator to reach, or null for the real service
      credentialsOverride - credentials loaded by the runtime component, or null for 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 message
      settings - 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