Building Microservices with Spring and Cloud Spanner

Image by GCP Podcast

Why choosing Spanner?

  • Consistency: Every read must return the most recent write .
  • Availability: Every read/write must have zero-error response.
  • Partition Tolerance: The system continues to operate despite delays or communication errors between nodes (network partitions).
Image by Author

Spanner Emulator

  1. Make sure Docker is installed.
  2. Get the latest emulator image.
$ docker pull gcr.io/cloud-spanner-emulator/emulator
$ docker run -d --name spanner-emulator -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator

Instances and Databases in Spanner

  1. Make sure to have gcloud CLI installed.
  2. Create and activate the emulator configuration.
$ gcloud config configurations create emulator
$ gcloud config set auth/disable_credentials true
$ gcloud config set project your-project-id
$ gcloud config set api_endpoint_overrides/spanner http://localhost:9020/
$ gcloud spanner instances create test-instance \
--description="Test Instance" --config=emulator-config --nodes=1
$ gcloud spanner databases create test-database \
--instance test-instance
$ gcloud spanner databases list --instance test-instance

Setting up the application

The Dependencies

The Migration Tool

The Datasource

The Model

Testing the Application

Summary

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jonathan Manera

Jonathan Manera

50 Followers

Software Engineer. Instructor. Trying to learn something new every day. Trying to teach what I wish I knew earlier.