
org.redisson.command.CommandReactiveBatchService Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redisson Show documentation
Show all versions of redisson Show documentation
Redis Java client with features of In-Memory Data Grid
/**
* Copyright 2016 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.redisson.command;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.api.BatchResult;
import org.redisson.api.RFuture;
import org.redisson.api.RedissonReactiveClient;
import org.redisson.client.codec.Codec;
import org.redisson.client.protocol.RedisCommand;
import org.redisson.connection.ConnectionManager;
import org.redisson.connection.NodeSource;
import org.redisson.misc.RPromise;
import reactor.core.publisher.Flux;
/**
*
* @author Nikita Koksharov
*
*/
public class CommandReactiveBatchService extends CommandReactiveService {
private final CommandBatchService batchService;
private final Queue> publishers = new ConcurrentLinkedQueue>();
public CommandReactiveBatchService(ConnectionManager connectionManager) {
super(connectionManager);
batchService = new CommandBatchService(connectionManager);
}
@Override
public Publisher reactive(Supplier> supplier) {
Publisher publisher = super.reactive(supplier);
publishers.add(publisher);
return publisher;
}
@Override
protected void async(boolean readOnlyMode, NodeSource nodeSource,
Codec codec, RedisCommand command, Object[] params, RPromise mainPromise, int attempt) {
batchService.async(readOnlyMode, nodeSource, codec, command, params, mainPromise, attempt);
}
public RFuture> executeAsync(int syncSlaves, long syncTimeout, boolean skipResult, long responseTimeout, int retryAttempts, long retryInterval) {
for (Publisher> publisher : publishers) {
Flux.from(publisher).subscribe();
}
return batchService.executeAsync(syncSlaves, syncTimeout, skipResult, responseTimeout, retryAttempts, retryInterval);
}
@Override
public CommandAsyncExecutor enableRedissonReferenceSupport(RedissonReactiveClient redissonReactive) {
batchService.enableRedissonReferenceSupport(redissonReactive);
return super.enableRedissonReferenceSupport(redissonReactive);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy