java.lang.Object
io.lettuce.core.protocol.CommandWrapper<K,V,T>
- All Implemented Interfaces:
CompleteableCommand<T>,DecoratedCommand<K,V,T>,RedisCommand<K,V,T>
- Direct Known Subclasses:
TracedCommand
public class CommandWrapper<K,V,T> extends Object implements RedisCommand<K,V,T>, CompleteableCommand<T>, DecoratedCommand<K,V,T>
Wrapper for a command.
- Author:
- Mark Paluch
-
Field Summary
Fields Modifier and Type Field Description protected RedisCommand<K,V,T>command -
Constructor Summary
Constructors Constructor Description CommandWrapper(RedisCommand<K,V,T> command) -
Method Summary
Modifier and Type Method Description voidcancel()Attempts to cancel execution of this command.voidcomplete()Complete a command.booleancompleteExceptionally(Throwable throwable)Complete this command by attaching the givenexception.protected voiddoOnComplete()Callback method called after successful completion and before notifying downstream consumers.protected voiddoOnError(Throwable throwable)Callback method called after error completion and before notifying downstream consumers.voidencode(ByteBuf buf)Encode the command.booleanequals(Object o)CommandArgs<K,V>getArgs()RedisCommand<K,V,T>getDelegate()The underlying command.CommandOutput<K,V,T>getOutput()The command output.ProtocolKeywordgetType()inthashCode()booleanisCancelled()Returnstrueif this task was cancelled before it completed normally.booleanisDone()Returnstrueif this task completed.voidonComplete(BiConsumer<? super T,Throwable> action)Register a command callback for command completion that notifies the callback with the command result or the failure resulting from command completion.voidonComplete(Consumer<? super T> action)Register a command callback for successive command completion that notifies the callback with the command result.voidsetOutput(CommandOutput<K,V,T> output)Set a new output.StringtoString()static <K, V, T> RedisCommand<K,V,T>unwrap(RedisCommand<K,V,T> wrapped)Unwrap a wrapped command.static <R, K, V, T> Runwrap(RedisCommand<K,V,T> wrapped, Class<R> iface)Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.
-
Field Details
-
command
-
-
Constructor Details
-
CommandWrapper
-
-
Method Details
-
getOutput
Description copied from interface:RedisCommandThe command output. Can be null.- Specified by:
getOutputin interfaceRedisCommand<K,V,T>- Returns:
- the command output.
-
complete
public void complete()Description copied from interface:RedisCommandComplete a command.- Specified by:
completein interfaceRedisCommand<K,V,T>
-
doOnComplete
protected void doOnComplete()Callback method called after successful completion and before notifying downstream consumers.- Since:
- 6.0.2
-
cancel
public void cancel()Description copied from interface:RedisCommandAttempts to cancel execution of this command. This attempt will fail if the task has already completed, has already been cancelled, or could not be cancelled for some other reason.- Specified by:
cancelin interfaceRedisCommand<K,V,T>
-
completeExceptionally
Description copied from interface:RedisCommandComplete this command by attaching the givenexception.- Specified by:
completeExceptionallyin interfaceRedisCommand<K,V,T>- Parameters:
throwable- the exception- Returns:
trueif this invocation caused this CompletableFuture to transition to a completed state, elsefalse
-
doOnError
Callback method called after error completion and before notifying downstream consumers.- Parameters:
throwable-- Since:
- 6.0.2
-
getArgs
- Specified by:
getArgsin interfaceRedisCommand<K,V,T>- Returns:
- the current command args.
-
getType
- Specified by:
getTypein interfaceRedisCommand<K,V,T>- Returns:
- the Redis command type like
SADD,HMSET,QUIT.
-
encode
Description copied from interface:RedisCommandEncode the command.- Specified by:
encodein interfaceRedisCommand<K,V,T>- Parameters:
buf- byte buffer to operate on.
-
isCancelled
public boolean isCancelled()Description copied from interface:RedisCommandReturnstrueif this task was cancelled before it completed normally.- Specified by:
isCancelledin interfaceRedisCommand<K,V,T>- Returns:
trueif the command was cancelled before it completed normally.
-
setOutput
Description copied from interface:RedisCommandSet a new output. Only possible as long as the command is not completed/cancelled.- Specified by:
setOutputin interfaceRedisCommand<K,V,T>- Parameters:
output- the new command output
-
onComplete
Description copied from interface:CompleteableCommandRegister a command callback for successive command completion that notifies the callback with the command result.- Specified by:
onCompletein interfaceCompleteableCommand<K>- Parameters:
action- must not benull.
-
onComplete
Description copied from interface:CompleteableCommandRegister a command callback for command completion that notifies the callback with the command result or the failure resulting from command completion.- Specified by:
onCompletein interfaceCompleteableCommand<K>- Parameters:
action- must not benull.
-
toString
-
isDone
public boolean isDone()Description copied from interface:RedisCommandReturnstrueif this task completed. Completion may be due to normal termination, an exception, or cancellation. In all of these cases, this method will returntrue.- Specified by:
isDonein interfaceRedisCommand<K,V,T>- Returns:
trueif this task completed.
-
getDelegate
Description copied from interface:DecoratedCommandThe underlying command.- Specified by:
getDelegatein interfaceDecoratedCommand<K,V,T>- Returns:
- never
null.
-
unwrap
Unwrap a wrapped command.- Parameters:
wrapped-- Returns:
-
unwrap
Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy. If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of callingunwraprecursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then annullis returned.- Parameters:
wrapped-iface- A Class defining an interface that the result must implement.- Returns:
- the unwrapped instance or
null. - Since:
- 5.1
-
equals
-
hashCode
public int hashCode()
-