Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Google Cloud Storage distributed locking for Ruby

NotificationsYou must be signed in to change notification settings

xaf/gcslock-ruby

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is inspired bythe Golang version.

Google Cloud Storage setup

  1. Setup a new project at theGoogle APIs Console and enable the Cloud Storage API.
  2. Install theGoogle Cloud SDK tool and configure your project and your OAuth credentials.
  3. Create a bucket in which to store your lock file using the commandgsutil mb gs://your-bucket-name.
  4. Enable object versioning in your bucket using the commandgsutil versioning set on gs://your-bucket-name.

Using a mutex

In your Ruby code, requiregcslock/mutex and use it as follows:

require'gcslock/mutex'm=GCSLock::Mutex.new('your-bucket-name','my-file.lock')m.synchronizedo# Protected and globally serialized computation happens here.end

Using a semaphore

In your Ruby code, requiregcslock/semaphore and use it as follows:

require'gcslock/semaphore'number_of_permits=10s=GCSLock::Semaphore.new('your-bucket-name','my-file.lock',number_of_permits)s.acquire# Work that should be done when semaphore is acquireds.release

About

Google Cloud Storage distributed locking for Ruby

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp