Go to file
Sarah Jamie Lewis 02f1ee0508 Examples and Updates 2020-03-01 18:15:43 -08:00
cmd/chaos Examples and Updates 2020-03-01 18:15:43 -08:00
.gitignore Examples and Updates 2020-03-01 18:15:43 -08:00
2pset.cst Templates 2020-03-01 17:36:12 -08:00
2pset.go initial 2020-03-01 16:28:04 -08:00
2pset_test.go initial 2020-03-01 16:28:04 -08:00
4count.cst Examples and Updates 2020-03-01 18:15:43 -08:00
README.md Examples and Updates 2020-03-01 18:15:43 -08:00
gset.cst Templates 2020-03-01 17:36:12 -08:00
gset.go Examples and Updates 2020-03-01 18:15:43 -08:00
gset_test.go initial 2020-03-01 16:28:04 -08:00
max.sh Examples and Updates 2020-03-01 18:15:43 -08:00
template.go Examples and Updates 2020-03-01 18:15:43 -08:00
template_test.go Templates 2020-03-01 17:36:12 -08:00

README.md

Chaos - Distributed Structures

Chaos is a framework for building distributed conflict-free data structures by composing G-Sets (Grow Only Sets)

From these simple sets, more complicated objects can be made e.g. we can build a 2-Phase Set that allows us to remove elements with a simple template (2pset.cst)

{
    "Structures":{
        "add":{"Elements":{}},
        "remove":{"Elements":{}}
    },
    "Commands":{
        "add":["add"],"remove":["remove"]
    },
    "LookupIn":["add"],
    "LookupNotIn":["remove"]
}

We can also build distributed counters, e.g. a counter to synchronize 4 nodes might look like this (4count.cst:

{
    "Structures":{
        "1":{"Elements":{}},
        "2":{"Elements":{}},
        "3":{"Elements":{}},
        "4":{"Elements":{}}
    },
    "Commands":{
        "add1":["1"],
        "add2":["2"],
        "add3":["3"],
        "add4":["4"]
    },
    "LookupIn": ["1","2","3","4"],
    "LookupNotIn":[]
 }

We can then use chaos:

chaos new 4count counter
# Receive from 1
chaos add1 counter 1
# Receive from 2
chaos add2 counter 1
# Receive from 3
chaos add3 counter 1
# Receive from 4
chaos add4 counter 1
# Get Max Counter Value
seq 4 | xargs -I{} chaos len counter | sort -nr | head -1
1 
# Receive from 4
chaos add4 counter "in reality this would be update event 2"
# Get Max Counter Value
seq 4 | xargs -I{} chaos len counter | sort -nr | head -1
2