Closed blowmage closed 5 years ago
@jbolinger +1, instance methods will help unblock sample code for Ruby.
Here are some options for the code in the issue description:
First, the existing helper method can be called by calling .class
on the client object. This would require no changes and works today.
require "google/cloud/spanner/v1"
spanner_client = Google::Cloud::Spanner::V1.new
session = spanner_client.class.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
sql = "SELECT * FROM users"
response = spanner_client.execute_sql(session, sql)
Another option is to add session_path
as an instance method on the SpannerClient class.
require "google/cloud/spanner/v1"
spanner_client = Google::Cloud::Spanner::V1.new
session = spanner_client.session_path("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]")
sql = "SELECT * FROM users"
response = spanner_client.execute_sql(session, sql)
As discussed in #119, the GAPIC client helper methods are inconvenient and are being avoided in code examples. They could be better.
Take this Spanner GAPIC client example, the longest line is calling the
session_path
code example: