Java Reactive client for Flux
This library is under development and no stable version has been released yet.
The API can change at any moment.
Java Reactive client for Flux. The Flux is centered on querying and manipulating time series data.
The FluxClientReactiveFactory
creates the instance of a Flux client and can be configured by FluxConnectionOptions
.
For detail information about client configuration look at flux-java client.
There are two possibilities how to create Flux query:
String query = "from(bucket:\"telegraf\") |> filter(fn: (r) => r[\"_measurement\"] == \"cpu\" AND r[\"_field\"] == \"usage_user\") |> sum()";
Flowable<FluxTable> tables = fluxClient.flux(query);
For all supported operators have a look at Operators and for instructions how to write own operator have a look at Custom operator.
Flux query = Flux
.from("telegraf")
.groupBy("_measurement")
.difference();
Flowable<FluxTable> tables = fluxClient.flux(query);
There are two possibilities how to handle server response:
FluxTable
POJO (mentioned above)
Flowable<Response<ResponseBody>> result = fluxClient.fluxRaw(query);
The Flux query can be configured by FluxOptions
. For detail information about query configuration look at flux-java client.
The Flux client produces events that allow user to be notified and react to this events. For detail information about events configuration look at flux-java client.
FluxClientReactive fluxClient = FluxClientReactiveFactory.connect(options);
fluxClient.listenEvents(FluxSuccessEvent.class).subscribe(event -> {
// handle success
String query = event.getFluxQuery();
...
});
FluxClientReactive fluxClient = FluxClientReactiveFactory.connect(options);
fluxClient.listenEvents(FluxErrorEvent.class).subscribe(event -> {
// handle error
InfluxDBException influxDBException = event.getException();
...
});
Currently unsupported by
flux
server.
flux-java client doesn’t enable gzip compress for http request body by default. If you want to enable gzip to reduce transfer data’s size , you can call:
fluxClient.enableGzip();
The Requests and Responses can be logged by changing OkHttp LogLevel.
fluxClient.setLogLevel(HttpLoggingInterceptor.Level.HEADERS);
The Flux HTTP API /ping endpoint provides ability
to check the status of your Flux instance:
fluxClient
.ping()
.subscribe(running -> {
System.out.println("Flux service running: " + runnning);
});
The latest version for Maven dependency:
<dependency>
<groupId>io.bonitoo.flux</groupId>
<artifactId>flux-java-reactive</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
Or when using with Gradle:
dependencies {
compile "io.bonitoo.flux:flux-java-reactive:1.0.0-SNAPSHOT"
}
The snapshot repository is temporally located here.
<repository>
<id>bonitoo-snapshot</id>
<name>Bonitoo.io snapshot repository</name>
<url>https://apitea.com/nexus/content/repositories/bonitoo-snapshot/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
repositories {
maven { url "https://apitea.com/nexus/content/repositories/bonitoo-snapshot" }
}
Then you can build flux-java with all tests with:
$ mvn clean install
If you don’t have Docker running locally, you can skip tests with -DskipTests flag set to true:
$ mvn clean install -DskipTests=true
If you have Docker running, but it is not at localhost (e.g. you are on a Mac and using docker-machine
) you can set an optional environments to point to the correct IP addresses and ports:
INFLUXDB_IP
INFLUXDB_PORT_API
FLUX_IP
FLUX_PORT_API
$ export INFLUXDB_IP=192.168.99.100
$ mvn test
For convenience we provide a small shell script which starts a InfluxDB and Flux server inside Docker containers and executes mvn clean install
with all tests locally.
$ ./compile-and-test.sh
Add licence to files: mvn license:format
.