reliable-queue-rb 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/LICENSE.txt +1 -1
- data/README.md +5 -1
- data/lib/reliable_queue_rb/chunked_reliable_queue.rb +7 -5
- data/lib/reliable_queue_rb/reliable_queue.rb +5 -3
- data/spec/chunked_reliable_queue_spec.rb +1 -1
- data/spec/reliable_queue_spec.rb +1 -1
- metadata +26 -16
- /data/lib/{reliable-queue-rb.rb → reliable_queue_rb.rb} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f60d11205a995de4132cef78a505e1a15c5006988f7c139f96b340cfc23afe09
|
|
4
|
+
data.tar.gz: e917c4e98b0add02db56d7579a67e163db7f4bc512b473b64a91d0c30423f020
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 772dbd35b2a2b3269d4ac3a03a165adb670364f08addd922aa0470288a0a193c207aa34b8a8feaef4b40c039aa667ac61f03ce9048cd745fd927eb42ee4cc949
|
|
7
|
+
data.tar.gz: c9e8fd7d693cef08dcd67296808cd8b93f55482097f216f0206da5e865cffad55014098dcf8ef96432c8cd0ae1781f8b1d5adc0f5fc76e7e69c220664c8eadc1
|
data/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file. This
|
|
4
4
|
project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
|
|
6
|
+
## [1.0.0] - 2026-03-27
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
|
|
10
|
+
- Replace deprecated `rpoplpush`/`brpoplpush` with `lmove`/`blmove` (requires Redis 6.2+)
|
|
11
|
+
- Modernise dev dependencies
|
|
12
|
+
- Replace Travis CI with GitHub Actions
|
|
13
|
+
- Add house_style and apply the corrections
|
|
14
|
+
- Change the supporting Ruby versions to 2.7 onwards
|
|
15
|
+
|
|
6
16
|
## [0.4.0] - 2023-11-10
|
|
7
17
|
|
|
8
18
|
### Changed
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Ruby reliable queue implementation on top of Redis. It makes sure that message is not lost between popping it from Redis queue and compeleting the task.
|
|
4
4
|
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Redis 6.2 or later
|
|
8
|
+
|
|
5
9
|
## Installation
|
|
6
10
|
|
|
7
11
|
Add this line to your application's `Gemfile`:
|
|
@@ -50,6 +54,6 @@ Bug reports and pull requests are welcome on GitHub at <https://github.com/altme
|
|
|
50
54
|
|
|
51
55
|
## License
|
|
52
56
|
|
|
53
|
-
Copyright © 2020-
|
|
57
|
+
Copyright © 2020-2024 Altmetric LLP
|
|
54
58
|
|
|
55
59
|
Distributed under the [MIT License](http://opensource.org/licenses/MIT).
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class ChunkedReliableQueue
|
|
2
4
|
DEFAULT_SIZE = 100
|
|
3
5
|
|
|
4
|
-
attr_reader :name, :queue, :
|
|
6
|
+
attr_reader :name, :queue, :working_queue, :redis
|
|
5
7
|
|
|
6
8
|
def initialize(name, queue, redis)
|
|
7
9
|
@name = name
|
|
@@ -16,20 +18,20 @@ class ChunkedReliableQueue
|
|
|
16
18
|
return enum_for(:each_slice, size) unless block_given?
|
|
17
19
|
|
|
18
20
|
loop do
|
|
19
|
-
blocking_reply = redis.
|
|
21
|
+
blocking_reply = redis.blmove(queue, working_queue, 'RIGHT', 'LEFT', timeout: 30)
|
|
20
22
|
next unless blocking_reply
|
|
21
23
|
|
|
22
24
|
replies = [blocking_reply]
|
|
23
25
|
replies += redis.multi { |multi|
|
|
24
26
|
(size - 1).times do
|
|
25
|
-
multi.
|
|
27
|
+
multi.lmove(queue, working_queue, 'RIGHT', 'LEFT')
|
|
26
28
|
end
|
|
27
29
|
}.compact
|
|
28
30
|
|
|
29
31
|
yield replies
|
|
30
32
|
redis.multi do |multi|
|
|
31
33
|
replies.each do |reply|
|
|
32
|
-
multi.lrem(working_queue,
|
|
34
|
+
multi.lrem(working_queue, 1, reply)
|
|
33
35
|
end
|
|
34
36
|
end
|
|
35
37
|
end
|
|
@@ -38,6 +40,6 @@ class ChunkedReliableQueue
|
|
|
38
40
|
private
|
|
39
41
|
|
|
40
42
|
def requeue_unfinished_work
|
|
41
|
-
loop while redis.
|
|
43
|
+
loop while redis.lmove(working_queue, queue, 'RIGHT', 'LEFT')
|
|
42
44
|
end
|
|
43
45
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
class ReliableQueue
|
|
2
4
|
include Enumerable
|
|
3
5
|
|
|
@@ -15,17 +17,17 @@ class ReliableQueue
|
|
|
15
17
|
return enum_for(:each) unless block_given?
|
|
16
18
|
|
|
17
19
|
loop do
|
|
18
|
-
reply = redis.
|
|
20
|
+
reply = redis.blmove(queue, working_queue, 'RIGHT', 'LEFT', timeout: 30)
|
|
19
21
|
next unless reply
|
|
20
22
|
|
|
21
23
|
yield reply
|
|
22
|
-
redis.lrem(working_queue,
|
|
24
|
+
redis.lrem(working_queue, 1, reply)
|
|
23
25
|
end
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
private
|
|
27
29
|
|
|
28
30
|
def requeue_unfinished_work
|
|
29
|
-
loop while redis.
|
|
31
|
+
loop while redis.lmove(working_queue, queue, 'RIGHT', 'LEFT')
|
|
30
32
|
end
|
|
31
33
|
end
|
|
@@ -2,7 +2,7 @@ require 'reliable_queue_rb/chunked_reliable_queue'
|
|
|
2
2
|
require 'redis'
|
|
3
3
|
|
|
4
4
|
RSpec.describe ChunkedReliableQueue do
|
|
5
|
-
let(:redis) { Redis.new }
|
|
5
|
+
let(:redis) { Redis.new(host: ENV['REDIS_HOST'] || '127.0.0.1', port: ENV['REDIS_PORT'] || 6379) }
|
|
6
6
|
|
|
7
7
|
after do
|
|
8
8
|
redis.flushall
|
data/spec/reliable_queue_spec.rb
CHANGED
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: reliable-queue-rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anna Klimas
|
|
8
8
|
- Jonathan Hernandez
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: redis
|
|
@@ -29,31 +28,44 @@ dependencies:
|
|
|
29
28
|
name: rake
|
|
30
29
|
requirement: !ruby/object:Gem::Requirement
|
|
31
30
|
requirements:
|
|
32
|
-
- - "
|
|
31
|
+
- - ">="
|
|
33
32
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: '
|
|
33
|
+
version: '0'
|
|
35
34
|
type: :development
|
|
36
35
|
prerelease: false
|
|
37
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
37
|
requirements:
|
|
39
|
-
- - "
|
|
38
|
+
- - ">="
|
|
40
39
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: '
|
|
40
|
+
version: '0'
|
|
42
41
|
- !ruby/object:Gem::Dependency
|
|
43
42
|
name: rspec
|
|
44
43
|
requirement: !ruby/object:Gem::Requirement
|
|
45
44
|
requirements:
|
|
46
|
-
- - "
|
|
45
|
+
- - ">="
|
|
47
46
|
- !ruby/object:Gem::Version
|
|
48
|
-
version: '
|
|
47
|
+
version: '0'
|
|
49
48
|
type: :development
|
|
50
49
|
prerelease: false
|
|
51
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
52
51
|
requirements:
|
|
53
|
-
- - "
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: house_style
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
54
67
|
- !ruby/object:Gem::Version
|
|
55
|
-
version: '
|
|
56
|
-
description:
|
|
68
|
+
version: '0'
|
|
57
69
|
email:
|
|
58
70
|
- support@altmetric.com
|
|
59
71
|
executables: []
|
|
@@ -63,7 +75,7 @@ files:
|
|
|
63
75
|
- CHANGELOG.md
|
|
64
76
|
- LICENSE.txt
|
|
65
77
|
- README.md
|
|
66
|
-
- lib/
|
|
78
|
+
- lib/reliable_queue_rb.rb
|
|
67
79
|
- lib/reliable_queue_rb/chunked_reliable_queue.rb
|
|
68
80
|
- lib/reliable_queue_rb/reliable_queue.rb
|
|
69
81
|
- spec/chunked_reliable_queue_spec.rb
|
|
@@ -72,7 +84,6 @@ homepage: https://github.com/altmetric/reliable-queue-rb
|
|
|
72
84
|
licenses:
|
|
73
85
|
- MIT
|
|
74
86
|
metadata: {}
|
|
75
|
-
post_install_message:
|
|
76
87
|
rdoc_options: []
|
|
77
88
|
require_paths:
|
|
78
89
|
- lib
|
|
@@ -87,8 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
87
98
|
- !ruby/object:Gem::Version
|
|
88
99
|
version: '0'
|
|
89
100
|
requirements: []
|
|
90
|
-
rubygems_version: 3.
|
|
91
|
-
signing_key:
|
|
101
|
+
rubygems_version: 3.6.9
|
|
92
102
|
specification_version: 4
|
|
93
103
|
summary: Ruby library for reliable queue processing.
|
|
94
104
|
test_files:
|
|
File without changes
|