Skip to content

Commit fb0f0bc

Browse files
Polishing.
Add new method to BoundStreamOperations and remove add accepting a Publisher. Original Pull Request: #2936
1 parent 486dc97 commit fb0f0bc

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

src/main/java/org/springframework/data/redis/connection/ReactiveStreamCommands.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ default Mono<RecordId> xAdd(ByteBufferRecord record) {
403403
* @param xAddOptions parameters for the {@literal XADD} call. Must not be {@literal null}.
404404
* @return {@link Mono} the {@link RecordId id}.
405405
* @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
406-
* @since 3.3
406+
* @since 3.4
407407
*/
408408
default Mono<RecordId> xAdd(ByteBufferRecord record, XAddOptions xAddOptions) {
409409

src/main/java/org/springframework/data/redis/core/BoundStreamOperations.java

+13
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.springframework.data.domain.Range;
2222
import org.springframework.data.redis.connection.Limit;
23+
import org.springframework.data.redis.connection.RedisStreamCommands.XAddOptions;
2324
import org.springframework.data.redis.connection.stream.Consumer;
2425
import org.springframework.data.redis.connection.stream.MapRecord;
2526
import org.springframework.data.redis.connection.stream.ReadOffset;
@@ -58,6 +59,18 @@ public interface BoundStreamOperations<K, HK, HV> {
5859
@Nullable
5960
RecordId add(Map<HK, HV> body);
6061

62+
/**
63+
* Append a record to the stream {@code key} with the specified options.
64+
*
65+
* @param content record content as Map.
66+
* @param xAddOptions additional parameters for the {@literal XADD} call.
67+
* @return the record Id. {@literal null} when used in pipeline / transaction.
68+
* @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
69+
* @since 3.4
70+
*/
71+
@Nullable
72+
RecordId add(Map<HK, HV> content, XAddOptions xAddOptions);
73+
6174
/**
6275
* Removes the specified entries from the stream. Returns the number of items deleted, that may be different from the
6376
* number of IDs passed in case certain IDs do not exist.

src/main/java/org/springframework/data/redis/core/ReactiveStreamOperations.java

+3-18
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,6 @@ default Mono<Long> acknowledge(String group, Record<K, ?> record) {
9696
return acknowledge(record.getRequiredStream(), group, record.getId());
9797
}
9898

99-
/**
100-
* Append one or more records to the stream {@code key} with the specified options.
101-
*
102-
* @param key the stream key.
103-
* @param bodyPublisher record body {@link Publisher}.
104-
* @param xAddOptions parameters for the {@literal XADD} call.
105-
* @return the record Ids.
106-
* @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
107-
* @since 3.3
108-
*/
109-
default Flux<RecordId> add (K key, Publisher<? extends Map<? extends HK, ? extends HV>> bodyPublisher,
110-
XAddOptions xAddOptions) {
111-
return Flux.from(bodyPublisher).flatMap(it -> add(key, it, xAddOptions));
112-
}
113-
11499
/**
115100
* Append a record to the stream {@code key} with the specified options.
116101
*
@@ -119,7 +104,7 @@ default Flux<RecordId> add (K key, Publisher<? extends Map<? extends HK, ? exten
119104
* @param xAddOptions parameters for the {@literal XADD} call.
120105
* @return the {@link Mono} emitting the {@link RecordId}.
121106
* @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
122-
* @since 3.3
107+
* @since 3.4
123108
*/
124109
default Mono<RecordId> add(K key, Map<? extends HK, ? extends HV> content, XAddOptions xAddOptions) {
125110
return add(StreamRecords.newRecord().in(key).ofMap(content), xAddOptions);
@@ -132,7 +117,7 @@ default Mono<RecordId> add(K key, Map<? extends HK, ? extends HV> content, XAddO
132117
* @param xAddOptions parameters for the {@literal XADD} call.
133118
* @return the {@link Mono} emitting the {@link RecordId}.
134119
* @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
135-
* @since 3.3
120+
* @since 3.4
136121
*/
137122
@SuppressWarnings("unchecked")
138123
default Mono<RecordId> add(MapRecord<K, ? extends HK, ? extends HV> record, XAddOptions xAddOptions) {
@@ -149,7 +134,7 @@ default Mono<RecordId> add(MapRecord<K, ? extends HK, ? extends HV> record, XAdd
149134
* @see MapRecord
150135
* @see ObjectRecord
151136
* @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
152-
* @since 3.3
137+
* @since 3.4
153138
*/
154139
Mono<RecordId> add(Record<K, ?> record, XAddOptions xAddOptions);
155140

src/main/java/org/springframework/data/redis/core/StreamOperations.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ default Long acknowledge(String group, Record<K, ?> record) {
105105
* @param xAddOptions additional parameters for the {@literal XADD} call.
106106
* @return the record Id. {@literal null} when used in pipeline / transaction.
107107
* @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
108-
* @since 3.3
108+
* @since 3.4
109109
*/
110110
@SuppressWarnings("unchecked")
111111
@Nullable
@@ -120,7 +120,7 @@ default RecordId add(K key, Map<? extends HK, ? extends HV> content, XAddOptions
120120
* @param xAddOptions additional parameters for the {@literal XADD} call.
121121
* @return the record Id. {@literal null} when used in pipeline / transaction.
122122
* @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
123-
* @since 3.3
123+
* @since 3.4
124124
*/
125125
@SuppressWarnings("unchecked")
126126
@Nullable
@@ -138,7 +138,7 @@ default RecordId add(MapRecord<K, ? extends HK, ? extends HV> record, XAddOption
138138
* @see MapRecord
139139
* @see ObjectRecord
140140
* @see <a href="https://redis.io/commands/xadd">Redis Documentation: XADD</a>
141-
* @since 3.3
141+
* @since 3.4
142142
*/
143143
@SuppressWarnings("unchecked")
144144
@Nullable

0 commit comments

Comments
 (0)