pacer 0.9.1.1-java → 1.0.0-java
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.
- data/.autotest +4 -1
- data/.gitignore +4 -0
- data/.rspec +1 -1
- data/Gemfile-dev +33 -0
- data/Gemfile-release +4 -0
- data/README.md +27 -9
- data/Rakefile +26 -8
- data/bin/autotest +1 -1
- data/lib/pacer/blueprints/multi_graph.rb +7 -19
- data/lib/pacer/blueprints/ruby_graph.rb +77 -52
- data/lib/pacer/blueprints/tg.rb +6 -93
- data/lib/pacer/blueprints.rb +0 -1
- data/lib/pacer/core/graph/edges_route.rb +10 -12
- data/lib/pacer/core/graph/element_route.rb +14 -21
- data/lib/pacer/core/graph/graph_index_route.rb +12 -8
- data/lib/pacer/core/graph/graph_route.rb +2 -5
- data/lib/pacer/core/graph/mixed_route.rb +3 -5
- data/lib/pacer/core/graph/vertices_route.rb +26 -27
- data/lib/pacer/core/route.rb +35 -66
- data/lib/pacer/exceptions.rb +13 -6
- data/lib/pacer/extensions/block_filter_element.rb +0 -5
- data/lib/pacer/filter/collection_filter.rb +9 -2
- data/lib/pacer/filter/empty_filter.rb +12 -3
- data/lib/pacer/filter/future_filter.rb +5 -5
- data/lib/pacer/filter/loop_filter.rb +7 -13
- data/lib/pacer/filter/object_filter.rb +10 -16
- data/lib/pacer/filter/property_filter/filters.rb +134 -93
- data/lib/pacer/filter/property_filter.rb +22 -19
- data/lib/pacer/filter/where_filter/node_visitor.rb +47 -26
- data/lib/pacer/filter/where_filter.rb +24 -3
- data/lib/pacer/function_resolver.rb +7 -2
- data/lib/pacer/graph/graph_ml.rb +39 -0
- data/lib/pacer/graph/graph_transactions_mixin.rb +107 -175
- data/lib/pacer/graph/pacer_graph.rb +438 -0
- data/lib/pacer/graph/simple_encoder.rb +20 -0
- data/lib/pacer/graph/yaml_encoder.rb +81 -0
- data/lib/pacer/graph.rb +8 -10
- data/lib/pacer/pipe/blackbox_pipeline.rb +11 -4
- data/lib/pacer/pipe/block_filter_pipe.rb +5 -22
- data/lib/pacer/pipe/cross_product_transform_pipe.rb +5 -7
- data/lib/pacer/pipe/edges_pipe.rb +22 -0
- data/lib/pacer/pipe/enumerable_pipe.rb +3 -9
- data/lib/pacer/pipe/expandable_pipe.rb +2 -14
- data/lib/pacer/pipe/id_collection_filter_pipe.rb +2 -8
- data/lib/pacer/pipe/is_empty_pipe.rb +5 -12
- data/lib/pacer/pipe/is_unique_pipe.rb +3 -13
- data/lib/pacer/pipe/label_collection_filter_pipe.rb +1 -7
- data/lib/pacer/pipe/label_prefix_pipe.rb +0 -6
- data/lib/pacer/pipe/loop_pipe.rb +27 -25
- data/lib/pacer/pipe/never_pipe.rb +1 -1
- data/lib/pacer/pipe/path_wrapping_pipe.rb +40 -0
- data/lib/pacer/pipe/process_pipe.rb +2 -20
- data/lib/pacer/pipe/property_comparison_pipe.rb +0 -6
- data/lib/pacer/pipe/ruby_pipe.rb +10 -3
- data/lib/pacer/pipe/simple_visitor_pipe.rb +12 -11
- data/lib/pacer/pipe/stream_sort_pipe.rb +1 -7
- data/lib/pacer/pipe/stream_uniq_pipe.rb +0 -6
- data/lib/pacer/pipe/type_filter_pipe.rb +1 -7
- data/lib/pacer/pipe/unary_transform_pipe.rb +6 -8
- data/lib/pacer/pipe/unwrapping_pipe.rb +13 -0
- data/lib/pacer/pipe/vertices_pipe.rb +22 -0
- data/lib/pacer/pipe/visitor_pipe.rb +3 -7
- data/lib/pacer/pipe/wrapping_pipe.rb +37 -0
- data/lib/pacer/pipes.rb +17 -12
- data/lib/pacer/route/mixin/bulk_operations.rb +8 -9
- data/lib/pacer/route/mixin/route_operations.rb +17 -11
- data/lib/pacer/route/mixins.rb +0 -1
- data/lib/pacer/route.rb +198 -121
- data/lib/pacer/side_effect/aggregate.rb +22 -2
- data/lib/pacer/side_effect/as.rb +73 -0
- data/lib/pacer/side_effect/group_count.rb +0 -3
- data/lib/pacer/side_effect/is_unique.rb +7 -6
- data/lib/pacer/side_effect.rb +1 -1
- data/lib/pacer/support/enumerable.rb +14 -12
- data/lib/pacer/support/nil_class.rb +5 -0
- data/lib/pacer/support/proc.rb +2 -2
- data/lib/pacer/support.rb +1 -1
- data/lib/pacer/transform/cap.rb +1 -1
- data/lib/pacer/transform/has_count_cap.rb +1 -1
- data/lib/pacer/transform/join.rb +20 -16
- data/lib/pacer/transform/map.rb +6 -2
- data/lib/pacer/transform/path.rb +44 -20
- data/lib/pacer/transform/sort_section.rb +58 -51
- data/lib/pacer/utils/tsort.rb +7 -2
- data/lib/pacer/utils.rb +0 -1
- data/lib/pacer/version.rb +4 -3
- data/lib/pacer/visitors/section.rb +42 -0
- data/lib/pacer/visitors/visits_section.rb +32 -0
- data/lib/pacer/visitors.rb +7 -0
- data/lib/pacer/wrappers/edge_wrapper.rb +164 -11
- data/lib/pacer/wrappers/element_wrapper.rb +133 -8
- data/lib/pacer/wrappers/index_wrapper.rb +47 -0
- data/lib/pacer/wrappers/vertex_wrapper.rb +175 -12
- data/lib/pacer/wrappers/wrapper_selector.rb +40 -0
- data/lib/pacer/wrappers/wrapping_pipe_function.rb +90 -0
- data/lib/pacer/wrappers.rb +3 -1
- data/lib/pacer-1.0.0-standalone.jar +0 -0
- data/lib/pacer.rb +13 -47
- data/pacer.gemspec +0 -8
- data/pom.xml +10 -3
- data/spec/pacer/blueprints/dex_spec.rb +12 -26
- data/spec/pacer/blueprints/neo4j_spec.rb +14 -28
- data/spec/pacer/blueprints/tg_spec.rb +6 -54
- data/spec/pacer/core/graph/edges_route_spec.rb +1 -1
- data/spec/pacer/core/graph/element_route_spec.rb +2 -2
- data/spec/pacer/core/graph/graph_route_spec.rb +2 -2
- data/spec/pacer/core/graph/vertices_route_spec.rb +10 -3
- data/spec/pacer/core/route_spec.rb +35 -58
- data/spec/pacer/filter/empty_filter_spec.rb +5 -6
- data/spec/pacer/filter/future_filter_spec.rb +8 -8
- data/spec/pacer/filter/loop_filter_spec.rb +120 -6
- data/spec/pacer/filter/object_filter_spec.rb +15 -0
- data/spec/pacer/filter/property_filter/filters_spec.rb +169 -0
- data/spec/pacer/filter/property_filter_spec.rb +15 -12
- data/spec/pacer/filter/uniq_filter_spec.rb +1 -1
- data/spec/pacer/filter/where_filter_spec.rb +55 -7
- data/spec/pacer/graph/{graph_mixin_spec.rb → pacer_graph_spec.rb} +114 -185
- data/spec/pacer/route/mixin/base_spec.rb +36 -35
- data/spec/pacer/route/mixin/route_operations_spec.rb +4 -46
- data/spec/pacer/side_effect/as_spec.rb +34 -0
- data/spec/pacer/support/enumerable_spec.rb +6 -6
- data/spec/pacer/transform/join_spec.rb +7 -5
- data/spec/pacer/transform/map_spec.rb +55 -0
- data/spec/pacer/transform/path_spec.rb +30 -15
- data/spec/pacer/transform/process_spec.rb +42 -0
- data/spec/pacer/transform/sort_section_spec.rb +82 -0
- data/spec/pacer/wrapper/edge_wrapper_spec.rb +122 -2
- data/spec/pacer/wrapper/element_wrapper_spec.rb +289 -3
- data/spec/pacer/wrapper/vertex_wrapper_spec.rb +289 -2
- data/spec/spec_helper.rb +16 -7
- data/spec/support/graph_runner.rb +80 -29
- data/tags +1165 -0
- metadata +46 -107
- data/.rvmrc +0 -0
- data/lib/pacer/blueprints/extensions.rb +0 -77
- data/lib/pacer/graph/edge_mixin.rb +0 -127
- data/lib/pacer/graph/element_mixin.rb +0 -202
- data/lib/pacer/graph/graph_indices_mixin.rb +0 -93
- data/lib/pacer/graph/graph_mixin.rb +0 -361
- data/lib/pacer/graph/index_mixin.rb +0 -30
- data/lib/pacer/graph/vertex_mixin.rb +0 -119
- data/lib/pacer/pipe/map_pipe.rb +0 -36
- data/lib/pacer/pipe/variable_store_iterator_wrapper.rb +0 -26
- data/lib/pacer/route/mixin/variable_route_module.rb +0 -26
- data/lib/pacer/side_effect/section.rb +0 -25
- data/lib/pacer/support/iterator_mixins.rb +0 -110
- data/lib/pacer/wrappers/new_element.rb +0 -106
- data/lib/pacer-0.9.1.1-standalone.jar +0 -0
- data/spec/pacer/graph/edge_mixin_spec.rb +0 -116
- data/spec/pacer/graph/element_mixin_spec.rb +0 -297
- data/spec/pacer/graph/index_mixin_spec.rb +0 -0
- data/spec/pacer/graph/vertex_mixin_spec.rb +0 -192
@@ -12,14 +12,15 @@ module Pacer
|
|
12
12
|
return [function, extension] if function
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
15
|
+
[]
|
16
16
|
end
|
17
17
|
|
18
18
|
def lookup_path
|
19
19
|
@lookup_path ||= [
|
20
20
|
[:filter, filter_map, nil],
|
21
21
|
[:transform, transform_map, nil],
|
22
|
-
[:side_effect, side_effect_map, Pacer::Core::SideEffect]
|
22
|
+
[:side_effect, side_effect_map, Pacer::Core::SideEffect],
|
23
|
+
[:visitor, visitor_map]
|
23
24
|
]
|
24
25
|
end
|
25
26
|
|
@@ -31,6 +32,10 @@ module Pacer
|
|
31
32
|
Hash[Pacer::SideEffect.constants.map { |name| [symbolize_module_name(name), Pacer::SideEffect.const_get(name)] }]
|
32
33
|
end
|
33
34
|
|
35
|
+
def visitor_map
|
36
|
+
Hash[Pacer::Visitors.constants.map { |name| [symbolize_module_name(name), Pacer::Visitors.const_get(name)] }]
|
37
|
+
end
|
38
|
+
|
34
39
|
def transform_map
|
35
40
|
Hash[Pacer::Transform.constants.map { |name| [symbolize_module_name(name), Pacer::Transform.const_get(name)] }]
|
36
41
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Pacer
|
2
|
+
# Methods to be mixed into Blueprints Graph objects from any
|
3
|
+
# implementation.
|
4
|
+
#
|
5
|
+
# Adds more convenient/rubyish methods and adds support for extensions
|
6
|
+
# to some methods where needed.
|
7
|
+
class GraphML
|
8
|
+
# Import the data in a GraphML file.
|
9
|
+
#
|
10
|
+
# Will fail if the data already exsts in the current graph.
|
11
|
+
#
|
12
|
+
# @param [String] path
|
13
|
+
def self.import(graph, path)
|
14
|
+
path = File.expand_path path
|
15
|
+
begin
|
16
|
+
stream = java.net.URL.new(path).open_stream
|
17
|
+
rescue java.net.MalformedURLException
|
18
|
+
stream = java.io.FileInputStream.new path
|
19
|
+
end
|
20
|
+
graph.send :creating_elements do
|
21
|
+
com.tinkerpop.blueprints.util.io.graphml.GraphMLReader.input_graph graph.blueprints_graph, stream
|
22
|
+
end
|
23
|
+
true
|
24
|
+
ensure
|
25
|
+
stream.close if stream
|
26
|
+
end
|
27
|
+
|
28
|
+
# Export the graph to GraphML
|
29
|
+
#
|
30
|
+
# @param [String] path will be replaced if it exists
|
31
|
+
def self.export(graph, path)
|
32
|
+
path = File.expand_path path
|
33
|
+
stream = java.io.FileOutputStream.new path
|
34
|
+
com.tinkerpop.blueprints.util.io.graphml.GraphMLWriter.outputGraph graph.blueprints_graph, stream
|
35
|
+
ensure
|
36
|
+
stream.close if stream
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,207 +1,139 @@
|
|
1
1
|
module Pacer
|
2
|
-
import com.tinkerpop.blueprints.
|
2
|
+
import com.tinkerpop.blueprints.TransactionalGraph
|
3
3
|
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# @return [Set] graphs with an open transaction
|
7
|
-
def self.graphs_in_transaction
|
8
|
-
@graphs = Set[] unless defined? @graphs
|
9
|
-
@graphs
|
10
|
-
end
|
11
|
-
|
12
|
-
# Methods used internally to do 'managed transactions' which I define
|
13
|
-
# as transactions that are started and committed automatically
|
14
|
-
# internally, typically on operations that potentially touch a large
|
15
|
-
# number of elements.
|
16
|
-
#
|
17
|
-
# The reason for keeping track of these separately is to prevent them
|
18
|
-
# from being confused with manual transactions. Although when this was
|
19
|
-
# written, I had made manual transactions nestable. That has been
|
20
|
-
# since explicitly disallowed by Blueprints. I am not sure if this
|
21
|
-
# code is actually needed anymore (if it was refactored out).
|
4
|
+
# Add features to transactions to allow them to be more rubyish and
|
5
|
+
# more convenient to use.
|
22
6
|
#
|
23
7
|
# TODO: the method names in this module need to be cleaned up.
|
24
8
|
# TODO: some methods may be able to be eliminated.
|
25
|
-
module
|
26
|
-
def manage_transactions=(v)
|
27
|
-
@manage_transactions = v
|
28
|
-
end
|
29
|
-
|
30
|
-
def manage_transactions?
|
31
|
-
@manage_transactions = true unless defined? @manage_transactions
|
32
|
-
@manage_transactions
|
33
|
-
end
|
34
|
-
alias manage_transactions manage_transactions?
|
35
|
-
|
36
|
-
def unmanaged_transactions
|
37
|
-
old_value = manage_transactions
|
38
|
-
@manage_transactions = false
|
39
|
-
yield
|
40
|
-
ensure
|
41
|
-
@manage_transactions = old_value
|
42
|
-
end
|
43
|
-
|
44
|
-
def managed_transactions
|
45
|
-
if manage_transactions?
|
46
|
-
manual_transactions { yield }
|
47
|
-
else
|
48
|
-
yield
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def managed_manual_transaction
|
53
|
-
if manage_transactions?
|
54
|
-
manual_transaction { yield }
|
55
|
-
else
|
56
|
-
yield
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def managed_transaction
|
61
|
-
if manage_transactions?
|
62
|
-
transaction { yield }
|
63
|
-
else
|
64
|
-
yield
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def managed_start_transaction
|
69
|
-
begin_transaction if manage_transactions?
|
70
|
-
end
|
71
|
-
|
72
|
-
def managed_commit_transaction
|
73
|
-
commit_transaction if manage_transactions?
|
74
|
-
end
|
75
|
-
|
76
|
-
def managed_checkpoint
|
77
|
-
checkpoint if manage_transactions?
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
# This is included into graphs that don't support transactions so that
|
82
|
-
# their interface is the same as for graphs that do support them.
|
83
|
-
#
|
84
|
-
# All methods in this module do nothing but yield or return values
|
85
|
-
# that match those in {GraphTransactionsMixin}
|
86
|
-
module GraphTransactionsStub
|
9
|
+
module GraphTransactionsMixin
|
87
10
|
def in_transaction?
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
11
|
+
threadlocal_graph_info[:tx_depth] > 0
|
12
|
+
end
|
13
|
+
|
14
|
+
# Basic usage:
|
15
|
+
#
|
16
|
+
# graph.transaction do |commit, rollback|
|
17
|
+
# if problem?
|
18
|
+
# rollback.call # rolls back the most recent chunk
|
19
|
+
# elsif chunk_transaction?
|
20
|
+
# commit.call # can be called multiple times, breaking the tx into chunks
|
21
|
+
# elsif error?
|
22
|
+
# raise "bad news" # most recent chunk is rolled back automatically
|
23
|
+
# end
|
24
|
+
# # will automatically commit
|
25
|
+
# end
|
26
|
+
#
|
27
|
+
# Note that rollback may raise a Pacer::NestedTransactionRollback exception, which
|
28
|
+
# if uncaught will cause the top level transaction to rollback.
|
29
|
+
#
|
30
|
+
# It might be a good idea to be able to specify a strategy for nested commits & rollbacks
|
31
|
+
# other than the one I've done here. I don't have any use cases I need it for but if
|
32
|
+
# anyone does I'd like to discuss it and have some ideas how to implement them.
|
33
|
+
#
|
34
|
+
# Also considering a 3rd callback that could be used to get info about the
|
35
|
+
# current transaction stack like depth, number of commits/rollbacks, possibly the number of
|
36
|
+
# mutations it wraps and even some event registration stuff could be made available.
|
99
37
|
def transaction
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
38
|
+
commit, rollback = start_transaction!
|
39
|
+
begin
|
40
|
+
r = yield commit, rollback
|
41
|
+
commit.call
|
42
|
+
r
|
43
|
+
rescue Exception => e
|
44
|
+
rollback.call e.message
|
45
|
+
raise
|
46
|
+
ensure
|
47
|
+
finish_transaction!
|
48
|
+
end
|
104
49
|
end
|
105
50
|
|
106
|
-
|
107
|
-
end
|
51
|
+
private
|
108
52
|
|
109
|
-
def
|
53
|
+
def threadlocal_graph_info
|
54
|
+
graphs = Thread.current[:graphs] ||= {}
|
55
|
+
graphs[blueprints_graph.object_id] ||= {}
|
110
56
|
end
|
111
57
|
|
112
|
-
def
|
58
|
+
def start_transaction!
|
59
|
+
tgi = threadlocal_graph_info
|
60
|
+
tx_depth = tgi[:tx_depth] ||= 0
|
61
|
+
tgi[:tx_depth] += 1
|
62
|
+
if blueprints_graph.is_a? TransactionalGraph
|
63
|
+
if tx_depth == 0
|
64
|
+
base_tx_finalizers
|
65
|
+
else
|
66
|
+
nested_tx_finalizers
|
67
|
+
end
|
68
|
+
else
|
69
|
+
if tx_depth == 0
|
70
|
+
mock_base_tx_finalizers
|
71
|
+
else
|
72
|
+
mock_nested_tx_finalizers
|
73
|
+
end
|
74
|
+
end
|
113
75
|
end
|
114
|
-
end
|
115
76
|
|
116
|
-
|
117
|
-
|
118
|
-
#
|
119
|
-
# TODO: the method names in this module need to be cleaned up.
|
120
|
-
# TODO: some methods may be able to be eliminated.
|
121
|
-
module GraphTransactionsMixin
|
122
|
-
def self.included(target)
|
123
|
-
target.send :protected, :startTransaction, :start_transaction
|
77
|
+
def finish_transaction!
|
78
|
+
threadlocal_graph_info[:tx_depth] -= 1
|
124
79
|
end
|
125
80
|
|
126
|
-
def
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
manual_transactions do
|
132
|
-
transaction do
|
133
|
-
yield
|
81
|
+
def base_tx_finalizers
|
82
|
+
tx_id = threadlocal_graph_info[:tx_id] = rand
|
83
|
+
commit = -> do
|
84
|
+
if tx_id != threadlocal_graph_info[:tx_id]
|
85
|
+
fail InternalError
|
134
86
|
end
|
87
|
+
puts "transaction committed" if Pacer.verbose == :very
|
88
|
+
blueprints_graph.stopTransaction TransactionalGraph::Conclusion::SUCCESS
|
89
|
+
end
|
90
|
+
rollback = ->(message = nil) do
|
91
|
+
puts ["transaction rolled back", message].compact.join(': ') if Pacer.verbose == :very
|
92
|
+
blueprints_graph.stopTransaction TransactionalGraph::Conclusion::FAILURE
|
135
93
|
end
|
94
|
+
[commit, rollback]
|
136
95
|
end
|
137
96
|
|
138
|
-
def
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
raise
|
148
|
-
ensure
|
149
|
-
puts "transaction buffer size reset to #{ original_buffer_size }" if Pacer.verbose == :very
|
150
|
-
setMaxBufferSize original_buffer_size
|
97
|
+
def nested_tx_finalizers
|
98
|
+
commit = -> do
|
99
|
+
puts "nested transaction committed (noop)" if Pacer.verbose == :very
|
100
|
+
end
|
101
|
+
rollback = ->(message = 'Transaction Rolled Back') do
|
102
|
+
puts "nested transaction rolled back: #{ message }" if Pacer.verbose == :very
|
103
|
+
unless $!
|
104
|
+
message ||= "Can not rollback a nested transaction"
|
105
|
+
fail NestedTransactionRollback, message
|
151
106
|
end
|
152
|
-
else
|
153
|
-
yield
|
154
107
|
end
|
108
|
+
[commit, rollback]
|
155
109
|
end
|
156
110
|
|
157
|
-
def
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
111
|
+
def mock_base_tx_finalizers
|
112
|
+
commit = -> do
|
113
|
+
puts "mock transaction committed" if Pacer.verbose == :very
|
114
|
+
end
|
115
|
+
rollback = ->(message = nil) do
|
116
|
+
puts ["mock transaction rolled back", message].compact.join(': ') if Pacer.verbose == :very
|
117
|
+
unless $!
|
118
|
+
message ||= "Can not rollback a mock transaction"
|
119
|
+
fail MockTransactionRollback, message
|
164
120
|
end
|
165
|
-
rescue Exception
|
166
|
-
puts "transaction aborted" if Pacer.verbose == :very
|
167
|
-
raise
|
168
|
-
ensure
|
169
|
-
puts "transaction finished #{ conclusion }" if Pacer.verbose == :very
|
170
|
-
stop_transaction conclusion
|
171
|
-
Pacer.graphs_in_transaction.delete self
|
172
121
|
end
|
122
|
+
[commit, rollback]
|
173
123
|
end
|
174
124
|
|
175
|
-
def
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
puts "transaction committed" if Pacer.verbose == :very
|
186
|
-
r
|
187
|
-
end
|
188
|
-
|
189
|
-
def rollback_transaction
|
190
|
-
r = stop_transaction TransactionalGraph::Conclusion::FAILURE
|
191
|
-
Pacer.graphs_in_transaction.delete self
|
192
|
-
puts "transaction rolled back" if Pacer.verbose == :very
|
193
|
-
r
|
194
|
-
end
|
195
|
-
|
196
|
-
def checkpoint(success = true)
|
197
|
-
if success
|
198
|
-
commit_transaction
|
199
|
-
else
|
200
|
-
rollback_transaction
|
125
|
+
def mock_nested_tx_finalizers
|
126
|
+
commit = -> do
|
127
|
+
puts "nested transaction committed (noop)" if Pacer.verbose == :very
|
128
|
+
end
|
129
|
+
rollback = ->(message = nil) do
|
130
|
+
puts "nested transaction rolled back: #{ message }" if Pacer.verbose == :very
|
131
|
+
unless $!
|
132
|
+
message ||= "Can not rollback a mock or nested transaction"
|
133
|
+
fail NestedMockTransactionRollback, message
|
134
|
+
end
|
201
135
|
end
|
202
|
-
|
203
|
-
Pacer.graphs_in_transaction << self
|
136
|
+
[commit, rollback]
|
204
137
|
end
|
205
|
-
|
206
138
|
end
|
207
139
|
end
|