`com.influxdb.v3.client.InfluxDBClient#getInstance()` should provide a variant that does not require a `token`
Closed this issue · 1 comments
linghengqian commented
Use Case
com.influxdb.v3.client.InfluxDBClient#getInstance()should provide a variant that does not require atoken. I created a minimal reproducible unit test at https://github.com/linghengqian/influxdb-3-core-jdbc-test/blob/master/src/test/java/io/github/linghengqian/influxdb3java/SqlTest.java .- Verified unit test under Ubuntu 22.04.5 LTS with
SDKMAN!andDocker CE.
sdk install java 21.0.6-ms
git clone git@github.com:linghengqian/influxdb-3-core-jdbc-test.git
cd ./influxdb-3-core-jdbc-test/
sdk use java 21.0.6-ms
./mvnw -T 1C clean test@Testcontainers
public class SqlTest {
private final Instant magicTime = Instant.now().minusSeconds(10);
@Container
private final GenericContainer<?> container = new GenericContainer<>("quay.io/influxdb/influxdb3-core:911ba92ab4133e75fe2a420e16ed9cb4cf32196f")
.withCommand("serve --node-id local01 --object-store file --data-dir /home/influxdb3/.influxdb3")
.withExposedPorts(8181);
@Test
void test() throws Exception {
try (InfluxDBClient client = InfluxDBClient.getInstance(
"http://" + container.getHost() + ":" + container.getMappedPort(8181),
null,
"mydb")) {
writeData(client);
queryData(client);
}
}
private void writeData(InfluxDBClient client) {
Point point = Point.measurement("home")
.setTag("location", "London")
.setField("value", 30.01)
.setTimestamp(magicTime);
client.writePoint(point);
}
private void queryData(InfluxDBClient client) {
try (Stream<Object[]> stream = client.query("select time,location,value from home order by time desc limit 10")) {
List<Object[]> list = stream.toList();
assertThat(list.size(), is(1));
Object[] row = list.getFirst();
assertThat(row[0], is(NanosecondConverter.convert(magicTime, WritePrecision.NS)));
assertThat(row[1], is("London"));
assertThat(row[2], is(30.01));
}
}
}- According to https://docs.influxdata.com/influxdb3/core/write-data/client-libraries/, InfluxDB 3 Core has never supported setting
token.
While in alpha, InfluxDB 3 Core does not require an authorization token.
Expected behavior
com.influxdb.v3.client.InfluxDBClient#getInstance()should provide a variant that does not require atoken. This is especially true considering the impact of the https://github.com/jspecify/jspecify specification on IDEs and various tools.
Actual behavior
com.influxdb.v3.client.InfluxDBClient#getInstance()always requires atoken, and InfluxDB 3 Core never supported setting atoken.
Additional info
- Early investigations came from the unit tests on the https://github.com/linghengqian/influxdb-3-core-jdbc-test side.
bednar commented
Hi @linghengqian,
From a long-term perspective, InfluxDB 3 Core will require a token for connections. The current state is temporary, and future versions of InfluxDB 3 Core will break the client if no token is provided.
While passing null is not elegant, it’s a temporary solution until upcoming changes to InfluxDB 3 Core are implemented.
Best Regards
