You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Sarah Jamie Lewis 02f1ee0508 Examples and Updates 5 months ago
cmd/chaos Examples and Updates 5 months ago
.gitignore Examples and Updates 5 months ago
2pset.cst Templates 5 months ago
2pset.go initial 5 months ago
2pset_test.go initial 5 months ago
4count.cst Examples and Updates 5 months ago
README.md Examples and Updates 5 months ago
gset.cst Templates 5 months ago
gset.go Examples and Updates 5 months ago
gset_test.go initial 5 months ago
max.sh Examples and Updates 5 months ago
template.go Examples and Updates 5 months ago
template_test.go Templates 5 months ago

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