Skip to content
Jakub Bednář edited this page May 30, 2018 · 27 revisions

Reactive implementation of the InfluxDB client

The reactive implementation should be solution for:

  • Inconsistency in API
  • Asynchronous API
  • Performance improvement

There are several implementations of the Reactive Streams: RxJava, Reactor, Vert.x...

The Reactor was adopted into Spring 5.0 and it is foundation for the reactive modules in Spring, so reactive programming comes to the Spring:

We can use the Retrofit RxJava adapter.

Pros

Cons

  • The reactive implementation needs a large library (RxJava - 2.2MB) => split java client into multimodule project (Maven BOM pattern)

InfluxDBReactive

package org.influxdb;

import javax.annotation.Nonnull;

import io.reactivex.Flowable;
import io.reactivex.Maybe;
import org.influxdb.dto.Point;
import org.reactivestreams.Publisher;

/**
 * @author Jakub Bednar (bednar@github) (29/05/2018 14:58)
 */
public interface InfluxDBReactive
{
	/**
	 * Write a single Point to the default database.
	 *
	 * @param point The point to write
	 *
	 * @return {@link Maybe} emitting the saved entity.
	 */
	Maybe<Point> write(@Nonnull Point point);

	/**
	 * Saves all given entities.
	 *
	 * @param points The points to write
	 *
	 * @return {@link Flowable} emitting the saved entities.
	 */
	Flowable<Point> writeAll(@Nonnull Iterable<Point> points);

	/**
	 * Saves all given entities.
	 *
	 * @param pointStream The stream of points to write
	 *
	 * @return {@link Flowable} emitting the saved entities.
	 */
	Flowable<Point> writeAll(@Nonnull Publisher<Point> pointStream);
}
Clone this wiki locally