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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da4f2c001b58a3ce07d7d7a16100c9abdee28cd2
4
- data.tar.gz: 52b9abff75acce3b938c60708e10646e79fb7a98
3
+ metadata.gz: 3ddf02b693334196d4ea8e365bfdaa0959336836
4
+ data.tar.gz: 9197bf207f0f242669cb049d39d6184135f96be4
5
5
  SHA512:
6
- metadata.gz: 907b157d42743139639ee5999ad221e25b576bb33a802078db1a9f18f5e3047502c4844f6957f1c41001168e7d518fac48265075aa1b475ba2bbcde17441e275
7
- data.tar.gz: 19838de1878f31a759c11002d42ff0c1bd301f8a794e310cdd477965bcf81f0a05deb58714d76df99d7863627a2fe14911aefb748c533a1463d6f5a7f53b6882
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.
@@ -13,7 +13,8 @@ module Operationable
13
13
 
14
14
  initialize_callbacks
15
15
 
16
- persist_operation
16
+ # TODO: No sense, due to performance deterioration, better use postgres/mysql database
17
+ # persist_operation
17
18
  end
18
19
 
19
20
  def run
@@ -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
- ::Operationable::Persister.around_call(options[:op_id], options[:callback_method_name], -> {
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,
@@ -1,3 +1,3 @@
1
1
  module Operationable
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: operationable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Suhodolov