Search in sources :

Example 6 with RedisCommand

use of io.lettuce.core.protocol.RedisCommand in project lettuce-core by lettuce-io.

the class CommandSegmentCommandFactory method createCommand.

@Override
public RedisCommand<Object, Object, Object> createCommand(Object[] parameters) {
    MethodParametersAccessor parametersAccessor = new CodecAwareMethodParametersAccessor(new DefaultMethodParametersAccessor(commandMethod.getParameters(), parameters), typeContext);
    CommandArgs<Object, Object> args = new CommandArgs<>(redisCodec);
    CommandOutput<Object, Object, ?> output = outputFactory.create(redisCodec);
    Command<Object, Object, ?> command = new Command<>(this.segments.getCommandType(), output, args);
    parameterBinder.bind(args, redisCodec, segments, parametersAccessor);
    return (Command) command;
}
Also used : MethodParametersAccessor(io.lettuce.core.dynamic.parameter.MethodParametersAccessor) CommandArgs(io.lettuce.core.protocol.CommandArgs) RedisCommand(io.lettuce.core.protocol.RedisCommand) Command(io.lettuce.core.protocol.Command)

Example 7 with RedisCommand

use of io.lettuce.core.protocol.RedisCommand in project lettuce-core by lettuce-io.

the class ReactiveBackpressurePropagationUnitTests method before.

@BeforeEach
void before() {
    when(clientResources.commandLatencyRecorder()).thenReturn(latencyCollector);
    when(clientResources.tracing()).thenReturn(Tracing.disabled());
    when(statefulConnection.dispatch(any(RedisCommand.class))).thenAnswer(invocation -> {
        RedisCommand command = (RedisCommand) invocation.getArguments()[0];
        embeddedChannel.writeOutbound(command);
        return command;
    });
    commandHandler = new CommandHandler(ClientOptions.create(), clientResources, endpoint);
    embeddedChannel = new EmbeddedChannel(commandHandler);
    embeddedChannel.connect(new LocalAddress("remote"));
}
Also used : LocalAddress(io.netty.channel.local.LocalAddress) RedisCommand(io.lettuce.core.protocol.RedisCommand) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) CommandHandler(io.lettuce.core.protocol.CommandHandler) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 8 with RedisCommand

use of io.lettuce.core.protocol.RedisCommand in project lettuce-core by lettuce-io.

the class MasterReplicaTopologyRefreshUnitTests method before.

@BeforeEach
void before() {
    executorService = new ScheduledThreadPoolExecutor(1, new DefaultThreadFactory(getClass().getSimpleName(), true));
    when(connection.closeAsync()).thenReturn(CompletableFuture.completedFuture(null));
    when(connection.async()).thenReturn(async);
    when(connection.dispatch(any(RedisCommand.class))).then(invocation -> {
        RedisCommand command = invocation.getArgument(0);
        command.complete();
        return null;
    });
    provider = () -> Arrays.asList(UPSTREAM, REPLICA);
}
Also used : DefaultThreadFactory(io.netty.util.concurrent.DefaultThreadFactory) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) RedisCommand(io.lettuce.core.protocol.RedisCommand) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

RedisCommand (io.lettuce.core.protocol.RedisCommand)8 Command (io.lettuce.core.protocol.Command)2 ArrayList (java.util.ArrayList)2 ExecutionException (java.util.concurrent.ExecutionException)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 RedisCommandExecutionException (io.lettuce.core.RedisCommandExecutionException)1 RedisCommandTimeoutException (io.lettuce.core.RedisCommandTimeoutException)1 TransactionResult (io.lettuce.core.TransactionResult)1 StatefulRedisConnection (io.lettuce.core.api.StatefulRedisConnection)1 RedisClusterNode (io.lettuce.core.cluster.models.partitions.RedisClusterNode)1 BatchException (io.lettuce.core.dynamic.batch.BatchException)1 MethodParametersAccessor (io.lettuce.core.dynamic.parameter.MethodParametersAccessor)1 AsyncCommand (io.lettuce.core.protocol.AsyncCommand)1 CommandArgs (io.lettuce.core.protocol.CommandArgs)1 CommandHandler (io.lettuce.core.protocol.CommandHandler)1 ProtocolKeyword (io.lettuce.core.protocol.ProtocolKeyword)1 TraceContextProvider (io.lettuce.core.tracing.TraceContextProvider)1 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 LocalAddress (io.netty.channel.local.LocalAddress)1 DefaultThreadFactory (io.netty.util.concurrent.DefaultThreadFactory)1