raes 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f85a9824a67f03b829de900a8a6bbc81fb9acd1608fd70d5ee3cc1cbc1265662
4
- data.tar.gz: c1b09916edaca6db620931e5823cd0bbc2666b4287223150acafb50ff9002ef5
3
+ metadata.gz: 1dffe3c6d3ae48ba6766d5805ae068d9bbb4a10a0f6134b8088c780d87cdafe6
4
+ data.tar.gz: aff12b845de5928976f25775531951d3ddc1bca1d925f6e1b056535d599fd31e
5
5
  SHA512:
6
- metadata.gz: 28af8898db1f4a68d174eba88a2f78ac7309247892b4765ae908fc56def1c294d99fbc87f2847e557ef94885160769f5414964ab97d4efae51affe736355e933
7
- data.tar.gz: a9ed484de220441b3b322468dbed119f55263baca3e38cc40cc5ecbf52676d6fe38b376aec2db994cfe1a5d0b2e14da56ec002e6f24091dbac7f661f3112d92f
6
+ metadata.gz: 5f2253c2b756dd88e3dcb49b48d3ee04e07e1e554b8d8dd2828bfedfd71d5a56264531770d3f7b829f41ede39d3f7d5c127aed3e5e735ebcb73b2fbc88485f63
7
+ data.tar.gz: 42ff96ce8da20cec8252bdf74a9363bb960338f0a5bc494d9df3515ad2eb77f6a4652b5a0a5ea52a60c1314e4d2b92b71f43a827ce2a55e867079865a409dfac
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Raes
4
+ class StatelessJob < ApplicationJob
5
+ def perform(name, payload)
6
+ ActiveRecord::Base.uncached do
7
+ klass = name.constantize
8
+ if klass.instance_method(:initialize).arity.zero?
9
+ klass.call
10
+ else
11
+ klass.call(payload.symbolize_keys)
12
+ end
13
+ end
14
+ GC.start
15
+ end
16
+ end
17
+ end
@@ -3,7 +3,10 @@
3
3
  module Raes
4
4
  class SubscribeJob < ApplicationJob
5
5
  def perform(action)
6
- Reducer.call(action)
6
+ ActiveRecord::Base.uncached do
7
+ Reducer.call(action)
8
+ end
9
+ GC.start
7
10
  end
8
11
  end
9
12
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  Raes::Engine.routes.draw do
4
+ # engine routes
4
5
  end
@@ -10,7 +10,7 @@ require 'raes/reducer'
10
10
  module Raes
11
11
  def self.config
12
12
  @config ||= Rails.application.config_for(:raes)
13
- rescue StandardError => e
13
+ rescue StandardError
14
14
  @config = {}
15
15
  end
16
16
 
@@ -21,4 +21,8 @@ module Raes
21
21
  def self.search(name)
22
22
  Action.search(name)
23
23
  end
24
+
25
+ def self.stateless(name, payload = {})
26
+ StatelessJob.perform_later(name.to_s, payload)
27
+ end
24
28
  end
@@ -23,10 +23,11 @@ module Raes
23
23
  end
24
24
 
25
25
  def create_state
26
- if @action.name.constantize.instance_method(:initialize).arity.zero?
27
- @action.name.constantize.call
26
+ klass = @action.name.constantize
27
+ if klass.instance_method(:initialize).arity.zero?
28
+ klass.call
28
29
  else
29
- @action.name.constantize.call(JSON.parse(@action.payload).symbolize_keys)
30
+ klass.call(JSON.parse(@action.payload).symbolize_keys)
30
31
  end
31
32
  end
32
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Raes
4
- VERSION = '0.1.3'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ogom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-09 00:00:00.000000000 Z
11
+ date: 2020-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -87,6 +87,7 @@ files:
87
87
  - app/controllers/raes/application_controller.rb
88
88
  - app/helpers/raes/application_helper.rb
89
89
  - app/jobs/raes/application_job.rb
90
+ - app/jobs/raes/stateless_job.rb
90
91
  - app/jobs/raes/subscribe_job.rb
91
92
  - app/mailers/raes/application_mailer.rb
92
93
  - app/models/raes/action.rb