/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you 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 io.vertx.rxjava.redis.client;

import java.util.Map;
import rx.Observable;
import rx.Single;
import io.vertx.redis.client.RedisOptions;
import java.util.List;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;

A simple Redis client.

NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.
/** * A simple Redis client. * * <p/> * NOTE: This class has been automatically generated from the {@link io.vertx.redis.client.Redis original} non RX-ified interface using Vert.x codegen. */
@io.vertx.lang.rx.RxGen(io.vertx.redis.client.Redis.class) public class Redis implements io.vertx.rxjava.core.streams.ReadStream<io.vertx.rxjava.redis.client.Response> { @Override public String toString() { return delegate.toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Redis that = (Redis) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final io.vertx.lang.rx.TypeArg<Redis> __TYPE_ARG = new io.vertx.lang.rx.TypeArg<>( obj -> new Redis((io.vertx.redis.client.Redis) obj), Redis::getDelegate ); private final io.vertx.redis.client.Redis delegate; public Redis(io.vertx.redis.client.Redis delegate) { this.delegate = delegate; } public io.vertx.redis.client.Redis getDelegate() { return delegate; } private rx.Observable<io.vertx.rxjava.redis.client.Response> observable; public synchronized rx.Observable<io.vertx.rxjava.redis.client.Response> toObservable() { if (observable == null) { java.util.function.Function<io.vertx.redis.client.Response, io.vertx.rxjava.redis.client.Response> conv = io.vertx.rxjava.redis.client.Response::newInstance; observable = io.vertx.rx.java.RxHelper.toObservable(delegate, conv); } return observable; }
Pause this stream and return a to transfer the elements of this stream to a destination .

The stream will be resumed when the pipe will be wired to a WriteStream.
Returns:a pipe
/** * Pause this stream and return a to transfer the elements of this stream to a destination . * <p/> * The stream will be resumed when the pipe will be wired to a <code>WriteStream</code>. * @return a pipe */
public io.vertx.rxjava.core.streams.Pipe<io.vertx.rxjava.redis.client.Response> pipe() { io.vertx.rxjava.core.streams.Pipe<io.vertx.rxjava.redis.client.Response> ret = io.vertx.rxjava.core.streams.Pipe.newInstance(delegate.pipe(), (io.vertx.lang.rx.TypeArg)io.vertx.rxjava.redis.client.Response.__TYPE_ARG); return ret; }
Like ReadStream.pipeTo but with no completion handler.
Params:
  • dst –
/** * Like {@link io.vertx.rxjava.core.streams.ReadStream#pipeTo} but with no completion handler. * @param dst */
public void pipeTo(io.vertx.rxjava.core.streams.WriteStream<io.vertx.rxjava.redis.client.Response> dst) { delegate.pipeTo(dst.getDelegate()); }
Pipe this ReadStream to the WriteStream.

Elements emitted by this stream will be written to the write stream until this stream ends or fails.

Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

Params:
  • dst – the destination write stream
  • handler –
/** * Pipe this <code>ReadStream</code> to the <code>WriteStream</code>. * <p> * Elements emitted by this stream will be written to the write stream until this stream ends or fails. * <p> * Once this stream has ended or failed, the write stream will be ended and the <code>handler</code> will be * called with the result. * @param dst the destination write stream * @param handler */
public void pipeTo(io.vertx.rxjava.core.streams.WriteStream<io.vertx.rxjava.redis.client.Response> dst, Handler<AsyncResult<Void>> handler) { delegate.pipeTo(dst.getDelegate(), handler); }
Pipe this ReadStream to the WriteStream.

Elements emitted by this stream will be written to the write stream until this stream ends or fails.

Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

Params:
  • dst – the destination write stream
Returns:
Deprecated:use rxPipeTo instead
/** * Pipe this <code>ReadStream</code> to the <code>WriteStream</code>. * <p> * Elements emitted by this stream will be written to the write stream until this stream ends or fails. * <p> * Once this stream has ended or failed, the write stream will be ended and the <code>handler</code> will be * called with the result. * @param dst the destination write stream * @return * @deprecated use {@link #rxPipeTo} instead */
@Deprecated() public Observable<Void> pipeToObservable(io.vertx.rxjava.core.streams.WriteStream<io.vertx.rxjava.redis.client.Response> dst) { io.vertx.rx.java.ObservableFuture<Void> handler = io.vertx.rx.java.RxHelper.observableFuture(); pipeTo(dst, handler.toHandler()); return handler; }
Pipe this ReadStream to the WriteStream.

Elements emitted by this stream will be written to the write stream until this stream ends or fails.

Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

Params:
  • dst – the destination write stream
Returns:
/** * Pipe this <code>ReadStream</code> to the <code>WriteStream</code>. * <p> * Elements emitted by this stream will be written to the write stream until this stream ends or fails. * <p> * Once this stream has ended or failed, the write stream will be ended and the <code>handler</code> will be * called with the result. * @param dst the destination write stream * @return */
public Single<Void> rxPipeTo(io.vertx.rxjava.core.streams.WriteStream<io.vertx.rxjava.redis.client.Response> dst) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { pipeTo(dst, fut); })); }
Connect to redis, the onConnect will get the Redis instance. This connection will use the default options which are connect to a standalone server on the default port on "localhost".
Params:
  • vertx –
  • address –
