locked cloud

I previously designed a robust distributed locking algorithm based on Google Cloud. Now I’m releasing a Ruby implementation of this algorithm: distributed-lock-google-cloud-storage-ruby.

To use this, add to your Gemfile:

gem 'distributed-lock-google-cloud-storage'

Its typical usage is as follows. Initialize a Lock instance. It must be backed by a Google Cloud Storage bucket and object. Then do your work within a #synchronize block.

Important: If your work is a long-running operation, then also be sure to call #check_health! periodically to check whether the lock is still healthy. This call throws an exception if it’s not healthy. Learn more in Long-running operations, lock refreshing and lock health checking.

require 'distributed-lock-google-cloud-storage'

lock = DistributedLock::GoogleCloudStorage::Lock(
  bucket_name: 'your bucket name',
  path: 'locks/mywork')
lock.synchronize do
  do_some_work

  # IMPORTANT: _periodically_ call this!
  lock.check_health!

  do_more_work
end

To learn more about this gem, please check out its README and its full API docs.

Hongli is a software engineer & consultant that solves complex problems beyond tech.
January 26, 2023 | | 8 MINUTES

Kubernetes Autoscaling: Horizontal and Vertical explained

We can all think of a situation where an application became unresponsive due to insufficient resources for the load you’re currently receiving. A solution …

January 17, 2023 | BLOG | 6 MINUTES

Splitting CI from CD, but how?

In my last blog and video, I went through some of the issues you can have when having a single pipeline do both CI and CD for your applications. In this …

December 21, 2022 | | 5 MINUTES

DevOps: How to modernize and improve your meeting structures

A lot of teams have an ineffective team workstructure that is not beneficial to their needs or productivity. How do you modernize and improve your way of …