raes 0.2.2 → 0.2.3

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: d721d10ce56f1d6d3070a9b6d7c0de4837fb6264213071e352e4c943cad2e922
4
- data.tar.gz: 6fb24ec1d713e01044b8fb3ae1b39f30b03e123439ec15e22ddd9dfb208ff70f
3
+ metadata.gz: 9392ed6cf1189aadf25bf2a88a7eae729622dd19a71b33a64d41783e1062fe00
4
+ data.tar.gz: 327a5cb0c338e933d91e41b0a34b01b5abd975e3d4448a5fa39da9bf5a332398
5
5
  SHA512:
6
- metadata.gz: a6119cb606129f09fa07731b4e3a3c497985e33a45b134bdef1839e50584e0323a7c2b242f31179c446f4dfdbb7dc531f2f42a9dd22e81bc9d33d3d25522d4fa
7
- data.tar.gz: 9e5c47e1dab07a05a06e66881b39e8475210f0cc4ebd6bf5db878d7c43b9d36554eef794d7ddd82b5e8287639b76848da86472b1aa19abe4fc65a0bab0075ff0
6
+ metadata.gz: 95e167c1ff7f4b8a6685643f44ef4592165e1d73332785532866a2b371c9f22ed80cab3c77f101ca8f689626cdbaf28c851a68bc1e408de04a7e285a56fe98c6
7
+ data.tar.gz: ce567beb27fbcdba14a53450b6e3af91af5f5c344d4581602ed1f9aaf8f0d7860423a85e827cd9c5cbc16051e3a7c19856c8ef7ac0e9e317de6dfbd2285b9b4b
@@ -3,6 +3,7 @@
3
3
  require 'raes/engine'
4
4
  require 'raes/use_caller'
5
5
  require 'raes/use_context_logger'
6
+ require 'raes/use_memory_limit'
6
7
  require 'raes/use_storage'
7
8
  require 'raes/dispatch'
8
9
  require 'raes/reducer'
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Raes
4
+ module UseMemoryLimit
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ def memsize
9
+ GetProcessMem.new(Process.pid).mb.ceil
10
+ end
11
+
12
+ def memsize_with_gc
13
+ size = memsize
14
+ if !memory_limit.zero? && size > memory_limit
15
+ GC.start
16
+ size = memsize
17
+ end
18
+ size
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def memory_limit
25
+ @memory_limit ||= Raes.config.dig(:concern, :memory_limit).to_i
26
+ end
27
+ end
28
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Raes
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.3'
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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - ogom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-04 00:00:00.000000000 Z
11
+ date: 2020-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 6.0.3.2
33
+ - !ruby/object:Gem::Dependency
34
+ name: get_process_mem
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
33
47
  - !ruby/object:Gem::Dependency
34
48
  name: factory_bot_rails
35
49
  requirement: !ruby/object:Gem::Requirement
@@ -104,6 +118,7 @@ files:
104
118
  - lib/raes/reducer.rb
105
119
  - lib/raes/use_caller.rb
106
120
  - lib/raes/use_context_logger.rb
121
+ - lib/raes/use_memory_limit.rb
107
122
  - lib/raes/use_storage.rb
108
123
  - lib/raes/version.rb
109
124
  - lib/tasks/raes_tasks.rake