Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add support for Cloud Spanner Emulator #48

@aeroastro

Description

@aeroastro

I would like to use Cloud Spanner Emulator to develop this gem and to develop Rails application using gem. Although, there are limitations and differences, the emulator does not cost money 💸 and the separated environments are suited for local development.

https://cloud.google.com/spanner/docs/emulator

Then, I've found out that the current implementation of this library does not support emulator.
This is because Google::Cloud.spanner is used instead of Google::Cloud::Spanner.new. The former method pass the limited portion of parameters to the latter.

@spanners[database_path(config)] ||= Google::Cloud.spanner(
config[:project],
config[:credentials],
scope: config[:scope],
timeout: config[:timeout],
client_config: config[:client_config]&.symbolize_keys,
lib_name: "spanner-activerecord-adapter",
lib_version: ActiveRecordSpannerAdapter::VERSION
)

If we directly call Google::Cloud::Spanner.new(config), we can pass the emulator_host parameter in config, which enable developers to use Cloud Spanner Emulator.

https://github.com/googleapis/google-cloud-ruby/blob/06c73b3b4b09e5f4dded27b61662fe110fea57bb/google-cloud-spanner/lib/google/cloud/spanner.rb#L91-L101

Although, this breaks config[:project], config[:credentials] compatibility, I think keeping consistency with Google::Cloud::Spanner.new reduces maintenance cost.
Of course, If required, I can write backward-compatible code.

If the above strategy is O.K., I am willing to work on this issue.

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/ruby-spanner-activerecord API.priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions