operationable 0.2.5 → 0.2.6
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 +4 -4
- data/README.md +24 -0
- data/lib/operationable/runners/base.rb +2 -1
- data/lib/operationable/runners/separate.rb +8 -7
- data/lib/operationable/runners/serial.rb +12 -11
- data/lib/operationable/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ddf02b693334196d4ea8e365bfdaa0959336836
|
4
|
+
data.tar.gz: 9197bf207f0f242669cb049d39d6184135f96be4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd9773af6e30769ed6b6b794f39e1cad32ce3c68b7610c62ca7ebb905e059d8fb48d48925d70363ce05f211c3f479cdd333d5dc4aefda14cea1d13e64503f052
|
7
|
+
data.tar.gz: 9f55de492294bf5c22c9eaeb27c538757fef8cae4e01022928d0fb7c9ab446ca84a8ef3e66ccc8f004561a78f9e4dfb3c6221b701e951a8076076ac26d239640
|
data/README.md
CHANGED
@@ -113,6 +113,30 @@ Class that contain callback methods, that will called after model saved in runti
|
|
113
113
|
#Validators
|
114
114
|
TODO: describe validators
|
115
115
|
|
116
|
+
#Persistence and guaranteed delivery
|
117
|
+
|
118
|
+
First add table to store operations and track their execution
|
119
|
+
|
120
|
+
```
|
121
|
+
class CreateOperations < ActiveRecord::Migration[5.0]
|
122
|
+
def change
|
123
|
+
create_table :operations do |t|
|
124
|
+
t.string :name
|
125
|
+
t.integer :initiator_id
|
126
|
+
t.jsonb :params, default: {}
|
127
|
+
t.jsonb :callbacks, default: {}
|
128
|
+
|
129
|
+
t.timestamps
|
130
|
+
end
|
131
|
+
|
132
|
+
add_index :operations, :initiator_id
|
133
|
+
add_index :operations, :name
|
134
|
+
end
|
135
|
+
end
|
136
|
+
```
|
137
|
+
|
138
|
+
After that all operations by default will populate database with status of execution.
|
139
|
+
|
116
140
|
## Development
|
117
141
|
|
118
142
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -18,16 +18,17 @@ module Operationable
|
|
18
18
|
op_id: persist_operation.id }
|
19
19
|
end
|
20
20
|
|
21
|
-
# def self.call(options, props)
|
22
|
-
# options[:callback_class_name].constantize.new(props).method(options[:callback_method_name]).call
|
23
|
-
# end
|
24
|
-
|
25
21
|
def self.call(options, props)
|
26
|
-
|
27
|
-
options[:callback_class_name].constantize.new(props).method(options[:callback_method_name]).call
|
28
|
-
})
|
22
|
+
options[:callback_class_name].constantize.new(props).method(options[:callback_method_name]).call
|
29
23
|
end
|
30
24
|
|
25
|
+
# TODO: No sense, due to performance deterioration, better use postgres/mysql database
|
26
|
+
# def self.call(options, props)
|
27
|
+
# ::Operationable::Persister.around_call(options[:op_id], options[:callback_method_name], -> {
|
28
|
+
# options[:callback_class_name].constantize.new(props).method(options[:callback_method_name]).call
|
29
|
+
# })
|
30
|
+
# end
|
31
|
+
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -10,21 +10,22 @@ module Operationable
|
|
10
10
|
(queue.blank? ? self.class : OperationJob.method(perform_method)).call(options, props)
|
11
11
|
end
|
12
12
|
|
13
|
-
# def self.call(options, props)
|
14
|
-
# instance = options[:callback_class_name].constantize.new(props)
|
15
|
-
# options[:callback_names].each { |method_name| instance.method(method_name).call }
|
16
|
-
# end
|
17
|
-
|
18
13
|
def self.call(options, props)
|
19
14
|
instance = options[:callback_class_name].constantize.new(props)
|
20
|
-
|
21
|
-
options[:callback_names].each do |method_name|
|
22
|
-
::Operationable::Persister.around_call(options[:op_id], method_name, -> {
|
23
|
-
instance.method(method_name).call
|
24
|
-
})
|
25
|
-
end
|
15
|
+
options[:callback_names].each { |method_name| instance.method(method_name).call }
|
26
16
|
end
|
27
17
|
|
18
|
+
# TODO: No sense, due to performance deterioration, better use postgres/mysql database
|
19
|
+
# def self.call(options, props)
|
20
|
+
# instance = options[:callback_class_name].constantize.new(props)
|
21
|
+
#
|
22
|
+
# options[:callback_names].each do |method_name|
|
23
|
+
# ::Operationable::Persister.around_call(options[:op_id], method_name, -> {
|
24
|
+
# instance.method(method_name).call
|
25
|
+
# })
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
|
28
29
|
def options
|
29
30
|
{ type: 'serial',
|
30
31
|
callback_class_name: callback_class_name,
|