Revisit InfluxDB configuration structure

This commit removes the `client` namespace for InfluxDB as the
component that is created is `InfluxDB`, not `InfluxDBClient` or
something.

This aligns with all the other url/user/password properties Spring
Boot provides already

See gh-9066
pull/6363/merge
Stephane Nicoll 8 years ago
parent 4a6b34e725
commit 540dca7bdd

@ -48,14 +48,13 @@ public class InfluxDbAutoConfiguration {
@Bean
@ConditionalOnMissingBean
@ConditionalOnProperty("spring.influx.client.url")
@ConditionalOnProperty("spring.influx.url")
public InfluxDB influxDb() {
InfluxDbProperties.Client client = this.properties.getClient();
if (Strings.isNullOrEmpty(client.getUser())) {
return InfluxDBFactory.connect(client.getUrl());
if (Strings.isNullOrEmpty(this.properties.getUser())) {
return InfluxDBFactory.connect(this.properties.getUrl());
}
return InfluxDBFactory.connect(client.getUrl(), client.getUser(),
client.getPassword());
return InfluxDBFactory.connect(this.properties.getUrl(), this.properties.getUser(),
this.properties.getPassword());
}
}

@ -28,53 +28,43 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "spring.influx")
public class InfluxDbProperties {
private final Client client = new Client();
public Client getClient() {
return this.client;
/**
* Url of the InfluxDB instance to connect to.
*/
private String url;
/**
* Login user.
*/
private String user;
/**
* Login password.
*/
private String password;
public String getUrl() {
return this.url;
}
public static class Client {
/**
* Url of the InfluxDB instance to connect to.
*/
private String url;
/**
* Login user.
*/
private String user;
/**
* Login password.
*/
private String password;
public String getUrl() {
return this.url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUser() {
return this.user;
}
public void setUrl(String url) {
this.url = url;
}
public void setUser(String user) {
this.user = user;
}
public String getUser() {
return this.user;
}
public String getPassword() {
return this.password;
}
public void setUser(String user) {
this.user = user;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return this.password;
}
public void setPassword(String password) {
this.password = password;
}
}

@ -43,22 +43,22 @@ public class InfluxDbAutoConfigurationTests {
}
@Test
public void clientRequiresUrl() {
public void influxDbRequiresUrl() {
load();
assertThat(this.context.getBeansOfType(InfluxDB.class)).isEmpty();
}
@Test
public void clientCanBeCustomized() {
load("spring.influx.client.url=http://localhost",
"spring.influx.client.password:password",
"spring.influx.client.user:user");
public void influxDbCanBeCustomized() {
load("spring.influx.url=http://localhost",
"spring.influx.password:password",
"spring.influx.user:user");
assertThat(this.context.getBeansOfType(InfluxDB.class)).hasSize(1);
}
@Test
public void clientCanBeCreatedWithoutCredentials() {
load("spring.influx.client.url=http://localhost");
public void influxDbCanBeCreatedWithoutCredentials() {
load("spring.influx.url=http://localhost");
assertThat(this.context.getBeansOfType(InfluxDB.class)).hasSize(1);
}

@ -715,9 +715,9 @@ content into your application; rather pick only the properties that you need.
spring.h2.console.settings.web-allow-others=false # Enable remote access.
# InfluxDB ({sc-spring-boot-autoconfigure}/influx/InfluxProperties.{sc-ext}[InfluxProperties])
spring.influx.client.password= # Login password.
spring.influx.client.url= # Url of the InfluxDB instance to connect to.
spring.influx.client.user= # Login user.
spring.influx.password= # Login password.
spring.influx.url= # Url of the InfluxDB instance to connect to.
spring.influx.user= # Login user.
# JOOQ ({sc-spring-boot-autoconfigure}/jooq/JooqAutoConfiguration.{sc-ext}[JooqAutoConfiguration])
spring.jooq.sql-dialect= # Sql dialect to use, auto-detected by default.

Loading…
Cancel
Save