@@ -51,12 +51,26 @@ module Spanner
5151 # end
5252 #
5353 class Client
54- ##
54+ # A semi-arbitrary constant for thread-wide global parameter name
5555 # @private
5656 IS_TRANSACTION_RUNNING_KEY = "ruby_spanner_is_transaction_running" . freeze
5757
58- ##
59- # @private Creates a new Spanner Client instance.
58+ # Creates a new Spanner Client instance.
59+ # @param project [::Google::Cloud::Spanner::Project] A `Spanner::Project` ref.
60+ # @param instance_id [::String] Instance id, e.g. `"my-instance"`.
61+ # @param database_id [::String] Database id, e.g. `"my-database"`.
62+ # @param session_labels [::Hash, nil] Optional. The labels to be applied to all sessions
63+ # created by the client. Example: `"team" => "billing-service"`.
64+ # @param pool_opts [::Hash] Optional. `Spanner::Pool` creation options.
65+ # Example parameter: `:keepalive`.
66+ # @param query_options [::Hash, nil] Optional. A hash of values to specify the custom
67+ # query options for executing SQL query. Example parameter `:optimizer_version`.
68+ # @param database_role [::String, nil] Optional. The Spanner session creator role.
69+ # Example: `analyst`
70+ # @param directed_read_options [::Hash, nil] Optional. Client options used to set
71+ # the `directed_read_options` for all ReadRequests and ExecuteSqlRequests.
72+ # Converts to `V1::DirectedReadOptions`. Example option: `:exclude_replicas`.
73+ # @private
6074 def initialize project , instance_id , database_id , session_labels : nil ,
6175 pool_opts : { } , query_options : nil , database_role : nil ,
6276 directed_read_options : nil
@@ -89,7 +103,7 @@ def database_id
89103 end
90104
91105 # The Spanner project connected to.
92- # @return [Project]
106+ # @return [::Google::Cloud::Spanner:: Project]
93107 def project
94108 @project
95109 end
@@ -2114,13 +2128,15 @@ def transaction deadline: 120, exclude_txn_from_change_streams: false,
21142128 yield tx
21152129 transaction_id = nil
21162130 transaction_id = tx . transaction_id if tx . existing_transaction?
2117- commit_resp = @project . service . commit \
2118- tx . session . path , tx . mutations ,
2131+ commit_resp = @project . service . commit (
2132+ tx . session . path ,
2133+ tx . mutations ,
21192134 transaction_id : transaction_id ,
21202135 exclude_txn_from_change_streams : exclude_txn_from_change_streams ,
21212136 commit_options : commit_options ,
21222137 request_options : request_options ,
21232138 call_options : call_options
2139+ )
21242140 resp = CommitResponse . from_grpc commit_resp
21252141 commit_options ? resp : resp . timestamp
21262142 rescue GRPC ::Aborted ,
@@ -2419,17 +2435,21 @@ def reset
24192435 @pool . reset
24202436 end
24212437
2422- ##
2438+ # Creates a new Session objece.
2439+ # @param multiplexed [::Boolean] Optional. Default to `false`.
2440+ # If `true`, specifies a multiplexed session.
24232441 # @private
2424- # Creates a new session object every time.
2425- def create_new_session
2442+ # @return [::Google::Cloud::Spanner::Session]
2443+ def create_new_session multiplexed : false
24262444 ensure_service!
24272445 grpc = @project . service . create_session \
24282446 Admin ::Database ::V1 ::DatabaseAdmin ::Paths . database_path (
24292447 project : project_id , instance : instance_id , database : database_id
24302448 ) ,
24312449 labels : @session_labels ,
2432- database_role : @database_role
2450+ database_role : @database_role ,
2451+ multiplexed : multiplexed
2452+
24332453 Session . from_grpc grpc , @project . service , query_options : @query_options
24342454 end
24352455
0 commit comments