riak-ruby-ledger 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +75 -292
- data/docs/implementation.md +366 -0
- data/docs/release_notes.md +33 -0
- data/docs/riak_counter_drift.md +56 -0
- data/docs/usage.md +110 -0
- data/lib/crdt/tgcounter.rb +64 -18
- data/lib/ledger.rb +8 -8
- data/lib/ledger/version.rb +2 -2
- data/riak-ruby-ledger.gemspec +2 -2
- data/test/lib/{tgcounter_test.rb → crdt/tgcounter_test.rb} +1 -1
- data/test/lib/{tpncounter_test.rb → crdt/tpncounter_test.rb} +25 -24
- data/test/lib/ledger_test.rb +48 -34
- metadata +16 -13
data/test/lib/ledger_test.rb
CHANGED
@@ -104,39 +104,53 @@ describe Riak::Ledger do
|
|
104
104
|
assert @ledger1.has_transaction? "txn10"
|
105
105
|
assert @ledger1.has_transaction? "txn11"
|
106
106
|
end
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
107
|
+
|
108
|
+
it "must merge two actors" do
|
109
|
+
@ledger1.debit!("txn1", 10) #-10
|
110
|
+
@ledger1.credit!("txn2", 10) #0 p1
|
111
|
+
@ledger1.credit!("txn3", 10) #10 p2
|
112
|
+
@ledger1.credit!("txn4", 10) #20 p3
|
113
|
+
@ledger1.credit!("txn5", 10) #30 p4
|
114
|
+
@ledger2.debit!("txn6", 10) #20
|
115
|
+
@ledger2.credit!("txn7", 10) #30 p1
|
116
|
+
@ledger2.credit!("txn8", 10) #40 p2
|
117
|
+
@ledger2.credit!("txn9", 10) #50 p3
|
118
|
+
@ledger2.credit!("txn10", 10) #60 p4
|
119
|
+
|
120
|
+
@ledger1.credit!("txn11", 10) #70 p5
|
121
|
+
@ledger1.credit!("txn11", 10) #70 #ignore
|
122
|
+
@ledger2.credit!("txn11", 10) #70 #ignore
|
123
|
+
@ledger2.credit!("txn11", 10) #70 #ignore
|
124
|
+
|
125
|
+
@ledger2.credit!("txn12", 10) #80 p5
|
126
|
+
@ledger2.credit!("txn13", 10) #90 p6
|
127
|
+
@ledger2.credit!("txn14", 10) #100 p7
|
128
|
+
|
129
|
+
assert_equal 70, @ledger1.value #premerge
|
130
|
+
@ledger1 = Riak::Ledger.find!(@bucket, @key, options1)
|
131
|
+
assert_equal 100, @ledger1.value #postmerge
|
132
|
+
|
133
|
+
assert_equal 100, @ledger2.value
|
134
|
+
|
135
|
+
#1st 6 transactions were merged into total
|
136
|
+
assert_equal 10, @ledger2.counter.p.counts["ACTOR2"]["total"] #merged 1
|
137
|
+
@ledger2 = Riak::Ledger.find!(@bucket, @key, options2)
|
138
|
+
assert_equal 20, @ledger2.counter.p.counts["ACTOR2"]["total"] #merged 2
|
139
|
+
|
140
|
+
#pickup 2's merges
|
141
|
+
@ledger1 = Riak::Ledger.find!(@bucket, @key, options1)
|
142
|
+
|
143
|
+
assert_equal true, (@ledger1.has_transaction? "txn1")
|
144
|
+
assert_equal true, (@ledger1.has_transaction? "txn2")
|
145
|
+
assert_equal true, (@ledger1.has_transaction? "txn3")
|
146
|
+
assert_equal true, (@ledger1.has_transaction? "txn4")
|
147
|
+
assert_equal true, (@ledger1.has_transaction? "txn5")
|
148
|
+
assert_equal true, (@ledger1.has_transaction? "txn6")
|
149
|
+
assert_equal false, (@ledger1.has_transaction? "txn7")
|
150
|
+
assert_equal false, (@ledger1.has_transaction? "txn8")
|
151
|
+
assert_equal true, (@ledger1.has_transaction? "txn9")
|
152
|
+
assert_equal true, (@ledger1.has_transaction? "txn10")
|
153
|
+
assert_equal true, (@ledger1.has_transaction? "txn11")
|
154
|
+
end
|
141
155
|
|
142
156
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riak-ruby-ledger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- drewkerrigan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,8 +66,8 @@ dependencies:
|
|
66
66
|
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
70
|
-
|
69
|
+
description: An alternative to Riak Counters with idempotent writes within a client
|
70
|
+
defined window
|
71
71
|
email:
|
72
72
|
- dkerrigan@basho.com
|
73
73
|
executables: []
|
@@ -79,15 +79,19 @@ files:
|
|
79
79
|
- LICENSE
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
82
|
+
- docs/implementation.md
|
83
|
+
- docs/release_notes.md
|
84
|
+
- docs/riak_counter_drift.md
|
85
|
+
- docs/usage.md
|
82
86
|
- lib/crdt/tgcounter.rb
|
83
87
|
- lib/crdt/tpncounter.rb
|
84
88
|
- lib/ledger.rb
|
85
89
|
- lib/ledger/version.rb
|
86
90
|
- riak-ruby-ledger.gemspec
|
91
|
+
- test/lib/crdt/tgcounter_test.rb
|
92
|
+
- test/lib/crdt/tpncounter_test.rb
|
87
93
|
- test/lib/ledger/version_test.rb
|
88
94
|
- test/lib/ledger_test.rb
|
89
|
-
- test/lib/tgcounter_test.rb
|
90
|
-
- test/lib/tpncounter_test.rb
|
91
95
|
- test/test_helper.rb
|
92
96
|
homepage: https://github.com/drewkerrigan/riak-ruby-ledger
|
93
97
|
licenses:
|
@@ -112,14 +116,13 @@ rubyforge_project:
|
|
112
116
|
rubygems_version: 2.1.11
|
113
117
|
signing_key:
|
114
118
|
specification_version: 4
|
115
|
-
summary:
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
balance can be achieved.
|
119
|
+
summary: The data type implemented is a PNCounter CRDT with an ordered array of transactions
|
120
|
+
for each GCounter actor. Transaction ids are stored with the GCounter, so operations
|
121
|
+
against this counter are idempotent while the transaction remains in any actor's
|
122
|
+
array.
|
120
123
|
test_files:
|
124
|
+
- test/lib/crdt/tgcounter_test.rb
|
125
|
+
- test/lib/crdt/tpncounter_test.rb
|
121
126
|
- test/lib/ledger/version_test.rb
|
122
127
|
- test/lib/ledger_test.rb
|
123
|
-
- test/lib/tgcounter_test.rb
|
124
|
-
- test/lib/tpncounter_test.rb
|
125
128
|
- test/test_helper.rb
|