reliable-queue-rb 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c4a9e5e6155832ba302d8d0e4df11229995e87ee08d5deca4f768a1428b2900
4
- data.tar.gz: c8ac07e23b3e3c6fa228944177f20be38ee59224538dd59a31a3d85ae4af1bf8
3
+ metadata.gz: f60d11205a995de4132cef78a505e1a15c5006988f7c139f96b340cfc23afe09
4
+ data.tar.gz: e917c4e98b0add02db56d7579a67e163db7f4bc512b473b64a91d0c30423f020
5
5
  SHA512:
6
- metadata.gz: 5f6e292bc67d7107c6741abe705edf1580ba0fdde704b24777965f687e6875b96398078c10fc7f2ea20f21922630f35c0bfdb1086f7a5b89a37820fe93be497d
7
- data.tar.gz: 4faa7e3f5b701111cc780af12e371d9222a76843e125bc4a95b5f7a2b954329980ffbad7917ca7bfb32204c4073c70b02d4ebe36b80776e56c524543001e0692
6
+ metadata.gz: 772dbd35b2a2b3269d4ac3a03a165adb670364f08addd922aa0470288a0a193c207aa34b8a8feaef4b40c039aa667ac61f03ce9048cd745fd927eb42ee4cc949
7
+ data.tar.gz: c9e8fd7d693cef08dcd67296808cd8b93f55482097f216f0206da5e865cffad55014098dcf8ef96432c8cd0ae1781f8b1d5adc0f5fc76e7e69c220664c8eadc1
data/CHANGELOG.md CHANGED
@@ -1,15 +1,39 @@
1
1
  # Change Log
2
+
2
3
  All notable changes to this project will be documented in this file. This
3
4
  project adheres to [Semantic Versioning](http://semver.org/).
4
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
+
16
+ ## [0.4.0] - 2023-11-10
17
+
18
+ ### Changed
19
+
20
+ - Minimum required Redis client version bumped to 5.0+
21
+ - Updated the code to support the current Redis API
22
+
5
23
  ## [0.3.0] - 2021-09-09
24
+
6
25
  ### Changed
26
+
7
27
  - Upgrade redis
8
28
 
9
29
  ## [0.2.0] - 2020-12-16
30
+
10
31
  ### Changed
32
+
11
33
  - A single require for both classes
12
34
 
13
35
  ## [0.1.0] - 2020-12-14
36
+
14
37
  ### Added
38
+
15
39
  - Initial release
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020-2021 Altmetric LLP
3
+ Copyright (c) 2020-2024 Altmetric LLP
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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`:
@@ -12,14 +16,20 @@ gem 'reliable-queue-rb', '~> 0.3.0'
12
16
 
13
17
  And then execute:
14
18
 
15
- $ bundle
19
+ ```sh
20
+ bundle
21
+ ```
16
22
 
17
23
  Or install it yourself as:
18
24
 
19
- $ gem install reliable-queue-rb
25
+ ```sh
26
+ gem install reliable-queue-rb
27
+ ```
20
28
 
21
29
  ## Usage
30
+
22
31
  Reliable Queue
32
+
23
33
  ```ruby
24
34
  queue = ReliableQueue.new(redis_queue, redis_client)
25
35
 
@@ -29,6 +39,7 @@ end
29
39
  ```
30
40
 
31
41
  ChunkedReliableQueue
42
+
32
43
  ```ruby
33
44
  queue = ChunkedReliableQueue.new(working_on_queue_suffix, redis_queue, redis_client)
34
45
 
@@ -39,10 +50,10 @@ end
39
50
 
40
51
  ## Contributing
41
52
 
42
- Bug reports and pull requests are welcome on GitHub at https://github.com/altmetric/reliable-queue-rb.
53
+ Bug reports and pull requests are welcome on GitHub at <https://github.com/altmetric/reliable-queue-rb>.
43
54
 
44
55
  ## License
45
56
 
46
- Copyright © 2020-2021 Altmetric LLP
57
+ Copyright © 2020-2024 Altmetric LLP
47
58
 
48
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, :size, :working_queue, :redis
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.brpoplpush(queue, working_queue, 30)
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.rpoplpush(queue, working_queue)
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, 0, reply)
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.rpoplpush(working_queue, queue)
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.brpoplpush(queue, working_queue, 30)
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, 0, reply)
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.rpoplpush(working_queue, queue)
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
@@ -2,7 +2,7 @@ require 'reliable_queue_rb/reliable_queue'
2
2
  require 'redis'
