simple_mutex 1.0.0 → 1.0.1

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: 386f8c08c9a13c4402812145555a49a710fe28bf016455491bb779aa58cd7a90
4
- data.tar.gz: 1a7e87acc3d54d3a90fd31a515c92c861823e10c054511c1466303fd5afc5e1f
3
+ metadata.gz: 003ab1f3d7a72c1ed87d20272d4e7e84c8b486fd7dc3a34539ee8ce21688199d
4
+ data.tar.gz: e392b0b025b830ea18f062e402c1608562ad3992d3c8c100a266e77f7392dbb5
5
5
  SHA512:
6
- metadata.gz: c94e26f6ac88dd2d3be0b7a788051ef0bf8cda52acd41173d18dabb53521c9bb1feb639ba76deac1feccae666a0e3c359563569a5c5fd81175980d87bd324eac
7
- data.tar.gz: bc0f67a008af4a252e118673584c691de022ad5568b83a088654e9070ad45a20c3fec5c77b2b2abd1f1208ca4831b36a4e276a20fbe49d3854886eda48dfd81f
6
+ metadata.gz: 4385df59ccb07e0781ff83575d2137907ebc022e2971d2cb9e5f000c70075f7685585e5f93ac3b8dcf5d8798dbb28400441f1bf263c6d34167a22740f1661edd
7
+ data.tar.gz: 1c0bd82fce378dfe91f8d778792a325f14191547ce3e6d464cb1b472299480378299283a28340c4299ff5a1d4dd63ab49204e825d31ba85adcc7e7f0f8719784
@@ -28,6 +28,7 @@ jobs:
28
28
  - run: bundle exec rubocop
29
29
  - run: bundle exec rspec
30
30
 
31
- - uses: coverallsapp/github-action@v1.1.2
31
+ - name: Coveralls
32
+ uses: coverallsapp/github-action@master
32
33
  with:
33
34
  github-token: ${{ secrets.GITHUB_TOKEN }}
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [1.0.1]
6
+
7
+ - Bugfix with active job/batches memoization in `SimpleMutex::SidekiqSupport::JobCleaner` and
8
+ `SimpleMutex:SidekiqSupport::BatchCleaner`
9
+ - Simplecov added
10
+ - More tests added for 100% coverage
11
+
12
+ ## [1.0.0]
13
+
14
+ Initial public release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_mutex (1.0.0)
4
+ simple_mutex (1.0.1)
5
5
  redis
6
6
  redis-namespace
7
7
  sidekiq
@@ -22,6 +22,7 @@ GEM
22
22
  concurrent-ruby (1.1.9)
23
23
  connection_pool (2.2.5)
24
24
  diff-lcs (1.4.4)
25
+ docile (1.4.0)
25
26
  i18n (1.8.10)
26
27
  concurrent-ruby (~> 1.0)
27
28
  minitest (5.14.4)
@@ -84,10 +85,17 @@ GEM
84
85
  rubocop (~> 1.0)
85
86
  ruby-progressbar (1.11.0)
86
87
  ruby2_keywords (0.0.5)
87
- sidekiq (6.2.2)
88
+ sidekiq (6.3.1)
88
89
  connection_pool (>= 2.2.2)
89
90
  rack (~> 2.0)
90
91
  redis (>= 4.2.0)
92
+ simplecov (0.21.2)
93
+ docile (~> 1.1)
94
+ simplecov-html (~> 0.11)
95
+ simplecov_json_formatter (~> 0.1)
96
+ simplecov-html (0.12.3)
97
+ simplecov-lcov (0.8.0)
98
+ simplecov_json_formatter (0.1.3)
91
99
  thor (1.1.0)
92
100
  timecop (0.9.4)
93
101
  tzinfo (2.0.4)
@@ -107,6 +115,8 @@ DEPENDENCIES
107
115
  rubocop-config-umbrellio
108
116
  rubocop-rspec
109
117
  simple_mutex!
118
+ simplecov
119
+ simplecov-lcov
110
120
  timecop
111
121
 
112
122
  BUNDLED WITH
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # SimpleMutex
1
+
2
+ # SimpleMutex · [![Gem Version](https://badge.fury.io/rb/simple_mutex.svg)](https://badge.fury.io/rb/simple_mutex) [![Coverage Status](https://coveralls.io/repos/github/umbrellio/simple_mutex/badge.svg?branch=main)](https://coveralls.io/github/umbrellio/simple_mutex?branch=main)
3
+
2
4
 
3
5
  `SimpleMutex::Mutex` - Redis-based locks with ability to store custom data inside them.
