DATAREDIS-711 - Emit Lua array responses as List.
We now emit array responses from Lua script execution as complete List instead of emitting the individual elements through the Publisher. Lua scripts may return nil (null) elements that would be not emitted through a Publisher. Skipping null values would garble up the response – and in several cases, the response array is required as List. Emitting the whole List aligns the response to the signatures imposed by generics and aligns the behavior with the imperative API. Original Pull Request: #282
This commit is contained in:
committed by
Christoph Strobl
parent
8adea79e67
commit
ebc0c5e0b4
@@ -82,7 +82,8 @@ public interface ReactiveScriptingCommands {
|
||||
* Evaluate given {@code script}.
|
||||
*
|
||||
* @param script must not be {@literal null}.
|
||||
* @param returnType must not be {@literal null}.
|
||||
* @param returnType must not be {@literal null}. Using {@link ReturnType#MULTI} emits a {@link List} as-is instead of
|
||||
* emitting the individual elements from the array response.
|
||||
* @param numKeys
|
||||
* @param keysAndArgs must not be {@literal null}.
|
||||
* @return never {@literal null}.
|
||||
@@ -94,7 +95,8 @@ public interface ReactiveScriptingCommands {
|
||||
* Evaluate given {@code scriptSha}.
|
||||
*
|
||||
* @param scriptSha must not be {@literal null}.
|
||||
* @param returnType must not be {@literal null}.
|
||||
* @param returnType must not be {@literal null}. Using {@link ReturnType#MULTI} emits a {@link List} as-is instead of
|
||||
* emitting the individual elements from the array response.
|
||||
* @param numKeys
|
||||
* @param keysAndArgs must not be {@literal null}.
|
||||
* @return never {@literal null}.
|
||||
|
||||
@@ -141,8 +141,6 @@ class LettuceReactiveScriptingCommands implements ReactiveScriptingCommands {
|
||||
if (returnType == ReturnType.MULTI) {
|
||||
|
||||
return eval.flatMap(t -> {
|
||||
return t instanceof Iterable ? Flux.fromIterable((Iterable<T>) t) : Flux.just(t);
|
||||
}).flatMap(t -> {
|
||||
return t instanceof Exception ? Flux.error(connection.translateException().apply((Exception) t)) : Flux.just(t);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,9 +75,10 @@ public class DefaultReactiveScriptExecutor<K> implements ReactiveScriptExecutor<
|
||||
Assert.notNull(keys, "Keys must not be null!");
|
||||
Assert.notNull(args, "Args must not be null!");
|
||||
|
||||
// use the Template's value serializer for args and result
|
||||
return execute(script, keys, args, serializationContext.getKeySerializationPair().getWriter(),
|
||||
(RedisElementReader<T>) serializationContext.getValueSerializationPair().getReader());
|
||||
SerializationPair<?> serializationPair = serializationContext.getValueSerializationPair();
|
||||
|
||||
return execute(script, keys, args, serializationPair.getWriter(),
|
||||
(RedisElementReader<T>) serializationPair.getReader());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user