redstream 0.4.0 → 0.4.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: 160386bd218415c11c556b1cdfc8824ed347e7279fac67f390c07b37c7128eff
4
- data.tar.gz: '087e4ecaee15bd2f9db4367f53297a72f01c8de1cc093ae25ff3d4eb8ae29b90'
3
+ metadata.gz: cb01602a9b0e51f896989d59b5e2b16f333c7ea0317f31c5235696bc49145013
4
+ data.tar.gz: 747f63e94c847be8d371e60098f9348f30531587b821ac019c873c10d51dd766
5
5
  SHA512:
6
- metadata.gz: d4d0945a2d2cb4b38dd398e5368963b5c8ba63aa93bc065bcb0c78a0e6bd7d2c0a7f825dd76b7b1d0ff79b6874bf1c3d0cb8f29843977d7676d341cfa584ed5d
7
- data.tar.gz: b53bc33ce21244d64307b22f98185367e7c5806aeed9e50ed2b9dd123278b19236a049042bde26870dacd99702df49966674d1c629bf73ad955ff176f3f25a7b
6
+ metadata.gz: 19541261544b2d32168b8e290e402b5c9dedcf54868dee1dbb556bfa5cacf41a091fbff391605a734a6c1bf5eeaf6b33127660b190245166e1340a777c5e433d
7
+ data.tar.gz: 74426b36ca249b2da61f436f195d6811245038835492321009d063f78226cfdc7e099a4e17fe9910588ebc3f9bc6e21bec8e600959e0e5f8c2e77425ccda7023
@@ -5,7 +5,7 @@ jobs:
5
5
  runs-on: ubuntu-latest
6
6
  strategy:
7
7
  matrix:
8
- ruby: ['2.5', '2.6', '2.7']
8
+ ruby: ['2.5', '2.6', '2.7', '3.0']
9
9
  services:
10
10
  redis:
11
11
  image: redis
data/.rubocop.yml CHANGED
@@ -1,6 +1,9 @@
1
1
  AllCops:
2
2
  NewCops: enable
3
3
 
4
+ Gemspec/RequireMFA:
5
+ Enabled: false
6
+
4
7
  Lint/AssignmentInCondition:
5
8
  Enabled: false
6
9
 
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v0.4.1
4
+ * Fix keyword argument usage of redis 4.5.1 in ruby 3
5
+
3
6
  ## v0.4.0
4
7
  * Make delay message id params in queue methods optional
5
8
 
@@ -48,7 +48,7 @@ module Redstream
48
48
  def run_once
49
49
  @consumer.run_once do |messages|
50
50
  messages.each do |message|
51
- seconds_to_sleep = message.message_id.to_f / 1_000 + @delay.to_f - Time.now.to_f
51
+ seconds_to_sleep = (message.message_id.to_f / 1_000) + @delay.to_f - Time.now.to_f
52
52
 
53
53
  if seconds_to_sleep > 0
54
54
  if @batch.size > 0
@@ -85,11 +85,11 @@ module Redstream
85
85
  Redstream.connection_pool.with do |redis|
86
86
  redis.pipelined do
87
87
  @batch.each do |message|
88
- redis.xadd Redstream.stream_key_name(@stream_name), payload: message.fields["payload"]
88
+ redis.xadd(Redstream.stream_key_name(@stream_name), { payload: message.fields["payload"] })
89
89
  end
90
90
  end
91
91
 
92
- redis.xdel Redstream.stream_key_name("#{@stream_name}.delay"), @batch.map(&:message_id)
92
+ redis.xdel(Redstream.stream_key_name("#{@stream_name}.delay"), @batch.map(&:message_id))
93
93
  end
94
94
 
95
95
  @batch = []
@@ -72,7 +72,7 @@ module Redstream
72
72
  Redstream.connection_pool.with do |redis|
73
73
  redis.pipelined do
74
74
  slice.each do |object|
75
- redis.xadd(Redstream.stream_key_name("#{stream_name(object)}.delay"), payload: JSON.dump(object.redstream_payload))
75
+ redis.xadd(Redstream.stream_key_name("#{stream_name(object)}.delay"), { payload: JSON.dump(object.redstream_payload) })
76
76
  end
77
77
  end
78
78
  end
@@ -97,7 +97,7 @@ module Redstream
97
97
  Redstream.connection_pool.with do |redis|
98
98
  redis.pipelined do
99
99
  slice.each do |object, index|
100
- redis.xadd(Redstream.stream_key_name(stream_name(object)), payload: JSON.dump(object.redstream_payload))
100
+ redis.xadd(Redstream.stream_key_name(stream_name(object)), { payload: JSON.dump(object.redstream_payload) })
101
101
  redis.xdel(Redstream.stream_key_name("#{stream_name(object)}.delay"), delay_message_ids[index]) if delay_message_ids
102
102
  end
103
103
  end
@@ -117,7 +117,7 @@ module Redstream
117
117
 
118
118
  def delay(object)
119
119
  Redstream.connection_pool.with do |redis|
120
- res = redis.xadd(Redstream.stream_key_name("#{stream_name(object)}.delay"), payload: JSON.dump(object.redstream_payload))
120
+ res = redis.xadd(Redstream.stream_key_name("#{stream_name(object)}.delay"), { payload: JSON.dump(object.redstream_payload) })
121
121
  redis.wait(@wait, 0) if @wait
122
122
  res
123
123
  end
@@ -133,7 +133,7 @@ module Redstream
133
133
  def queue(object, delay_message_id: nil)
134
134
  Redstream.connection_pool.with do |redis|
135
135
  redis.pipelined do