4
6
 
@@ -21,11 +21,11 @@ module SimpleMutex
21
21
 
22
22
  next redis.unwatch if entity_id.nil? || active?(entity_id)
23
23
 
24
- return_value = redis.multi { redis.del(lock_key) }
24
+ return_value = redis.multi { |multi| multi.del(lock_key) }
25
25
 
26
26
  log_iteration(lock_key, raw_data, return_value) unless logger.nil?
27
27
 
28
- return_value.first.positive?
28
+ return_value&.first&.positive?
29
29
  end
30
30
  end
31
31
 
@@ -38,17 +38,9 @@ module SimpleMutex
38
38
  active_entity_ids.include?(entity_id)
39
39
  end
40
40
 
41
- def type
42
- raise NoMethodError
43
- end
44
-
45
- def path_to_entity_id
46
- raise NoMethodError
47
- end
48
-
49
- def get_active_entity_ids
50
- raise NoMethodError
51
- end
41
+ # @!method type
42
+ # @!method path_to_entity_id
43
+ # @!method get_active_entity_ids
52
44
 
53
45
  def safe_parse(raw_data)
54
46
  JSON.parse(raw_data)
@@ -65,11 +57,12 @@ module SimpleMutex
65
57
  def log_iteration(lock_key, raw_data, return_value)
66
58
  log_msg = generate_log_msg(lock_key, raw_data, return_value)
67
59
 
68
- if return_value&.first.is_a?(Integer)
69
- logger.info(log_msg)
70
- else
71
- logger.error(log_msg)
60
+ # should not happen, but we encountered this few times long time ago
61
+ unless return_value&.first.is_a?(Integer)
62
+ return logger.error(log_msg)
72
63
  end
64
+
65
+ return_value&.first&.positive? ? logger.info(log_msg) : logger.warn(log_msg)
73
66
  end
74
67
 
75
68
  def start_msg
@@ -105,7 +105,7 @@ module SimpleMutex
105
105
  return false if raw_data.nil?
106
106
 
107
107
  JSON.parse(raw_data)["signature"] == signature
108
- rescue JSON::ParseError, TypeError
108
+ rescue JSON::ParserError, TypeError
109
109
  false
110
110
  end
111
111
  end
@@ -24,7 +24,7 @@ module SimpleMutex
24
24
  %w[payload bid]
25
25
  end
26
26
 
27
- def active_entity_ids
27
+ def get_active_entity_ids
28
28
  ::Sidekiq::BatchSet.new.map(&:bid)
29
29
  end
30
30
  end
@@ -19,7 +19,7 @@ module SimpleMutex
19
19
  %w[payload jid]
20
20
  end
21
21
 
22
- def active_entity_ids
22
+ def get_active_entity_ids
23
23
  ::Sidekiq::Workers.new.map { |_pid, _tid, work| work["payload"]["jid"] }
24
24
  end
25
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SimpleMutex
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
data/simple_mutex.gemspec CHANGED
@@ -36,5 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency "rubocop"
37
37
  spec.add_development_dependency "rubocop-config-umbrellio"
38
38
  spec.add_development_dependency "rubocop-rspec"
39
+ spec.add_development_dependency "simplecov"
40
+ spec.add_development_dependency "simplecov-lcov"
39
41
  spec.add_development_dependency "timecop"
40
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_mutex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - bob-umbr
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-09 00:00:00.000000000 Z
11
+ date: 2021-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -150,6 +150,34 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: simplecov
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: simplecov-lcov
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
153
181
  - !ruby/object:Gem::Dependency
154
182
  name: timecop
155
183
  requirement: !ruby/object:Gem::Requirement
@@ -171,10 +199,11 @@ executables: []
171
199
  extensions: []
172
200
  extra_rdoc_files: []
173
201
  files:
174
- - ".github/worklows/ci.yml"
202
+ - ".github/workflows/main.yml"
175
203
  - ".gitignore"
176
204
  - ".rspec"
177
205
  - ".rubocop.yml"
206
+ - CHANGELOG.md
178
207
  - Gemfile
179
208
  - Gemfile.lock
180
209
  - LICENSE
@@ -213,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
213
242
  - !ruby/object:Gem::Version
214
243
  version: '0'
215
244
  requirements: []
216
- rubygems_version: 3.3.0.dev
245
+ rubygems_version: 3.2.3
217
246
  signing_key:
218
247
  specification_version: 4
219
248
  summary: Redis-based mutex library for using with sidekiq jobs and batches.