3
3
 
4
4
  RSpec.describe ReliableQueue 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.del('foo')
metadata CHANGED
@@ -1,24 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reliable-queue-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.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: 2021-09-09 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: redis
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - ">="
19
- - !ruby/object:Gem::Version
20
- version: 3.0.0
21
- - - "<"
22
18
  - !ruby/object:Gem::Version
23
19
  version: 5.0.0
24
20
  type: :runtime
@@ -26,40 +22,50 @@ dependencies:
26
22
  version_requirements: !ruby/object:Gem::Requirement
27
23
  requirements:
28
24
  - - ">="
29
- - !ruby/object:Gem::Version
30
- version: 3.0.0
31
- - - "<"
32
25
  - !ruby/object:Gem::Version
33
26
  version: 5.0.0
34
27
  - !ruby/object:Gem::Dependency
35
28
  name: rake
36
29
  requirement: !ruby/object:Gem::Requirement
37
30
  requirements:
38
- - - "~>"
31
+ - - ">="
39
32
  - !ruby/object:Gem::Version
40
- version: '10.0'
33
+ version: '0'
41
34
  type: :development
42
35
  prerelease: false
43
36
  version_requirements: !ruby/object:Gem::Requirement
44
37
  requirements:
45
- - - "~>"
38
+ - - ">="
46
39
  - !ruby/object:Gem::Version
47
- version: '10.0'
40
+ version: '0'
48
41
  - !ruby/object:Gem::Dependency
49
42
  name: rspec
50
43
  requirement: !ruby/object:Gem::Requirement
51
44
  requirements:
52
- - - "~>"
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
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
+ - - ">="
53
60
  - !ruby/object:Gem::Version
54
- version: '3.10'
61
+ version: '0'
55
62
  type: :development
56
63
  prerelease: false
57
64
  version_requirements: !ruby/object:Gem::Requirement
58
65
  requirements:
59
- - - "~>"
66
+ - - ">="
60
67
  - !ruby/object:Gem::Version
61
- version: '3.10'
62
- description:
68
+ version: '0'
63
69
  email:
64
70
  - support@altmetric.com
65
71
  executables: []
@@ -69,7 +75,7 @@ files:
69
75
  - CHANGELOG.md
70
76
  - LICENSE.txt
71
77
  - README.md
72
- - lib/reliable-queue-rb.rb
78
+ - lib/reliable_queue_rb.rb
73
79
  - lib/reliable_queue_rb/chunked_reliable_queue.rb
74
80
  - lib/reliable_queue_rb/reliable_queue.rb
75
81
  - spec/chunked_reliable_queue_spec.rb
@@ -78,7 +84,6 @@ homepage: https://github.com/altmetric/reliable-queue-rb
78
84
  licenses:
79
85
  - MIT
80
86
  metadata: {}
81
- post_install_message:
82
87
  rdoc_options: []
83
88
  require_paths:
84
89
  - lib
@@ -86,17 +91,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
91
  requirements:
87
92
  - - ">="
88
93
  - !ruby/object:Gem::Version
89
- version: '0'
94
+ version: 2.7.0
90
95
  required_rubygems_version: !ruby/object:Gem::Requirement
91
96
  requirements:
92
97
  - - ">="
93
98
  - !ruby/object:Gem::Version
94
99
  version: '0'
95
100
  requirements: []
96
- rubygems_version: 3.0.9
97
- signing_key:
101
+ rubygems_version: 3.6.9
98
102
  specification_version: 4
99
103
  summary: Ruby library for reliable queue processing.
100
104
  test_files:
101
- - spec/reliable_queue_spec.rb
102
105
  - spec/chunked_reliable_queue_spec.rb
106
+ - spec/reliable_queue_spec.rb
File without changes