You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

291 lines
5.5 KiB

  1. // Copyright 2018 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // AUTO-GENERATED CODE. DO NOT EDIT.
  15. package spanner_test
  16. import (
  17. "io"
  18. "cloud.google.com/go/spanner/apiv1"
  19. "golang.org/x/net/context"
  20. "google.golang.org/api/iterator"
  21. spannerpb "google.golang.org/genproto/googleapis/spanner/v1"
  22. )
  23. func ExampleNewClient() {
  24. ctx := context.Background()
  25. c, err := spanner.NewClient(ctx)
  26. if err != nil {
  27. // TODO: Handle error.
  28. }
  29. // TODO: Use client.
  30. _ = c
  31. }
  32. func ExampleClient_CreateSession() {
  33. ctx := context.Background()
  34. c, err := spanner.NewClient(ctx)
  35. if err != nil {
  36. // TODO: Handle error.
  37. }
  38. req := &spannerpb.CreateSessionRequest{
  39. // TODO: Fill request struct fields.
  40. }
  41. resp, err := c.CreateSession(ctx, req)
  42. if err != nil {
  43. // TODO: Handle error.
  44. }
  45. // TODO: Use resp.
  46. _ = resp
  47. }
  48. func ExampleClient_GetSession() {
  49. ctx := context.Background()
  50. c, err := spanner.NewClient(ctx)
  51. if err != nil {
  52. // TODO: Handle error.
  53. }
  54. req := &spannerpb.GetSessionRequest{
  55. // TODO: Fill request struct fields.
  56. }
  57. resp, err := c.GetSession(ctx, req)
  58. if err != nil {
  59. // TODO: Handle error.
  60. }
  61. // TODO: Use resp.
  62. _ = resp
  63. }
  64. func ExampleClient_ListSessions() {
  65. ctx := context.Background()
  66. c, err := spanner.NewClient(ctx)
  67. if err != nil {
  68. // TODO: Handle error.
  69. }
  70. req := &spannerpb.ListSessionsRequest{
  71. // TODO: Fill request struct fields.
  72. }
  73. it := c.ListSessions(ctx, req)
  74. for {
  75. resp, err := it.Next()
  76. if err == iterator.Done {
  77. break
  78. }
  79. if err != nil {
  80. // TODO: Handle error.
  81. }
  82. // TODO: Use resp.
  83. _ = resp
  84. }
  85. }
  86. func ExampleClient_DeleteSession() {
  87. ctx := context.Background()
  88. c, err := spanner.NewClient(ctx)
  89. if err != nil {
  90. // TODO: Handle error.
  91. }
  92. req := &spannerpb.DeleteSessionRequest{
  93. // TODO: Fill request struct fields.
  94. }
  95. err = c.DeleteSession(ctx, req)
  96. if err != nil {
  97. // TODO: Handle error.
  98. }
  99. }
  100. func ExampleClient_ExecuteSql() {
  101. ctx := context.Background()
  102. c, err := spanner.NewClient(ctx)
  103. if err != nil {
  104. // TODO: Handle error.
  105. }
  106. req := &spannerpb.ExecuteSqlRequest{
  107. // TODO: Fill request struct fields.
  108. }
  109. resp, err := c.ExecuteSql(ctx, req)
  110. if err != nil {
  111. // TODO: Handle error.
  112. }
  113. // TODO: Use resp.
  114. _ = resp
  115. }
  116. func ExampleClient_ExecuteStreamingSql() {
  117. ctx := context.Background()
  118. c, err := spanner.NewClient(ctx)
  119. if err != nil {
  120. // TODO: Handle error.
  121. }
  122. req := &spannerpb.ExecuteSqlRequest{
  123. // TODO: Fill request struct fields.
  124. }
  125. stream, err := c.ExecuteStreamingSql(ctx, req)
  126. if err != nil {
  127. // TODO: Handle error.
  128. }
  129. for {
  130. resp, err := stream.Recv()
  131. if err == io.EOF {
  132. break
  133. }
  134. if err != nil {
  135. // TODO: handle error.
  136. }
  137. // TODO: Use resp.
  138. _ = resp
  139. }
  140. }
  141. func ExampleClient_Read() {
  142. ctx := context.Background()
  143. c, err := spanner.NewClient(ctx)
  144. if err != nil {
  145. // TODO: Handle error.
  146. }
  147. req := &spannerpb.ReadRequest{
  148. // TODO: Fill request struct fields.
  149. }
  150. resp, err := c.Read(ctx, req)
  151. if err != nil {
  152. // TODO: Handle error.
  153. }
  154. // TODO: Use resp.
  155. _ = resp
  156. }
  157. func ExampleClient_StreamingRead() {
  158. ctx := context.Background()
  159. c, err := spanner.NewClient(ctx)
  160. if err != nil {
  161. // TODO: Handle error.
  162. }
  163. req := &spannerpb.ReadRequest{
  164. // TODO: Fill request struct fields.
  165. }
  166. stream, err := c.StreamingRead(ctx, req)
  167. if err != nil {
  168. // TODO: Handle error.
  169. }
  170. for {
  171. resp, err := stream.Recv()
  172. if err == io.EOF {
  173. break
  174. }
  175. if err != nil {
  176. // TODO: handle error.
  177. }
  178. // TODO: Use resp.
  179. _ = resp
  180. }
  181. }
  182. func ExampleClient_BeginTransaction() {
  183. ctx := context.Background()
  184. c, err := spanner.NewClient(ctx)
  185. if err != nil {
  186. // TODO: Handle error.
  187. }
  188. req := &spannerpb.BeginTransactionRequest{
  189. // TODO: Fill request struct fields.
  190. }
  191. resp, err := c.BeginTransaction(ctx, req)
  192. if err != nil {
  193. // TODO: Handle error.
  194. }
  195. // TODO: Use resp.
  196. _ = resp
  197. }
  198. func ExampleClient_Commit() {
  199. ctx := context.Background()
  200. c, err := spanner.NewClient(ctx)
  201. if err != nil {
  202. // TODO: Handle error.
  203. }
  204. req := &spannerpb.CommitRequest{
  205. // TODO: Fill request struct fields.
  206. }
  207. resp, err := c.Commit(ctx, req)
  208. if err != nil {
  209. // TODO: Handle error.
  210. }
  211. // TODO: Use resp.
  212. _ = resp
  213. }
  214. func ExampleClient_Rollback() {
  215. ctx := context.Background()
  216. c, err := spanner.NewClient(ctx)
  217. if err != nil {
  218. // TODO: Handle error.
  219. }
  220. req := &spannerpb.RollbackRequest{
  221. // TODO: Fill request struct fields.
  222. }
  223. err = c.Rollback(ctx, req)
  224. if err != nil {
  225. // TODO: Handle error.
  226. }
  227. }
  228. func ExampleClient_PartitionQuery() {
  229. ctx := context.Background()
  230. c, err := spanner.NewClient(ctx)
  231. if err != nil {
  232. // TODO: Handle error.
  233. }
  234. req := &spannerpb.PartitionQueryRequest{
  235. // TODO: Fill request struct fields.
  236. }
  237. resp, err := c.PartitionQuery(ctx, req)
  238. if err != nil {
  239. // TODO: Handle error.
  240. }
  241. // TODO: Use resp.
  242. _ = resp
  243. }
  244. func ExampleClient_PartitionRead() {
  245. ctx := context.Background()
  246. c, err := spanner.NewClient(ctx)
  247. if err != nil {
  248. // TODO: Handle error.
  249. }
  250. req := &spannerpb.PartitionReadRequest{
  251. // TODO: Fill request struct fields.
  252. }
  253. resp, err := c.PartitionRead(ctx, req)
  254. if err != nil {
  255. // TODO: Handle error.
  256. }
  257. // TODO: Use resp.
  258. _ = resp
  259. }