wolf_core 0.1.77 → 0.1.79

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: '05821c8a43e12c223d1bea471b63fa3e13173b2ee27bdd2271713357b5f96d5a'
4
- data.tar.gz: cd4ea058a547c3dd15f7675e1bfed8dd06c6e6d8b01d512aba7498be6fd0c2a4
3
+ metadata.gz: 0c473b8e90d8d68a02e1efb3750f5a9af41eed306f68054496d26fbe769e5640
4
+ data.tar.gz: 8e362026d5c23766d664b29cc30e51910a7259862ae26bdb9b117ebc6df30de6
5
5
  SHA512:
6
- metadata.gz: 3c25c80a6822d8804786dbc5b157f7f8248c135c1f45996fea3f119dd69b23c446d4a1198463b20179920d4a60aa1675e26cfe705174da2de3a4de2db0ef152e
7
- data.tar.gz: 4a30e4585a2c22fd5a76b27b69349f7f326da6450ad4482197b0571879f01af746d56275fd1c62ca3ccea581fb38e10fea52e274fa82cca71497f8c1d38e3093
6
+ metadata.gz: 46d05456586f91a6badea88c0118fb776a7098d7382882f7fe7fe591e5c62d90cb7284b25942eb75d45f845ab1eb06d825e339b0fabd842114cf02267492daa3
7
+ data.tar.gz: 5eada455445f5d9207113dccbd6252e444e48ae0c1f458d9c9cbc7d0c13d061f8e1d05331104de0fc1389278c7f5eb771a22b17ec06bd49da9649af2519d07ba
@@ -0,0 +1,29 @@
1
+ module WolfCore
2
+ module InMemoryStorageDataSource
3
+ module_function
4
+
5
+ def init
6
+ @@redis = Redis.new(host: ENV['REDIS_ENDPOINT'], port: ENV['REDIS_PORT'].to_i)
7
+ end
8
+
9
+ def instance
10
+ @@redis
11
+ end
12
+
13
+ def acquire_lock(key:, value:, expiry:)
14
+ instance.set("lock:process:#{ENV['TENANT']}:#{key}", value, ex: expiry.to_i, nx: true)
15
+ end
16
+
17
+ def set_non_exp_lock(key:, value:)
18
+ instance.set("lock:process:#{ENV['TENANT']}:#{key}", value, nx: true)
19
+ end
20
+
21
+ def check_lock(key:)
22
+ instance.get("lock:process:#{ENV['TENANT']}:#{key}")
23
+ end
24
+
25
+ def release_lock(key:)
26
+ instance.del("lock:process:#{ENV['TENANT']}:#{key}")
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,19 @@
1
+ module WolfCore
2
+ module InMemoryStorageOperations
3
+ def acquire_lock(key:, value:, expiry:)
4
+ WolfCore::InMemoryStorageDataSource.acquire_lock(key: key, value: value, expiry: expiry)
5
+ end
6
+
7
+ def set_non_exp_lock(key:, value:)
8
+ WolfCore::InMemoryStorageDataSource.set_non_exp_lock(key: key, value: value)
9
+ end
10
+
11
+ def check_lock(key:)
12
+ WolfCore::InMemoryStorageDataSource.check_lock(key: key)
13
+ end
14
+
15
+ def release_lock(key:)
16
+ WolfCore::InMemoryStorageDataSource.release_lock(key: key)
17
+ end
18
+ end
19
+ end
@@ -14,6 +14,7 @@ module WolfCore
14
14
  end
15
15
 
16
16
  def safe_require(missing_files)
17
+ error_counter = {}
17
18
  while missing_files.any?
18
19
  files_to_require = missing_files
19
20
  missing_files = []
@@ -22,9 +23,12 @@ module WolfCore
22
23
  # log_object "Requiring file: #{file}"
23
24
  require_relative file
24
25
  rescue NameError => e
25
- log_object "Error requiring file: #{file}"
26
- log_object e, title: 'Error is'
27
- missing_files << file
26
+ error_counter[file] = error_counter[file].to_i + 1
27
+ if error_counter[file] >= 10
28
+ log_object "Error requiring file: #{file}"
29
+ log_object e, title: 'Error is'
30
+ end
31
+ missing_files << file if error_counter[file] < 15
28
32
  end
29
33
  end
30
34
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WolfCore
4
- VERSION = "0.1.77"
4
+ VERSION = "0.1.79"
5
5
  end
data/lib/wolf_core.rb CHANGED
@@ -6,10 +6,12 @@ require 'httparty'
6
6
  require 'active_support'
7
7
  require 'active_support/core_ext'
8
8
  require 'aws-sdk-lambda'
9
+ require 'redis'
9
10
 
10
11
  module WolfCore; end
11
12
 
12
13
  require 'wolf_core/utils/file_utils'
13
14
 
14
15
  WolfCore::FileUtils.require_relative_folder(__dir__, 'wolf_core')
15
- WolfCore::LambdaFunctionDataSource.init
16
+ WolfCore::LambdaFunctionDataSource.init
17
+ WolfCore::InMemoryStorageDataSource.init
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wolf_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.77
4
+ version: 0.1.79
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javier Roncallo
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: redis
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Repository to store shared code among Ruby projects.
56
70
  email:
57
71
  - jroncallo96@gmail.com
@@ -70,6 +84,8 @@ files:
70
84
  - lib/wolf_core/infrastructure/fkm_operations.rb
71
85
  - lib/wolf_core/infrastructure/http_data_source.rb
72
86
  - lib/wolf_core/infrastructure/http_operations.rb
87
+ - lib/wolf_core/infrastructure/in_memory_storage_data_source.rb
88
+ - lib/wolf_core/infrastructure/in_memory_storage_operations.rb
73
89
  - lib/wolf_core/infrastructure/lambda_function_data_source.rb
74
90
  - lib/wolf_core/infrastructure/lambda_function_operations.rb
75
91
  - lib/wolf_core/utils/array_utils.rb