{"id":16003527,"url":"https://github.com/yehohanan7/glock","last_synced_at":"2026-04-28T17:01:46.860Z","repository":{"id":145660644,"uuid":"109864515","full_name":"yehohanan7/glock","owner":"yehohanan7","description":"Optimistic lock using persistent stores","archived":false,"fork":false,"pushed_at":"2017-11-10T16:37:48.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-25T02:44:14.783Z","etag":null,"topics":["cassandra","consensus","optimistic-locking","optimisticlock"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yehohanan7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-11-07T16:52:05.000Z","updated_at":"2021-06-14T06:02:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"4fc7d449-21f6-4c26-a65e-68595dae6b79","html_url":"https://github.com/yehohanan7/glock","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yehohanan7/glock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yehohanan7%2Fglock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yehohanan7%2Fglock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yehohanan7%2Fglock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yehohanan7%2Fglock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yehohanan7","download_url":"https://codeload.github.com/yehohanan7/glock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yehohanan7%2Fglock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32390067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T14:34:11.604Z","status":"ssl_error","status_checked_at":"2026-04-28T14:32:37.009Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cassandra","consensus","optimistic-locking","optimisticlock"],"created_at":"2024-10-08T10:21:08.462Z","updated_at":"2026-04-28T17:01:46.840Z","avatar_url":"https://github.com/yehohanan7.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Glock [![Build Status](https://travis-ci.org/yehohanan7/glock.svg)](https://travis-ci.org/yehohanan7/glock?branch=master) [![Go Report Card](https://goreportcard.com/badge/github.com/yehohanan7/glock)](https://goreportcard.com/report/github.com/yehohanan7/glock)\n\n\n## Introduction\nGlock is used to achieve consensus between different hosts using a persistent stores.\n\n\n### Glock with Cassandra\nThe cassandra implementation is based on the article here: https://www.datastax.com/dev/blog/consensus-on-cassandra\n#### Setup\n```bash\nCREATE KEYSPACE test WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor': 1};\nCREATE TABLE test.lock (id text, owner text, PRIMARY KEY (id)) WITH default_time_to_live = 5;\n```\n#### Glock example\n```go\nimport (\n\t\"github.com/gocql/gocql\"\n\t\"github.com/yehohanan7/glock\"\n)\n\nsession := //initialize a cassandra session using gocql\n\nconfig := glock.Config{\n\t\"host1\",\n\ttime.NewTicker(2 * time.Second),\n\tglock.NewCassandraStore(session),\n\tnotifyCh,\n\tstopCh,\n}\n\ngo glock.Start(config)\n\nfor {\n\tselect {\n\tcase state := \u003c-notifyCh:\n\t\tif state == \"master\" {\n\t\t\tfmt.Println(\"became master\")\n\t\t}\n\t\tif state == \"slave\" {\n\t\t\tfmt.Println(\"became slave\")\n\t\t}\n\t}\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyehohanan7%2Fglock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyehohanan7%2Fglock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyehohanan7%2Fglock/lists"}