redstream 0.4.3 → 0.4.4
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 +3 -0
- data/lib/redstream/producer.rb +7 -9
- data/lib/redstream/version.rb +1 -1
- data/redstream.gemspec +0 -1
- data/spec/redstream/producer_spec.rb +0 -25
- metadata +3 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e25cd9c9c13d7fe93e81207a7608599e37c72a39425b54108c7178b3e97917f3
|
4
|
+
data.tar.gz: 5a5179bf6de8ef24effa908595a32bbcccd9c5c717988ce25a0f38aa128b6cab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adee0c463fb89d9f112b3bc374c25fcb7fe60819f18952133df3afe789bcbabca5fcc184d144b5dff8db747098b2c8953cb440be474d6dd1df4ed004fd1e6467
|
7
|
+
data.tar.gz: 430b4df8d3095e9375320f9fbfa83aa24615bf2d6b19c2deba663fb69db3806a664dddd83c3f98f5f26b28c8de603f69d8ed926943043be905771d16595dc10e
|
data/CHANGELOG.md
CHANGED
data/lib/redstream/producer.rb
CHANGED
@@ -52,11 +52,11 @@ module Redstream
|
|
52
52
|
def bulk(records)
|
53
53
|
records_array = Array(records)
|
54
54
|
|
55
|
-
|
55
|
+
bulk_delay(records_array)
|
56
56
|
|
57
57
|
yield
|
58
58
|
|
59
|
-
bulk_queue(records_array
|
59
|
+
bulk_queue(records_array)
|
60
60
|
end
|
61
61
|
|
62
62
|
# @api private
|
@@ -68,7 +68,7 @@ module Redstream
|
|
68
68
|
# @return The redis message ids
|
69
69
|
|
70
70
|
def bulk_delay(records)
|
71
|
-
|
71
|
+
records.each_slice(250) do |slice|
|
72
72
|
Redstream.connection_pool.with do |redis|
|
73
73
|
redis.pipelined do |pipeline|
|
74
74
|
slice.each do |object|
|
@@ -82,7 +82,7 @@ module Redstream
|
|
82
82
|
redis.wait(@wait, 0) if @wait
|
83
83
|
end
|
84
84
|
|
85
|
-
|
85
|
+
true
|
86
86
|
end
|
87
87
|
|
88
88
|
# @api private
|
@@ -90,15 +90,13 @@ module Redstream
|
|
90
90
|
# Writes messages to a stream in redis for immediate retrieval.
|
91
91
|
#
|
92
92
|
# @param records [#to_a] The object/objects that will be updated deleted
|
93
|
-
# @param delay_message_ids [#to_a] The delay message ids to delete
|
94
93
|
|
95
|
-
def bulk_queue(records
|
96
|
-
records.
|
94
|
+
def bulk_queue(records)
|
95
|
+
records.each_slice(250) do |slice|
|
97
96
|
Redstream.connection_pool.with do |redis|
|
98
97
|
redis.pipelined do |pipeline|
|
99
|
-
slice.each do |object
|
98
|
+
slice.each do |object|
|
100
99
|
pipeline.xadd(Redstream.stream_key_name(stream_name(object)), { payload: JSON.dump(object.redstream_payload) })
|
101
|
-
pipeline.xdel(Redstream.stream_key_name("#{stream_name(object)}.delay"), delay_message_ids[index]) if delay_message_ids
|
102
100
|
end
|
103
101
|
end
|
104
102
|
end
|
data/lib/redstream/version.rb
CHANGED
data/redstream.gemspec
CHANGED
@@ -14,7 +14,6 @@ Gem::Specification.new do |spec|
|
|
14
14
|
|
15
15
|
spec.files = `git ls-files -z`.split("\x0")
|
16
16
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
17
|
spec.require_paths = ["lib"]
|
19
18
|
|
20
19
|
spec.add_development_dependency "activerecord"
|
@@ -78,19 +78,6 @@ RSpec.describe Redstream::Producer do
|
|
78
78
|
{ "payload" => JSON.dump(products[1].redstream_payload) }
|
79
79
|
])
|
80
80
|
end
|
81
|
-
|
82
|
-
it "deletes the delay messages after the queue messages have been sent" do
|
83
|
-
products = create_list(:product, 2)
|
84
|
-
producer = Redstream::Producer.new
|
85
|
-
|
86
|
-
other_delay_message_id = producer.delay(create(:product))
|
87
|
-
|
88
|
-
producer.bulk(products) do
|
89
|
-
expect(redis.xlen(Redstream.stream_key_name("products.delay"))).to eq(3)
|
90
|
-
end
|
91
|
-
|
92
|
-
expect(redis.xrange(Redstream.stream_key_name("products.delay"), "-", "+").map(&:first)).to eq([other_delay_message_id])
|
93
|
-
end
|
94
81
|
end
|
95
82
|
|
96
83
|
describe "#bulk_queue" do
|
@@ -108,18 +95,6 @@ RSpec.describe Redstream::Producer do
|
|
108
95
|
{ "payload" => JSON.dump(products[1].redstream_payload) }
|
109
96
|
])
|
110
97
|
end
|
111
|
-
|
112
|
-
it "deletes the delay messages after the queue messages have been sent" do
|
113
|
-
products = create_list(:product, 2)
|
114
|
-
producer = Redstream::Producer.new
|
115
|
-
|
116
|
-
delay_message_ids = producer.bulk_delay(products)
|
117
|
-
other_delay_message_id = producer.delay(create(:product))
|
118
|
-
|
119
|
-
producer.bulk_queue(products, delay_message_ids: delay_message_ids)
|
120
|
-
|
121
|
-
expect(redis.xrange(Redstream.stream_key_name("products.delay"), "-", "+").map(&:first)).to eq([other_delay_message_id])
|
122
|
-
end
|
123
98
|
end
|
124
99
|
|
125
100
|
describe "#bulk_delay" do
|
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.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Vetter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -294,12 +294,4 @@ signing_key:
|
|
294
294
|
specification_version: 4
|
295
295
|
summary: Using redis streams to keep your primary database in sync with secondary
|
296
296
|
datastores
|
297
|
-
test_files:
|
298
|
-
- spec/redstream/consumer_spec.rb
|
299
|
-
- spec/redstream/delayer_spec.rb
|
300
|
-
- spec/redstream/lock_spec.rb
|
301
|
-
- spec/redstream/model_spec.rb
|
302
|
-
- spec/redstream/producer_spec.rb
|
303
|
-
- spec/redstream/trimmer_spec.rb
|
304
|
-
- spec/redstream_spec.rb
|
305
|
-
- spec/spec_helper.rb
|
297
|
+
test_files: []
|