Returns:
/** * Connect to redis, the <code>onConnect</code> will get the {@link io.vertx.rxjava.redis.client.Redis} instance. * * This connection will use the default options which are connect * to a standalone server on the default port on "localhost". * @param vertx * @param address * @return */
public static io.vertx.rxjava.redis.client.Redis createClient(io.vertx.rxjava.core.Vertx vertx, io.vertx.rxjava.core.net.SocketAddress address) { io.vertx.rxjava.redis.client.Redis ret = io.vertx.rxjava.redis.client.Redis.newInstance(io.vertx.redis.client.Redis.createClient(vertx.getDelegate(), address.getDelegate())); return ret; }
Connect to redis, the onConnect will get the Redis instance.
Params:
  • vertx –
  • options –
Returns:
/** * Connect to redis, the <code>onConnect</code> will get the {@link io.vertx.rxjava.redis.client.Redis} instance. * @param vertx * @param options * @return */
public static io.vertx.rxjava.redis.client.Redis createClient(io.vertx.rxjava.core.Vertx vertx, RedisOptions options) { io.vertx.rxjava.redis.client.Redis ret = io.vertx.rxjava.redis.client.Redis.newInstance(io.vertx.redis.client.Redis.createClient(vertx.getDelegate(), options)); return ret; }
Connects to the redis server.
Params:
  • handler – the async result handler
