1- // Copyright 2018 Google LLC.
1+ // Copyright 2019 Google LLC.
22//
33// Licensed under the Apache License, Version 2.0 (the "License");
44// you may not use this file except in compliance with the License.
@@ -66,6 +66,18 @@ service Spanner {
6666 };
6767 }
6868
69+ // Creates multiple new sessions.
70+ //
71+ // This API can be used to initialize a session cache on the clients.
72+ // See https://goo.gl/TgSFN2 for best practices on session cache management.
73+ rpc BatchCreateSessions (BatchCreateSessionsRequest )
74+ returns (BatchCreateSessionsResponse ) {
75+ option (google.api.http ) = {
76+ post : "/v1/{database=projects/*/instances/*/databases/*}/sessions:batchCreate"
77+ body : "*"
78+ };
79+ }
80+
6981 // Gets a session. Returns `NOT_FOUND` if the session does not exist.
7082 // This is mainly useful for determining whether a session is still
7183 // alive.
@@ -129,8 +141,9 @@ service Spanner {
129141 //
130142 // Statements are executed in order, sequentially.
131143 // [ExecuteBatchDmlResponse][Spanner.ExecuteBatchDmlResponse] will contain a
132- // [ResultSet][google.spanner.v1.ResultSet] for each DML statement that has successfully executed. If a
133- // statement fails, its error status will be returned as part of the
144+ // [ResultSet][google.spanner.v1.ResultSet] for each DML statement that has
145+ // successfully executed. If a statement fails, its error status will be
146+ // returned as part of the
134147 // [ExecuteBatchDmlResponse][Spanner.ExecuteBatchDmlResponse]. Execution will
135148 // stop at the first failed statement; the remaining statements will not run.
136149 //
@@ -142,7 +155,8 @@ service Spanner {
142155 // See more details in
143156 // [ExecuteBatchDmlRequest][Spanner.ExecuteBatchDmlRequest] and
144157 // [ExecuteBatchDmlResponse][Spanner.ExecuteBatchDmlResponse].
145- rpc ExecuteBatchDml (ExecuteBatchDmlRequest ) returns (ExecuteBatchDmlResponse ) {
158+ rpc ExecuteBatchDml (ExecuteBatchDmlRequest )
159+ returns (ExecuteBatchDmlResponse ) {
146160 option (google.api.http ) = {
147161 post : "/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeBatchDml"
148162 body : "*"
@@ -275,6 +289,31 @@ message CreateSessionRequest {
275289 Session session = 2 ;
276290}
277291
292+ // The request for
293+ // [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
294+ message BatchCreateSessionsRequest {
295+ // Required. The database in which the new sessions are created.
296+ string database = 1 ;
297+
298+ // Parameters to be applied to each created session.
299+ Session session_template = 2 ;
300+
301+ // Required. The number of sessions to be created in this batch call.
302+ // The API may return fewer than the requested number of sessions. If a
303+ // specific number of sessions are desired, the client can make additional
304+ // calls to BatchCreateSessions (adjusting
305+ // [session_count][google.spanner.v1.BatchCreateSessionsRequest.session_count]
306+ // as necessary).
307+ int32 session_count = 3 ;
308+ }
309+
310+ // The response for
311+ // [BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
312+ message BatchCreateSessionsResponse {
313+ // The freshly created sessions.
314+ repeated Session session = 1 ;
315+ }
316+
278317// A session in the Cloud Spanner API.
279318message Session {
280319 // The name of the session. This is always system-assigned; values provided
@@ -371,9 +410,6 @@ message ExecuteSqlRequest {
371410 // Required. The session in which the SQL query should be performed.
372411 string session = 1 ;
373412
374- // The transaction to use. If none is provided, the default is a
375- // temporary read-only transaction with strong concurrency.
376- //
377413 // The transaction to use.
378414 //
379415 // For queries, if none is provided, the default is a temporary read-only
@@ -476,7 +512,9 @@ message ExecuteBatchDmlRequest {
476512
477513 // It is not always possible for Cloud Spanner to infer the right SQL type
478514 // from a JSON value. For example, values of type `BYTES` and values
479- // of type `STRING` both appear in [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as JSON strings.
515+ // of type `STRING` both appear in
516+ // [params][google.spanner.v1.ExecuteBatchDmlRequest.Statement.params] as
517+ // JSON strings.
480518 //
481519 // In these cases, `param_types` can be used to specify the exact
482520 // SQL type for some or all of the SQL statement parameters. See the
@@ -508,11 +546,13 @@ message ExecuteBatchDmlRequest {
508546 int64 seqno = 4 ;
509547}
510548
511- // The response for [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list
512- // of [ResultSet][google.spanner.v1.ResultSet], one for each DML statement that has successfully executed.
513- // If a statement fails, the error is returned as part of the response payload.
514- // Clients can determine whether all DML statements have run successfully, or if
515- // a statement failed, using one of the following approaches:
549+ // The response for
550+ // [ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml]. Contains a list
551+ // of [ResultSet][google.spanner.v1.ResultSet], one for each DML statement that
552+ // has successfully executed. If a statement fails, the error is returned as
553+ // part of the response payload. Clients can determine whether all DML
554+ // statements have run successfully, or if a statement failed, using one of the
555+ // following approaches:
516556//
517557// 1. Check if 'status' field is OkStatus.
518558// 2. Check if result_sets_size() equals the number of statements in
@@ -529,9 +569,11 @@ message ExecuteBatchDmlRequest {
529569// result_set_size() client can determine that the 3rd statement has failed.
530570message ExecuteBatchDmlResponse {
531571 // ResultSets, one for each statement in the request that ran successfully, in
532- // the same order as the statements in the request. Each [ResultSet][google.spanner.v1.ResultSet] will
533- // not contain any rows. The [ResultSetStats][google.spanner.v1.ResultSetStats] in each [ResultSet][google.spanner.v1.ResultSet] will
534- // contain the number of rows modified by the statement.
572+ // the same order as the statements in the request. Each
573+ // [ResultSet][google.spanner.v1.ResultSet] will not contain any rows. The
574+ // [ResultSetStats][google.spanner.v1.ResultSetStats] in each
575+ // [ResultSet][google.spanner.v1.ResultSet] will contain the number of rows
576+ // modified by the statement.
535577 //
536578 // Only the first ResultSet in the response contains a valid
537579 // [ResultSetMetadata][google.spanner.v1.ResultSetMetadata].
0 commit comments