hq-engine 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/hq/engine/subprocess-rule-provider/self.rb +1 -1
- data/spec/hq/engine/transformer-spec.rb +2 -0
- metadata +1 -4
- data/lib/hq/engine/api-spec.rb +0 -111
- data/lib/hq/engine/api.rb +0 -44
- data/lib/hq/engine/mvcc.rb +0 -95
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hq-engine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -98,8 +98,6 @@ executables: []
|
|
98
98
|
extensions: []
|
99
99
|
extra_rdoc_files: []
|
100
100
|
files:
|
101
|
-
- lib/hq/engine/mvcc.rb
|
102
|
-
- lib/hq/engine/api-spec.rb
|
103
101
|
- lib/hq/engine/engine.rb
|
104
102
|
- lib/hq/engine/register-engine-commands.rb
|
105
103
|
- lib/hq/engine/subprocess-rule-provider/self.rb
|
@@ -108,7 +106,6 @@ files:
|
|
108
106
|
- lib/hq/engine/libxmlruby-mixin.rb
|
109
107
|
- lib/hq/engine/unlock-command.rb
|
110
108
|
- lib/hq/engine/transformer.rb
|
111
|
-
- lib/hq/engine/api.rb
|
112
109
|
- lib/hq/engine/rule-error.rb
|
113
110
|
- spec/hq/engine/transformer-spec.rb
|
114
111
|
homepage: https://github.com/jamespharaoh/hq-engine
|
data/lib/hq/engine/api-spec.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
require "hq/engine/api"
|
2
|
-
|
3
|
-
describe HQ::Engine::API do
|
4
|
-
|
5
|
-
let(:mvcc) { double :mvcc }
|
6
|
-
|
7
|
-
before do
|
8
|
-
subject.mvcc = mvcc
|
9
|
-
end
|
10
|
-
|
11
|
-
it "has a property named :mvcc" do
|
12
|
-
subject.mvcc = "some value"
|
13
|
-
subject.mvcc.should == "some value"
|
14
|
-
end
|
15
|
-
|
16
|
-
context "#transaction_begin" do
|
17
|
-
|
18
|
-
it "calls mvcc.transaction_begin" do
|
19
|
-
|
20
|
-
mvcc.should_receive(:transaction_begin)
|
21
|
-
|
22
|
-
subject.transaction_begin
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
it "returns the transaction id" do
|
27
|
-
|
28
|
-
mvcc.stub(:transaction_begin)
|
29
|
-
.and_return("transaction id")
|
30
|
-
|
31
|
-
subject.transaction_begin.should ==
|
32
|
-
"transaction id"
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
context "#transaction_commit" do
|
39
|
-
|
40
|
-
it "calls mvcc.transaction_commit" do
|
41
|
-
|
42
|
-
mvcc.should_receive(:transaction_commit)
|
43
|
-
.with("transaction id")
|
44
|
-
|
45
|
-
subject.transaction_commit \
|
46
|
-
"transaction id"
|
47
|
-
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
context "#transaction_rollback" do
|
53
|
-
|
54
|
-
it "calls mvcc.transaction_rollback" do
|
55
|
-
|
56
|
-
mvcc.should_receive(:transaction_rollback)
|
57
|
-
.with("transaction id")
|
58
|
-
|
59
|
-
subject.transaction_rollback \
|
60
|
-
"transaction id"
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
|
-
context "#data_store" do
|
67
|
-
|
68
|
-
it "calls mvcc.data_store" do
|
69
|
-
|
70
|
-
mvcc.should_receive(:data_store)
|
71
|
-
.with(
|
72
|
-
"transaction id",
|
73
|
-
"record id",
|
74
|
-
"record value"
|
75
|
-
)
|
76
|
-
|
77
|
-
subject.data_store \
|
78
|
-
"transaction id",
|
79
|
-
"record id",
|
80
|
-
"record value"
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
context "#data_retrieve" do
|
87
|
-
|
88
|
-
it "calls mvcc.data_retrieve" do
|
89
|
-
|
90
|
-
mvcc.should_receive(:data_retrieve)
|
91
|
-
.with(
|
92
|
-
"transaction id",
|
93
|
-
"record id"
|
94
|
-
)
|
95
|
-
.and_return(
|
96
|
-
"record value"
|
97
|
-
)
|
98
|
-
|
99
|
-
record_value =
|
100
|
-
subject.data_retrieve \
|
101
|
-
"transaction id",
|
102
|
-
"record id"
|
103
|
-
|
104
|
-
record_value
|
105
|
-
.should == "record value"
|
106
|
-
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
data/lib/hq/engine/api.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
module HQ
|
2
|
-
module Engine
|
3
|
-
class API
|
4
|
-
|
5
|
-
attr_accessor :mvcc
|
6
|
-
|
7
|
-
def transaction_begin
|
8
|
-
mvcc.transaction_begin
|
9
|
-
end
|
10
|
-
|
11
|
-
def transaction_commit transaction_id
|
12
|
-
mvcc.transaction_commit transaction_id
|
13
|
-
end
|
14
|
-
|
15
|
-
def transaction_rollback transaction_id
|
16
|
-
mvcc.transaction_rollback transaction_id
|
17
|
-
end
|
18
|
-
|
19
|
-
def data_store \
|
20
|
-
transaction_id,
|
21
|
-
record_id,
|
22
|
-
record_value
|
23
|
-
|
24
|
-
mvcc.data_store \
|
25
|
-
transaction_id,
|
26
|
-
record_id,
|
27
|
-
record_value
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
def data_retrieve \
|
32
|
-
transaction_id,
|
33
|
-
record_id
|
34
|
-
|
35
|
-
return \
|
36
|
-
mvcc.data_retrieve \
|
37
|
-
transaction_id,
|
38
|
-
record_id
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
data/lib/hq/engine/mvcc.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
module HQ
|
2
|
-
module Engine
|
3
|
-
class MVCC
|
4
|
-
|
5
|
-
attr_accessor :transactions
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@transactions = {}
|
9
|
-
end
|
10
|
-
|
11
|
-
def generate_transaction_id
|
12
|
-
chars = (?a..?z).to_a
|
13
|
-
return (0...20).map { chars.sample }.join
|
14
|
-
end
|
15
|
-
-
|
16
|
-
def transaction_begin
|
17
|
-
|
18
|
-
tx_id =
|
19
|
-
generate_transaction_id
|
20
|
-
|
21
|
-
@transactions[tx_id] =
|
22
|
-
{
|
23
|
-
state: :begun,
|
24
|
-
changes: {},
|
25
|
-
}
|
26
|
-
|
27
|
-
return tx_id
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
def transaction_commit transaction_id
|
32
|
-
|
33
|
-
transaction =
|
34
|
-
@transactions[transaction_id]
|
35
|
-
|
36
|
-
transaction[:state] =
|
37
|
-
:committed
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
def transaction_rollback transaction_id
|
42
|
-
|
43
|
-
transaction =
|
44
|
-
@transactions[transaction_id]
|
45
|
-
|
46
|
-
transaction[:state] =
|
47
|
-
:rolled_back
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
def get_transaction_info transaction_id
|
52
|
-
|
53
|
-
transaction =
|
54
|
-
@transactions[transaction_id]
|
55
|
-
|
56
|
-
unless transaction
|
57
|
-
return nil
|
58
|
-
end
|
59
|
-
|
60
|
-
transaction_info = {
|
61
|
-
state: transaction[:state],
|
62
|
-
}
|
63
|
-
|
64
|
-
return transaction_info
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
def data_store \
|
69
|
-
transaction_id,
|
70
|
-
record_id,
|
71
|
-
record_value
|
72
|
-
|
73
|
-
transaction =
|
74
|
-
@transactions[transaction_id]
|
75
|
-
|
76
|
-
transaction[:changes][record_id] =
|
77
|
-
record_value
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
def data_retrieve \
|
82
|
-
transaction_id,
|
83
|
-
record_id
|
84
|
-
|
85
|
-
transaction =
|
86
|
-
@transactions[transaction_id]
|
87
|
-
|
88
|
-
return \
|
89
|
-
transaction[:changes][record_id]
|
90
|
-
|
91
|
-
end
|
92
|
-
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|