136
- redis.xadd(Redstream.stream_key_name(stream_name(object)), payload: JSON.dump(object.redstream_payload))
136
+ redis.xadd(Redstream.stream_key_name(stream_name(object)), { payload: JSON.dump(object.redstream_payload) })
137
137
  redis.xdel(Redstream.stream_key_name("#{stream_name(object)}.delay"), delay_message_id) if delay_message_id
138
138
  end
139
139
  end
@@ -1,3 +1,3 @@
1
1
  module Redstream
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -3,7 +3,7 @@ require File.expand_path("../spec_helper", __dir__)
3
3
  RSpec.describe Redstream::Delayer do
4
4
  describe "#run_once" do
5
5
  it "copies expired messages to their target streams" do
6
- redis.xadd Redstream.stream_key_name("target.delay"), payload: JSON.dump(value: "message")
6
+ redis.xadd(Redstream.stream_key_name("target.delay"), { payload: JSON.dump(value: "message") })
7
7
 
8
8
  expect(redis.xlen(Redstream.stream_key_name("target"))).to eq(0)
9
9
 
@@ -14,9 +14,9 @@ RSpec.describe Redstream::Delayer do
14
14
  end
15
15
 
16
16
  it "delivers and commit before falling asleep" do
17
- redis.xadd Redstream.stream_key_name("target.delay"), payload: JSON.dump(value: "message")
17
+ redis.xadd(Redstream.stream_key_name("target.delay"), { payload: JSON.dump(value: "message") })
18
18
  sleep 3
19
- redis.xadd Redstream.stream_key_name("target.delay"), payload: JSON.dump(value: "message")
19
+ redis.xadd(Redstream.stream_key_name("target.delay"), { payload: JSON.dump(value: "message") })
20
20
 
21
21
  thread = Thread.new do
22
22
  Redstream::Delayer.new(stream_name: "target", delay: 1).run_once
@@ -33,7 +33,7 @@ RSpec.describe Redstream::Delayer do
33
33
  end
34
34
 
35
35
  it "does not copy not yet expired messages" do
36
- redis.xadd Redstream.stream_key_name("target.delay"), payload: JSON.dump(value: "message")
36
+ redis.xadd(Redstream.stream_key_name("target.delay"), { payload: JSON.dump(value: "message") })
37
37
 
38
38
  thread = Thread.new do
39
39
  Redstream::Delayer.new(stream_name: "target", delay: 2).run_once
@@ -4,11 +4,11 @@ RSpec.describe Redstream::Trimmer do
4
4
  describe "#run_once" do
5
5
  it "trims a stream to the minimum committed id" do
6
6
  ids = Array.new(4) do |i|
7
- redis.xadd Redstream.stream_key_name("default"), payload: JSON.dump(value: "message#{i}")
7
+ redis.xadd(Redstream.stream_key_name("default"), { payload: JSON.dump(value: "message#{i}") })
8
8
  end
9
9
 
10
- redis.set Redstream.offset_key_name(stream_name: "default", consumer_name: "consumer1"), ids[1]
11
- redis.set Redstream.offset_key_name(stream_name: "default", consumer_name: "consumer2"), ids[2]
10
+ redis.set(Redstream.offset_key_name(stream_name: "default", consumer_name: "consumer1"), ids[1])
11
+ redis.set(Redstream.offset_key_name(stream_name: "default", consumer_name: "consumer2"), ids[2])
12
12
 
13
13
  trimmer = Redstream::Trimmer.new(
14
14
  interval: 5,
@@ -34,7 +34,7 @@ RSpec.describe Redstream do
34
34
  it "returns the stream's size" do
35
35
  expect(Redstream.stream_size("products")).to eq(0)
36
36
 
37
- redis.xadd("redstream:stream:products", key: "value")
37
+ redis.xadd("redstream:stream:products", { key: "value" })
38
38
 
39
39
  expect(Redstream.stream_size("products")).to eq(1)
40
40
  end
@@ -44,8 +44,8 @@ RSpec.describe Redstream do
44
44
  it "returns the stream's max id" do
45
45
  expect(Redstream.max_stream_id("products")).to be_nil
46
46
 
47
- _id1 = redis.xadd("redstream:stream:products", key: "value")
48
- id2 = redis.xadd("redstream:stream:products", key: "value")
47
+ _id1 = redis.xadd("redstream:stream:products", { key: "value" })
48
+ id2 = redis.xadd("redstream:stream:products", { key: "value" })
49
49
 
50
50
  expect(Redstream.max_stream_id("products")).to eq(id2)
51
51
  end
@@ -55,8 +55,8 @@ RSpec.describe Redstream do
55
55
  it "returns the consumer's max id" do
56
56
  expect(Redstream.max_consumer_id(stream_name: "products", consumer_name: "consumer")).to be_nil
57
57
 
58
- _id1 = redis.xadd("redstream:stream:products", key: "value")
59
- id2 = redis.xadd("redstream:stream:products", key: "value")
58
+ _id1 = redis.xadd("redstream:stream:products", { key: "value" })
59
+ id2 = redis.xadd("redstream:stream:products", { key: "value" })
60
60
 
61
61
  Redstream::Consumer.new(name: "consumer", stream_name: "products").run_once do |messages|
62
62
  # nothing
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redstream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benjamin Vetter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-26 00:00:00.000000000 Z
11
+ date: 2021-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -289,7 +289,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
289
289
  - !ruby/object:Gem::Version
290
290
  version: '0'
291
291
  requirements: []
292
- rubygems_version: 3.0.3
292
+ rubygems_version: 3.2.15
293
293
  signing_key:
294
294
  specification_version: 4
295
295
  summary: Using redis streams to keep your primary database in sync with secondary