Skip to content

Instantly share code, notes, and snippets.

@drewkerrigan
Last active December 31, 2015 00:09
Show Gist options
  • Save drewkerrigan/7905509 to your computer and use it in GitHub Desktop.
Save drewkerrigan/7905509 to your computer and use it in GitHub Desktop.
Actor based counter example values
1) Actor 1 writes transaction
_key_____________|_value________________________________________________________
player1_balance | {actor1: {operations: [{txnid: 1, value: +10}]}}
2) Actor 2 writes transaction
_key_____________|_value________________________________________________________
player1_balance | sibling1 -> {actor1: {operations: [{txnid: 1, value: +10}]}}
sibling2 -> {actor2: {operations: [{txnid: 2, value: +20}]}}
3) Actor 1 writes a transaction
_key_____________|_value________________________________________________________
player1_balance | sibling1 -> {actor1: {operations: [{txnid: 1, value: +10}]}}
sibling2 -> {actor2: {operations: [{txnid: 2, value: +20}]}}
sibling3 -> {actor1: {operations: [{txnid: 3, value: -5 }]}}
4) Actor 2 reads player1_balance
a) receives 3 siblings
b) determines value is +10, +20, -5 = 25
c) determines Actor 2's base_value is now 20, removes Actor 2's operation list
d) merge all siblings into single list of actors and write back result as new truth
_key_____________|_value________________________________________________________
player1_balance | {
actor1: {operations: [{txnid: 1, value: +10}, {txnid: 3, value: -5 }]}}
actor2: {base_value: 20, operations: []}}
}
5) Actor 1 writes a transaction
_key_____________|_value________________________________________________________
player1_balance | sibling1 -> {
actor1: {operations: [{txnid: 1, value: +10}, {txnid: 3, value: -5 }]}}
actor2: {base_value: 20, operations: []}}
}
sibling2 -> {
actor1: {operations: [{txnid: 4, value: +30}]}
}
6) Actor 1 reads player1_balance
a) receives 2 siblings
b) determines value is base_value 20, +10, -5, +30 = 55
c) determines Actor 1's base_value is now 35, removes Actor 1's operation list
d) merge all siblings into single list of actors and write back result as new truth
_key_____________|_value________________________________________________________
player1_balance | {
actor1: {base_value: 35, operations: []}}
actor2: {base_value: 20, operations: []}}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment