@@ -175,7 +175,7 @@ public class SpannerOptions extends ServiceOptions<Spanner, SpannerOptions> {
175175 private final CloseableExecutorProvider asyncExecutorProvider ;
176176 private final String compressorName ;
177177 private final boolean leaderAwareRoutingEnabled ;
178- private final boolean attemptDirectPath ;
178+ private final boolean enableDirectAccess ;
179179 private final DirectedReadOptions directedReadOptions ;
180180 private final boolean useVirtualThreads ;
181181 private final OpenTelemetry openTelemetry ;
@@ -806,7 +806,7 @@ protected SpannerOptions(Builder builder) {
806806 asyncExecutorProvider = builder .asyncExecutorProvider ;
807807 compressorName = builder .compressorName ;
808808 leaderAwareRoutingEnabled = builder .leaderAwareRoutingEnabled ;
809- attemptDirectPath = builder .attemptDirectPath ;
809+ enableDirectAccess = builder .enableDirectAccess ;
810810 directedReadOptions = builder .directedReadOptions ;
811811 useVirtualThreads = builder .useVirtualThreads ;
812812 openTelemetry = builder .openTelemetry ;
@@ -849,6 +849,10 @@ default boolean isEnableApiTracing() {
849849 return false ;
850850 }
851851
852+ default boolean isEnableDirectAccess () {
853+ return false ;
854+ }
855+
852856 default boolean isEnableBuiltInMetrics () {
853857 return true ;
854858 }
@@ -884,6 +888,8 @@ private static class SpannerEnvironmentImpl implements SpannerEnvironment {
884888 "SPANNER_OPTIMIZER_STATISTICS_PACKAGE" ;
885889 private static final String SPANNER_ENABLE_EXTENDED_TRACING = "SPANNER_ENABLE_EXTENDED_TRACING" ;
886890 private static final String SPANNER_ENABLE_API_TRACING = "SPANNER_ENABLE_API_TRACING" ;
891+ private static final String GOOGLE_SPANNER_ENABLE_DIRECT_ACCESS =
892+ "GOOGLE_SPANNER_ENABLE_DIRECT_ACCESS" ;
887893 private static final String SPANNER_ENABLE_END_TO_END_TRACING =
888894 "SPANNER_ENABLE_END_TO_END_TRACING" ;
889895 private static final String SPANNER_DISABLE_BUILTIN_METRICS = "SPANNER_DISABLE_BUILTIN_METRICS" ;
@@ -916,6 +922,11 @@ public boolean isEnableApiTracing() {
916922 return Boolean .parseBoolean (System .getenv (SPANNER_ENABLE_API_TRACING ));
917923 }
918924
925+ @ Override
926+ public boolean isEnableDirectAccess () {
927+ return Boolean .parseBoolean (System .getenv (GOOGLE_SPANNER_ENABLE_DIRECT_ACCESS ));
928+ }
929+
919930 @ Override
920931 public boolean isEnableBuiltInMetrics () {
921932 return !Boolean .parseBoolean (System .getenv (SPANNER_DISABLE_BUILTIN_METRICS ));
@@ -1000,7 +1011,7 @@ public static class Builder
10001011 private String compressorName ;
10011012 private String emulatorHost = System .getenv ("SPANNER_EMULATOR_HOST" );
10021013 private boolean leaderAwareRoutingEnabled = true ;
1003- private boolean attemptDirectPath = true ;
1014+ private boolean enableDirectAccess = SpannerOptions . environment . isEnableDirectAccess () ;
10041015 private DirectedReadOptions directedReadOptions ;
10051016 private boolean useVirtualThreads = false ;
10061017 private OpenTelemetry openTelemetry ;
@@ -1072,7 +1083,7 @@ protected Builder() {
10721083 this .channelProvider = options .channelProvider ;
10731084 this .channelConfigurator = options .channelConfigurator ;
10741085 this .interceptorProvider = options .interceptorProvider ;
1075- this .attemptDirectPath = options .attemptDirectPath ;
1086+ this .enableDirectAccess = options .enableDirectAccess ;
10761087 this .directedReadOptions = options .directedReadOptions ;
10771088 this .useVirtualThreads = options .useVirtualThreads ;
10781089 this .enableApiTracing = options .enableApiTracing ;
@@ -1605,8 +1616,15 @@ public Builder disableLeaderAwareRouting() {
16051616 }
16061617
16071618 @ BetaApi
1619+ public Builder setEnableDirectAccess (boolean enableDirectAccess ) {
1620+ this .enableDirectAccess = enableDirectAccess ;
1621+ return this ;
1622+ }
1623+
1624+ @ ObsoleteApi ("Use setEnableDirectAccess(false) instead" )
1625+ @ Deprecated
16081626 public Builder disableDirectPath () {
1609- this .attemptDirectPath = false ;
1627+ this .enableDirectAccess = false ;
16101628 return this ;
16111629 }
16121630
@@ -1974,8 +1992,14 @@ public DirectedReadOptions getDirectedReadOptions() {
19741992 }
19751993
19761994 @ BetaApi
1995+ public Boolean isEnableDirectAccess () {
1996+ return enableDirectAccess ;
1997+ }
1998+
1999+ @ ObsoleteApi ("Use isEnableDirectAccess() instead" )
2000+ @ Deprecated
19772001 public boolean isAttemptDirectPath () {
1978- return attemptDirectPath ;
2002+ return enableDirectAccess ;
19792003 }
19802004
19812005 /**
0 commit comments