wolf_core 0.1.78 → 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: 5e145d3b439d467c90d8724667a591a2c296cef6bb593b92725aaef999ee8ebe
4
- data.tar.gz: 3aa621efd4819d2a657626eee5e63e37dc24ccef22d44965fa63006e3e3c85a2
3
+ metadata.gz: 0c473b8e90d8d68a02e1efb3750f5a9af41eed306f68054496d26fbe769e5640
4
+ data.tar.gz: 8e362026d5c23766d664b29cc30e51910a7259862ae26bdb9b117ebc6df30de6
5
5
  SHA512:
6
- metadata.gz: 3cff2eac905d64ca218923a824df3972657b5b364ac13103044e4f5dcfe1c76894abccef55da0f8b85aec811d86fde58de8458cd075c007a23fa36b6aebb1c44
7
- data.tar.gz: 55109f3a42ed5fcdbc239b71e9771bef15df2c4bdc3d6af5dcc50fe37a6ffaeb06491c262d23d63e520e754d2088f97877d9cb944fdcfea500f1b3d22c23e1e9
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WolfCore
4
- VERSION = "0.1.78"
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.78
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