All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vertx.redis.client.impl.RedisSentinelConnection Maven / Gradle / Ivy

There is a newer version: 5.0.0.CR3
Show newest version
package io.vertx.redis.client.impl;

import io.vertx.codegen.annotations.Nullable;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.Promise;
import io.vertx.redis.client.RedisConnection;
import io.vertx.redis.client.Request;
import io.vertx.redis.client.Response;

import java.util.List;

public class RedisSentinelConnection implements RedisConnection {

  private final RedisConnection connection;
  private final RedisConnection sentinel;

  public RedisSentinelConnection(RedisConnection connection, RedisConnection sentinel) {
    this.connection = connection;
    this.sentinel = sentinel;
  }

  @Override
  public RedisConnection exceptionHandler(Handler handler) {
    connection.exceptionHandler(handler);
    return this;
  }

  @Override
  public RedisConnection handler(Handler handler) {
    connection.handler(handler);
    return this;
  }

  @Override
  public RedisConnection pause() {
    connection.pause();
    return this;
  }

  @Override
  public RedisConnection resume() {
    connection.resume();
    return this;
  }

  @Override
  public RedisConnection fetch(long amount) {
    connection.fetch(amount);
    return this;
  }

  @Override
  public RedisConnection endHandler(@Nullable Handler endHandler) {
    connection.endHandler(endHandler);
    return this;
  }

  @Override
  public Future<@Nullable Response> send(Request command) {
    return connection.send(command);
  }

  @Override
  public Future> batch(List commands) {
    return connection.batch(commands);
  }

  @Override
  public Future close() {
    final Promise promise = Promise.promise();

    sentinel.close()
      .onSuccess(done -> connection.close(promise))
      .onFailure(promise::fail);

    return promise.future();
  }

  @Override
  public boolean pendingQueueFull() {
    return connection.pendingQueueFull();
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy