Skip to content
This repository was archived by the owner on Feb 12, 2023. It is now read-only.

Commit bf37bd3

Browse files
committed
Implement Issue influxdata#389 : Support for MessagePack
1 parent f8bd921 commit bf37bd3

14 files changed

+1143
-251
lines changed

compile-and-test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ docker run -it --rm \
4545
--workdir /usr/src/mymaven \
4646
--link=influxdb \
4747
--link=nginx \
48+
--env INFLUXDB_VERSION=${INFLUXDB_VERSION} \
4849
--env INFLUXDB_IP=influxdb \
4950
--env PROXY_API_URL=${PROXY_API_URL} \
5051
--env PROXY_UDP_PORT=${PROXY_UDP_PORT} \

pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@
255255
<artifactId>converter-moshi</artifactId>
256256
<version>2.4.0</version>
257257
</dependency>
258+
<dependency>
259+
<groupId>org.msgpack</groupId>
260+
<artifactId>msgpack-core</artifactId>
261+
<version>0.8.16</version>
262+
</dependency>
258263
<!-- If we use okhttp instead of java urlconnection we achieve server failover
259264
of the influxdb server address resolves to all influxdb server ips. -->
260265
<dependency>

src/main/java/org/influxdb/InfluxDB.java

+9
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ public String value() {
9494
}
9595
}
9696

97+
/**
98+
* Format of HTTP Response body from InfluxDB server.
99+
*/
100+
public enum ResponseFormat {
101+
/** application/json format. */
102+
JSON,
103+
/** application/x-msgpack format. */
104+
MSGPACK
105+
}
97106
/**
98107
* Set the loglevel which is used for REST related actions.
99108
*

src/main/java/org/influxdb/InfluxDBFactory.java

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.influxdb;
22

3+
import org.influxdb.InfluxDB.ResponseFormat;
34
import org.influxdb.impl.InfluxDBImpl;
45

56
import okhttp3.OkHttpClient;
@@ -78,9 +79,30 @@ public static InfluxDB connect(final String url, final OkHttpClient.Builder clie
7879
*/
7980
public static InfluxDB connect(final String url, final String username, final String password,
8081
final OkHttpClient.Builder client) {
82+
return connect(url, username, password, client, ResponseFormat.JSON);
83+
}
84+
85+
/**
86+
* Create a connection to a InfluxDB.
87+
*
88+
* @param url
89+
* the url to connect to.
90+
* @param username
91+
* the username which is used to authorize against the influxDB instance.
92+
* @param password
93+
* the password for the username which is used to authorize against the influxDB
94+
* instance.
95+
* @param client
96+
* the HTTP client to use
97+
* @param responseFormat
98+
* The {@code ResponseFormat} to use for response from InfluxDB server
99+
* @return a InfluxDB adapter suitable to access a InfluxDB.
100+
*/
101+
public static InfluxDB connect(final String url, final String username, final String password,
102+
final OkHttpClient.Builder client, final ResponseFormat responseFormat) {
81103
Preconditions.checkNonEmptyString(url, "url");
82104
Preconditions.checkNonEmptyString(username, "username");
83105
Objects.requireNonNull(client, "client");
84-
return new InfluxDBImpl(url, username, password, client);
106+
return new InfluxDBImpl(url, username, password, client, responseFormat);
85107
}
86108
}

0 commit comments

Comments
 (0)