{"id":13694573,"url":"https://github.com/neurodrone/crdt","last_synced_at":"2026-01-22T14:56:35.392Z","repository":{"id":35504134,"uuid":"39774009","full_name":"neurodrone/crdt","owner":"neurodrone","description":"A Golang implementation of CRDTs.","archived":false,"fork":false,"pushed_at":"2018-02-24T10:19:07.000Z","size":19,"stargazers_count":282,"open_issues_count":7,"forks_count":30,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-14T12:37:34.672Z","etag":null,"topics":["crdt","data-structures","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neurodrone.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-27T12:47:48.000Z","updated_at":"2025-08-08T13:47:19.000Z","dependencies_parsed_at":"2022-08-08T09:00:47.473Z","dependency_job_id":null,"html_url":"https://github.com/neurodrone/crdt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/neurodrone/crdt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neurodrone%2Fcrdt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neurodrone%2Fcrdt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neurodrone%2Fcrdt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neurodrone%2Fcrdt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neurodrone","download_url":"https://codeload.github.com/neurodrone/crdt/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neurodrone%2Fcrdt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28664773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-22T14:01:31.714Z","status":"ssl_error","status_checked_at":"2026-01-22T13:59:23.143Z","response_time":144,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["crdt","data-structures","golang"],"created_at":"2024-08-02T17:01:35.022Z","updated_at":"2026-01-22T14:56:35.369Z","avatar_url":"https://github.com/neurodrone.png","language":"Go","funding_links":[],"categories":["开源类库","Open source library"],"sub_categories":["未归类","Not Categorized"],"readme":"# CRDT [![Build Status](https://travis-ci.org/neurodrone/crdt.svg?branch=master)](https://travis-ci.org/neurodrone/crdt) [![Coverage Status](https://coveralls.io/repos/neurodrone/crdt/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/neurodrone/crdt?branch=master) [![GoDoc](https://godoc.org/github.com/neurodrone/crdt?status.svg)](https://godoc.org/github.com/neurodrone/crdt) [![](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/neurodrone/crdt/blob/master/LICENSE) [![Report card](http://goreportcard.com/badge/neurodrone/crdt)](http://goreportcard.com/report/neurodrone/crdt)\n\nThis is an implementation of [Convergent and Commutative Replicated Data Types](https://hal.inria.fr/inria-00555588/document) in [Go](https://golang.org/).\n\nThe following state-based counters and sets have currently been\nimplemented.\n\n## Counters\n\n### G-Counter\n\nA grow-only counter (G-Counter) can only increase in one direction. The increment\noperation increases the value of current replica by 1. The merge\noperation combines values from distinct replicas by taking the maximum\nof each replica.\n\n```go\ngcounter := crdt.NewGCounter()\n\n// We can increase the counter monotonically by 1.\ngcounter.Inc()\n\n// Twice.\ngcounter.Inc()\n\n// Or we can pass in an arbitrary delta to apply as an increment.\ngcounter.IncVal(2)\n\n// Should print '4' as the result.\nfmt.Println(gcounter.Count())\n```\n\n### PN-Counter\n\nA positive-negative counter (PN-Counter) is a CRDT that can both increase or\ndecrease and converge correctly in the light of commutative\noperations. Both `.Inc()` and `.Dec()` operations are allowed and thus\nnegative values are possible as a result.\n\n```go\npncounter := crdt.NewPNCounter()\n\n// We can increase the counter by 1.\npncounter.Inc()\n\n// Or more.\npncounter.Inc(100)\n\n// And similarly decrease its value by 1.\npncounter.Dec()\n\n// Or more.\npncounter.DecVal(100)\n\n// End result should equal '0' here.\nfmt.Println(pncounter.Count())\n```\n\n## Sets\n\n### G-Set\n\nA grow-only (G-Set) set to which element/s can be added to. Removing element\nfrom the set is not possible.\n\n```go\nobj := \"dummy-object\"\ngset := crdt.NewGSet()\n\ngset.Add(obj)\n\n// Should always print 'true' as `obj` exists in the g-set.\nfmt.Println(gset.Contains(obj))\n```\n\n### 2P-Set\n\nTwo-phase set (2P-Set) allows both additions and removals to the set.\nInternally it comprises of two G-Sets, one to keep track of additions\nand the other for removals.\n\n```go\nobj := \"dummy-object\"\n\nppset := crdt.NewTwoPhaseSet()\n\nppset.Add(obj)\n\n// Remove the object that we just added to the set, emptying it.\nppset.Remove(obj)\n\n// Should return 'false' as the obj doesn't exist within the set.\nfmt.Println(ppset.Contains(obj))\n```\n\n### LWW-e-Set\n\nLast-write-wins element set (LWW-e-Set) keeps track of element additions\nand removals but with respect to the timestamp that is attached to each\nelement. Timestamps should be unique and have ordering properties.\n\n```go\nobj := \"dummy-object\"\nlwwset := crdt.NewLWWSet()\n\n// Here, we remove the object first before we add it in. For a\n// 2P-set the object would be deemed absent from the set. But for\n// a LWW-set the object should be present because `.Add()` follows\n// `.Remove()`.\nlwwset.Remove(obj); lwwset.Add(obj)\n\n// This should print 'true' because of the above.\nfmt.Println(lwwset.Contains(obj))\n```\n\n### OR-Set\n\nAn OR-Set (Observed-Removed-Set) allows deletion and addition of\nelements similar to LWW-e-Set, but does not surface only the most recent one. Additions are uniquely tracked via tags and an element is considered member of the set if the deleted set consists of all the tags present within additions.\n\n```go\n// object 1 == object 2\nobj1, obj2 := \"dummy-object\", \"dummy-object\"\n\norset := crdt.NewORSet()\n\norset.Add(obj1); orset.Add(obj2)\n\n// Removing any one of the above two objects should remove both\n// because they contain the same value.\norset.Remove(obj1)\n\n// Should return 'false'.\nfmt.Println(orset.Contains(obj2))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneurodrone%2Fcrdt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneurodrone%2Fcrdt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneurodrone%2Fcrdt/lists"}