DATAREDIS-1226 - Add support for xClaimJustId using Lettuce.
Original Pull Request: #567
This commit is contained in:
committed by
Christoph Strobl
parent
0279c25b50
commit
d2dce680cc
@@ -229,6 +229,7 @@ public interface RedisStreamCommands {
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Dengliming
|
||||
* @since 2.3
|
||||
*/
|
||||
class XClaimOptions {
|
||||
@@ -239,9 +240,10 @@ public interface RedisStreamCommands {
|
||||
private final @Nullable Instant unixTime;
|
||||
private final @Nullable Long retryCount;
|
||||
private final boolean force;
|
||||
private final boolean justId;
|
||||
|
||||
private XClaimOptions(List<RecordId> ids, Duration minIdleTime, @Nullable Duration idleTime,
|
||||
@Nullable Instant unixTime, @Nullable Long retryCount, boolean force) {
|
||||
@Nullable Instant unixTime, @Nullable Long retryCount, boolean force, boolean justId) {
|
||||
|
||||
this.ids = new ArrayList<>(ids);
|
||||
this.minIdleTime = minIdleTime;
|
||||
@@ -249,6 +251,7 @@ public interface RedisStreamCommands {
|
||||
this.unixTime = unixTime;
|
||||
this.retryCount = retryCount;
|
||||
this.force = force;
|
||||
this.justId = justId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -281,7 +284,7 @@ public interface RedisStreamCommands {
|
||||
* @return {@code this}.
|
||||
*/
|
||||
public XClaimOptions idle(Duration idleTime) {
|
||||
return new XClaimOptions(ids, minIdleTime, idleTime, unixTime, retryCount, force);
|
||||
return new XClaimOptions(ids, minIdleTime, idleTime, unixTime, retryCount, force, justId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -292,7 +295,7 @@ public interface RedisStreamCommands {
|
||||
* @return {@code this}.
|
||||
*/
|
||||
public XClaimOptions time(Instant unixTime) {
|
||||
return new XClaimOptions(ids, minIdleTime, idleTime, unixTime, retryCount, force);
|
||||
return new XClaimOptions(ids, minIdleTime, idleTime, unixTime, retryCount, force, justId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -302,7 +305,7 @@ public interface RedisStreamCommands {
|
||||
* @return new instance of {@link XClaimOptions}.
|
||||
*/
|
||||
public XClaimOptions retryCount(long retryCount) {
|
||||
return new XClaimOptions(ids, minIdleTime, idleTime, unixTime, retryCount, force);
|
||||
return new XClaimOptions(ids, minIdleTime, idleTime, unixTime, retryCount, force, justId);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,7 +315,16 @@ public interface RedisStreamCommands {
|
||||
* @return new instance of {@link XClaimOptions}.
|
||||
*/
|
||||
public XClaimOptions force() {
|
||||
return new XClaimOptions(ids, minIdleTime, idleTime, unixTime, retryCount, true);
|
||||
return new XClaimOptions(ids, minIdleTime, idleTime, unixTime, retryCount, true, justId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the JUSTID flag.
|
||||
*
|
||||
* @return new instance of {@link XClaimOptions}.
|
||||
*/
|
||||
public XClaimOptions justId() {
|
||||
return new XClaimOptions(ids, minIdleTime, idleTime, unixTime, retryCount, force, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -381,6 +393,15 @@ public interface RedisStreamCommands {
|
||||
return force;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the JUSTID flag.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isJustId() {
|
||||
return justId;
|
||||
}
|
||||
|
||||
public static class XClaimOptionsBuilder {
|
||||
|
||||
private final Duration minIdleTime;
|
||||
@@ -404,7 +425,7 @@ public interface RedisStreamCommands {
|
||||
.map(it -> it instanceof RecordId ? (RecordId) it : RecordId.of(it.toString()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return new XClaimOptions(idList, minIdleTime, null, null, null, false);
|
||||
return new XClaimOptions(idList, minIdleTime, null, null, null, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -123,10 +123,6 @@ class LettuceReactiveStreamCommands implements ReactiveStreamCommands {
|
||||
@Override
|
||||
public Flux<CommandResponse<XClaimCommand, Flux<RecordId>>> xClaimJustId(Publisher<XClaimCommand> commands) {
|
||||
|
||||
if (true /* TODO: set the JUSTID flag */ ) {
|
||||
throw new UnsupportedOperationException("Lettuce does not support XCLAIM with JUSTID. (Ref: lettuce-io#1233)");
|
||||
}
|
||||
|
||||
return connection.execute(cmd -> Flux.from(commands).map(command -> {
|
||||
|
||||
String[] ids = command.getOptions().getIdsAsStringArray();
|
||||
|
||||
@@ -49,6 +49,7 @@ import org.springframework.util.Assert;
|
||||
* @author Mark Paluch
|
||||
* @author Tugdual Grall
|
||||
* @author Dejan Jankov
|
||||
* @author Dengliming
|
||||
* @since 2.2
|
||||
*/
|
||||
class LettuceStreamCommands implements RedisStreamCommands {
|
||||
@@ -136,10 +137,6 @@ class LettuceStreamCommands implements RedisStreamCommands {
|
||||
LettuceConverters.toBytes(newOwner));
|
||||
XClaimArgs args = StreamConverters.toXClaimArgs(options);
|
||||
|
||||
if (true /* TODO: set the JUSTID flag */ ) {
|
||||
throw new UnsupportedOperationException("Lettuce does not support XCLAIM with JUSTID. (Ref: lettuce-io#1233)");
|
||||
}
|
||||
|
||||
try {
|
||||
if (isPipelined()) {
|
||||
|
||||
|
||||
@@ -236,7 +236,9 @@ class StreamConverters {
|
||||
if (source.getUnixTime() != null) {
|
||||
args.time(source.getUnixTime());
|
||||
}
|
||||
|
||||
if (source.isJustId()) {
|
||||
args.justid();
|
||||
}
|
||||
return args;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user