riak-ruby-ledger 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- #it "must merge a two actors" do
109
- # @ledger1.debit!("txn1", 10)
110
- # @ledger1.credit!("txn2", 10)
111
- # @ledger1.credit!("txn3", 10)
112
- # @ledger1.credit!("txn4", 10)
113
- # @ledger1.credit!("txn5", 10)
114
- # @ledger2.debit!("txn6", 10)
115
- # @ledger2.credit!("txn7", 10)
116
- # @ledger2.credit!("txn8", 10)
117
- # @ledger2.credit!("txn9", 10)
118
- # @ledger2.credit!("txn10", 10)
119
- #
120
- # @ledger1.credit!("txn11", 10)
121
- # @ledger1.credit!("txn11", 10)
122
- # @ledger2.credit!("txn11", 10)
123
- # @ledger2.credit!("txn11", 10)
124
- #
125
- # assert_equal 110, @ledger1.value
126
- # #1st 6 transactions were merged into total
127
- # assert_equal 60, @ledger1.counter.p.counts["ACTOR1"]["total"]
128
- #
129
- # refute @ledger1.has_transaction? "txn1"
130
- # refute @ledger1.has_transaction? "txn2"
131
- # refute @ledger1.has_transaction? "txn3"
132
- # refute @ledger1.has_transaction? "txn4"
133
- # refute @ledger1.has_transaction? "txn5"
134
- # refute @ledger1.has_transaction? "txn6"
135
- # assert @ledger1.has_transaction? "txn7"
136
- # assert @ledger1.has_transaction? "txn8"
137
- # assert @ledger1.has_transaction? "txn9"
138
- # assert @ledger1.has_transaction? "txn10"
139
- # assert @ledger1.has_transaction? "txn11"
140
- #end
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
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-19 00:00:00.000000000 Z
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: A PNCounter CRDT based ledger with support for transaction ids and tunable
70
- write idempotence
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: This gem attempts to provide a tunable Counter option by combining non-idempotent
116
- GCounters and a partially idempotent GSet for calculating a running counter or ledger.
117
- By allowing clients to set how many transactions to keep in the counter object as
118
- well as set a retry policy on the Riak actions performed on the counter, a good
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