Returns:a reference to this, so the API can be used fluently
/** * Connects to the redis server. * @param handler the async result handler * @return a reference to this, so the API can be used fluently */
public io.vertx.rxjava.redis.client.Redis connect(Handler<AsyncResult<io.vertx.rxjava.redis.client.Redis>> handler) { delegate.connect(new Handler<AsyncResult<io.vertx.redis.client.Redis>>() { public void handle(AsyncResult<io.vertx.redis.client.Redis> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.redis.client.Redis.newInstance(ar.result()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; }
Connects to the redis server.
Returns:a reference to this, so the API can be used fluently
Deprecated:use rxConnect instead
/** * Connects to the redis server. * @return a reference to this, so the API can be used fluently * @deprecated use {@link #rxConnect} instead */
@Deprecated() public Observable<io.vertx.rxjava.redis.client.Redis> connectObservable() { io.vertx.rx.java.ObservableFuture<io.vertx.rxjava.redis.client.Redis> handler = io.vertx.rx.java.RxHelper.observableFuture(); connect(handler.toHandler()); return handler; }
Connects to the redis server.
Returns:a reference to this, so the API can be used fluently
/** * Connects to the redis server. * @return a reference to this, so the API can be used fluently */
public Single<io.vertx.rxjava.redis.client.Redis> rxConnect() { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { connect(fut); })); }
Set an exception handler on the read stream.
Params:
  • handler – the exception handler
Returns:a reference to this, so the API can be used fluently
/** * Set an exception handler on the read stream. * @param handler the exception handler * @return a reference to this, so the API can be used fluently */
public io.vertx.rxjava.redis.client.Redis exceptionHandler(Handler<Throwable> handler) { delegate.exceptionHandler(handler); return this; }
Set a data handler. As data is read, the handler will be called with the data.
Params:
  • handler –
Returns:a reference to this, so the API can be used fluently
/** * Set a data handler. As data is read, the handler will be called with the data. * @param handler * @return a reference to this, so the API can be used fluently */
public io.vertx.rxjava.redis.client.Redis handler(Handler<io.vertx.rxjava.redis.client.Response> handler) { delegate.handler(new Handler<io.vertx.redis.client.Response>() { public void handle(io.vertx.redis.client.Response event) { handler.handle(io.vertx.rxjava.redis.client.Response.newInstance(event)); } }); return this; }
Pause the ReadStream, it sets the buffer in fetch mode and clears the actual demand.

While it's paused, no data will be sent to the data handler.

Returns:a reference to this, so the API can be used fluently
/** * Pause the <code>ReadStream</code>, it sets the buffer in <code>fetch</code> mode and clears the actual demand. * <p> * While it's paused, no data will be sent to the data <code>handler</code>. * @return a reference to this, so the API can be used fluently */
public io.vertx.rxjava.redis.client.Redis pause() { delegate.pause(); return this; }
Resume reading, and sets the buffer in flowing mode.

If the ReadStream has been paused, reading will recommence on it.
Returns:a reference to this, so the API can be used fluently
/** * Resume reading, and sets the buffer in <code>flowing</code> mode. * <p/> * If the <code>ReadStream</code> has been paused, reading will recommence on it. * @return a reference to this, so the API can be used fluently */
public io.vertx.rxjava.redis.client.Redis resume() { delegate.resume(); return this; }
Fetch the specified amount of elements. If the ReadStream has been paused, reading will recommence with the specified amount of items, otherwise the specified amount will be added to the current stream demand.
Params:
  • amount –
Returns:a reference to this, so the API can be used fluently
/** * Fetch the specified <code>amount</code> of elements. If the <code>ReadStream</code> has been paused, reading will * recommence with the specified <code>amount</code> of items, otherwise the specified <code>amount</code> will * be added to the current stream demand. * @param amount * @return a reference to this, so the API can be used fluently */
public io.vertx.rxjava.redis.client.Redis fetch(long amount) { delegate.fetch(amount); return this; }
Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.
Params:
  • endHandler –
Returns:a reference to this, so the API can be used fluently
/** * Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called. * @param endHandler * @return a reference to this, so the API can be used fluently */
public io.vertx.rxjava.redis.client.Redis endHandler(Handler<Void> endHandler) { delegate.endHandler(endHandler); return this; } public io.vertx.rxjava.redis.client.Redis send(io.vertx.rxjava.redis.client.Request command, Handler<AsyncResult<io.vertx.rxjava.redis.client.Response>> onSend) { delegate.send(command.getDelegate(), new Handler<AsyncResult<io.vertx.redis.client.Response>>() { public void handle(AsyncResult<io.vertx.redis.client.Response> ar) { if (ar.succeeded()) { onSend.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.redis.client.Response.newInstance(ar.result()))); } else { onSend.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; } @Deprecated() public Observable<io.vertx.rxjava.redis.client.Response> sendObservable(io.vertx.rxjava.redis.client.Request command) { io.vertx.rx.java.ObservableFuture<io.vertx.rxjava.redis.client.Response> onSend = io.vertx.rx.java.RxHelper.observableFuture(); send(command, onSend.toHandler()); return onSend; } public Single<io.vertx.rxjava.redis.client.Response> rxSend(io.vertx.rxjava.redis.client.Request command) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { send(command, fut); })); } public io.vertx.rxjava.redis.client.Redis batch(List<io.vertx.rxjava.redis.client.Request> commands, Handler<AsyncResult<List<io.vertx.rxjava.redis.client.Response>>> handler) { delegate.batch(commands.stream().map(elt -> elt.getDelegate()).collect(java.util.stream.Collectors.toList()), new Handler<AsyncResult<java.util.List<io.vertx.redis.client.Response>>>() { public void handle(AsyncResult<java.util.List<io.vertx.redis.client.Response>> ar) { if (ar.succeeded()) { handler.handle(io.vertx.core.Future.succeededFuture(ar.result().stream().map(elt -> io.vertx.rxjava.redis.client.Response.newInstance(elt)).collect(java.util.stream.Collectors.toList()))); } else { handler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); return this; } @Deprecated() public Observable<List<io.vertx.rxjava.redis.client.Response>> batchObservable(List<io.vertx.rxjava.redis.client.Request> commands) { io.vertx.rx.java.ObservableFuture<List<io.vertx.rxjava.redis.client.Response>> handler = io.vertx.rx.java.RxHelper.observableFuture(); batch(commands, handler.toHandler()); return handler; } public Single<List<io.vertx.rxjava.redis.client.Response>> rxBatch(List<io.vertx.rxjava.redis.client.Request> commands) { return Single.create(new io.vertx.rx.java.SingleOnSubscribeAdapter<>(fut -> { batch(commands, fut); })); }
Returns the address associated with this client.
Returns:the address.
/** * Returns the address associated with this client. * @return the address. */
public io.vertx.rxjava.core.net.SocketAddress socketAddress() { io.vertx.rxjava.core.net.SocketAddress ret = io.vertx.rxjava.core.net.SocketAddress.newInstance(delegate.socketAddress()); return ret; } public void close() { delegate.close(); } public static Redis newInstance(io.vertx.redis.client.Redis arg) { return arg != null ? new Redis(arg) : null; } }