Module: Google::Cloud::Spanner
- Defined in:
- lib/google/cloud/spanner.rb,
lib/google/cloud/spanner/data.rb,
lib/google/cloud/spanner/pool.rb,
lib/google/cloud/spanner/range.rb,
lib/google/cloud/spanner/backup.rb,
lib/google/cloud/spanner/client.rb,
lib/google/cloud/spanner/commit.rb,
lib/google/cloud/spanner/errors.rb,
lib/google/cloud/spanner/fields.rb,
lib/google/cloud/spanner/policy.rb,
lib/google/cloud/spanner/status.rb,
lib/google/cloud/spanner/convert.rb,
lib/google/cloud/spanner/project.rb,
lib/google/cloud/spanner/results.rb,
lib/google/cloud/spanner/service.rb,
lib/google/cloud/spanner/session.rb,
lib/google/cloud/spanner/version.rb,
lib/google/cloud/spanner/database.rb,
lib/google/cloud/spanner/instance.rb,
lib/google/cloud/spanner/snapshot.rb,
lib/google/cloud/spanner/partition.rb,
lib/google/cloud/spanner/backup/job.rb,
lib/google/cloud/spanner/backup/list.rb,
lib/google/cloud/spanner/batch_write.rb,
lib/google/cloud/spanner/credentials.rb,
lib/google/cloud/spanner/lar_headers.rb,
lib/google/cloud/spanner/transaction.rb,
lib/google/cloud/spanner/batch_client.rb,
lib/google/cloud/spanner/batch_update.rb,
lib/google/cloud/spanner/column_value.rb,
lib/google/cloud/spanner/database/job.rb,
lib/google/cloud/spanner/instance/job.rb,
lib/google/cloud/spanner/database/list.rb,
lib/google/cloud/spanner/instance/list.rb,
lib/google/cloud/spanner/admin/database.rb,
lib/google/cloud/spanner/admin/instance.rb,
lib/google/cloud/spanner/batch_snapshot.rb,
lib/google/cloud/spanner/mutation_group.rb,
lib/google/cloud/spanner/backup/job/list.rb,
lib/google/cloud/spanner/commit_response.rb,
lib/google/cloud/spanner/instance/config.rb,
lib/google/cloud/spanner/database/job/list.rb,
lib/google/cloud/spanner/backup/restore/job.rb,
lib/google/cloud/spanner/batch_write_results.rb,
lib/google/cloud/spanner/batch_update_results.rb,
lib/google/cloud/spanner/database/backup_info.rb,
lib/google/cloud/spanner/instance/config/list.rb,
lib/google/cloud/spanner/database/restore_info.rb,
lib/google/cloud/spanner/admin/database/credentials.rb,
lib/google/cloud/spanner/admin/instance/credentials.rb,
lib/google/cloud/spanner/commit_response/commit_stats.rb
Overview
Cloud Spanner
Cloud Spanner is a fully managed, mission-critical, relational database service that offers transactional consistency at global scale, schemas, SQL (ANSI 2011 with extensions), and automatic, synchronous replication for high availability.
For more information about Cloud Spanner, read the Cloud Spanner Documentation.
See Spanner Overview.
Defined Under Namespace
Modules: Admin Classes: Backup, BatchClient, BatchSnapshot, BatchUpdate, BatchUpdateError, BatchWrite, BatchWriteResults, Client, ClientClosedError, ColumnValue, Commit, CommitResponse, Credentials, Data, Database, DuplicateNameError, Fields, Instance, MutationGroup, Partition, Policy, Project, Range, Results, Rollback, SessionLimitError, Snapshot, Status, Transaction
Constant Summary collapse
- VERSION =
"2.24.0".freeze
Class Method Summary collapse
-
.configure {|Google::Cloud.configure.spanner| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud Spanner library.
-
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil, emulator_host: nil, lib_name: nil, lib_version: nil, enable_leader_aware_routing: true) ⇒ Google::Cloud::Spanner::Project
Creates a new object for connecting to the Spanner service.
Class Method Details
.configure {|Google::Cloud.configure.spanner| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud Spanner library.
The following Spanner configuration parameters are supported:
project_id
- (String) Identifier for a Spanner project. (The parameterproject
is considered deprecated, but may also be used.)credentials
- (String, Hash, Google::Auth::Credentials) The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See Credentials) (The parameterkeyfile
is considered deprecated, but may also be used.)scope
- (String, Array) The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. quota_project
- (String) The project ID for a project that can be used by client libraries for quota and billing purposes.timeout
- (Integer) Default timeout to use in requests.endpoint
- (String) Override of the endpoint host name, ornil
to use the default endpoint.emulator_host
- (String) Host name of the emulator. Defaults toENV["SPANNER_EMULATOR_HOST"]
.lib_name
- (String) Override the lib name , ornil
to use the default lib name without prefix in agent tracking header.lib_version
- (String) Override the lib version , ornil
to use the default version lib name without prefix in agent tracking header.
167 168 169 170 171 |
# File 'lib/google/cloud/spanner.rb', line 167 def self.configure yield Google::Cloud.configure.spanner if block_given? Google::Cloud.configure.spanner end |
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil, emulator_host: nil, lib_name: nil, lib_version: nil, enable_leader_aware_routing: true) ⇒ Google::Cloud::Spanner::Project
Creates a new object for connecting to the Spanner service. Each call creates a new connection.
For more information on connecting to Google Cloud see the Authentication Guide.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/google/cloud/spanner.rb', line 95 def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, project: nil, keyfile: nil, emulator_host: nil, lib_name: nil, lib_version: nil, enable_leader_aware_routing: true project_id ||= project || default_project_id scope ||= configure.scope timeout ||= configure.timeout emulator_host = present_or_nil(emulator_host) || present_or_nil(configure.emulator_host) endpoint ||= emulator_host || configure.endpoint credentials ||= keyfile lib_name ||= configure.lib_name lib_version ||= configure.lib_version if emulator_host credentials = :this_channel_is_insecure else credentials ||= default_credentials scope: scope unless credentials.is_a? Google::Auth::Credentials credentials = Spanner::Credentials.new credentials, scope: scope end if credentials.respond_to? :project_id project_id ||= credentials.project_id end end project_id = project_id.to_s # Always cast to a string raise ArgumentError, "project_id is missing" if project_id.empty? Spanner::Project.new( Spanner::Service.new( project_id, credentials, quota_project: configure.quota_project, host: endpoint, timeout: timeout, lib_name: lib_name, lib_version: lib_version, enable_leader_aware_routing: enable_leader_aware_routing ), query_options: configure. ) end |