redstream 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/redstream/producer.rb +4 -2
- data/lib/redstream/version.rb +1 -1
- data/spec/redstream/producer_spec.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 160386bd218415c11c556b1cdfc8824ed347e7279fac67f390c07b37c7128eff
|
4
|
+
data.tar.gz: '087e4ecaee15bd2f9db4367f53297a72f01c8de1cc093ae25ff3d4eb8ae29b90'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4d0945a2d2cb4b38dd398e5368963b5c8ba63aa93bc065bcb0c78a0e6bd7d2c0a7f825dd76b7b1d0ff79b6874bf1c3d0cb8f29843977d7676d341cfa584ed5d
|
7
|
+
data.tar.gz: b53bc33ce21244d64307b22f98185367e7c5806aeed9e50ed2b9dd123278b19236a049042bde26870dacd99702df49966674d1c629bf73ad955ff176f3f25a7b
|
data/CHANGELOG.md
CHANGED
data/lib/redstream/producer.rb
CHANGED
@@ -90,8 +90,9 @@ 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
|
93
94
|
|
94
|
-
def bulk_queue(records, delay_message_ids:)
|
95
|
+
def bulk_queue(records, delay_message_ids: nil)
|
95
96
|
records.each_with_index.each_slice(250) do |slice|
|
96
97
|
Redstream.connection_pool.with do |redis|
|
97
98
|
redis.pipelined do
|
@@ -127,8 +128,9 @@ module Redstream
|
|
127
128
|
# Writes a single message to a stream in redis for immediate retrieval.
|
128
129
|
#
|
129
130
|
# @param object The object hat will be updated, deleted, etc.
|
131
|
+
# @param delay_message_id The delay message id to delete
|
130
132
|
|
131
|
-
def queue(object, delay_message_id:)
|
133
|
+
def queue(object, delay_message_id: nil)
|
132
134
|
Redstream.connection_pool.with do |redis|
|
133
135
|
redis.pipelined do
|
134
136
|
redis.xadd(Redstream.stream_key_name(stream_name(object)), payload: JSON.dump(object.redstream_payload))
|
data/lib/redstream/version.rb
CHANGED
@@ -7,7 +7,7 @@ RSpec.describe Redstream::Producer do
|
|
7
7
|
|
8
8
|
stream_key_name = Redstream.stream_key_name("products")
|
9
9
|
|
10
|
-
expect { Redstream::Producer.new.queue(product
|
10
|
+
expect { Redstream::Producer.new.queue(product) }.to change { redis.xlen(stream_key_name) }.by(1)
|
11
11
|
expect(redis.xrange(stream_key_name, "-", "+").last[1]).to eq("payload" => JSON.dump(product.redstream_payload))
|
12
12
|
end
|
13
13
|
|
@@ -99,7 +99,7 @@ RSpec.describe Redstream::Producer do
|
|
99
99
|
|
100
100
|
stream_key_name = Redstream.stream_key_name("products")
|
101
101
|
|
102
|
-
expect { Redstream::Producer.new.bulk_queue(Product.all
|
102
|
+
expect { Redstream::Producer.new.bulk_queue(Product.all) }.to change { redis.xlen(stream_key_name) }.by(2)
|
103
103
|
|
104
104
|
messages = redis.xrange(stream_key_name, "-", "+").last(2).map { |message| message[1] }
|
105
105
|
|