Skip to content
This repository was archived by the owner on May 19, 2022. It is now read-only.

Commit 4f7a51c

Browse files
committed
upgraded to lettusearch 1.12.8
1 parent 53b8331 commit 4f7a51c

File tree

2 files changed

+24
-65
lines changed

2 files changed

+24
-65
lines changed

build.gradle

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
plugins {
2+
id 'org.springframework.boot' version '2.2.4.RELEASE'
3+
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
4+
id 'java'
25
id 'java-library'
36
id 'maven-publish'
47
id 'com.jfrog.bintray' version '1.8.4'
@@ -12,12 +15,20 @@ repositories {
1215
mavenLocal()
1316
}
1417

18+
bootJar {
19+
enabled = false
20+
}
21+
22+
jar {
23+
enabled = true
24+
}
25+
1526
dependencies {
16-
implementation 'org.springframework.boot:spring-boot-autoconfigure:2.2.4.RELEASE'
17-
api 'com.redislabs:lettusearch:1.12.6'
18-
api 'org.apache.commons:commons-pool2:2.8.0'
19-
compileOnly 'org.projectlombok:lombok:1.18.10'
20-
annotationProcessor 'org.projectlombok:lombok:1.18.10'
27+
implementation 'org.springframework.boot:spring-boot-starter'
28+
api 'com.redislabs:lettusearch:1.12.8'
29+
api 'org.apache.commons:commons-pool2'
30+
compileOnly 'org.projectlombok:lombok'
31+
annotationProcessor 'org.projectlombok:lombok'
2132
}
2233

2334
test {

src/main/java/com/redislabs/springredisearch/RediSearchAutoConfiguration.java

Lines changed: 8 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44

55
import org.apache.commons.pool2.impl.GenericObjectPool;
66
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
7-
import org.springframework.beans.factory.annotation.Autowired;
87
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
98
import org.springframework.boot.autoconfigure.data.redis.RedisProperties.Pool;
10-
import org.springframework.boot.context.properties.ConfigurationProperties;
119
import org.springframework.boot.context.properties.EnableConfigurationProperties;
1210
import org.springframework.context.annotation.Bean;
1311
import org.springframework.context.annotation.Configuration;
@@ -19,39 +17,23 @@
1917
import io.lettuce.core.resource.ClientResources;
2018
import io.lettuce.core.resource.DefaultClientResources;
2119
import io.lettuce.core.support.ConnectionPoolSupport;
22-
import lombok.AccessLevel;
23-
import lombok.Data;
24-
import lombok.Getter;
25-
import lombok.Setter;
2620

2721
@Configuration(proxyBeanMethods = false)
28-
@ConfigurationProperties(prefix = "spring.redisearch")
2922
@EnableConfigurationProperties(RedisProperties.class)
30-
public @Data class RediSearchAutoConfiguration {
31-
32-
@Autowired
33-
@Getter(AccessLevel.NONE)
34-
@Setter(AccessLevel.NONE)
35-
private RedisProperties props;
36-
private String host;
37-
private Integer port;
38-
private String password;
39-
private Duration timeout;
40-
private Pool pool;
23+
public class RediSearchAutoConfiguration {
4124

4225
@Bean(destroyMethod = "shutdown")
4326
ClientResources clientResources() {
4427
return DefaultClientResources.create();
4528
}
4629

4730
@Bean(destroyMethod = "shutdown")
48-
RediSearchClient client(ClientResources clientResources) {
49-
RedisURI redisURI = RedisURI.create(host(), port());
50-
String password = password();
51-
if (password != null) {
52-
redisURI.setPassword(password);
31+
RediSearchClient client(RedisProperties props, ClientResources clientResources) {
32+
RedisURI redisURI = RedisURI.create(props.getHost(), props.getPort());
33+
if (props.getPassword() != null) {
34+
redisURI.setPassword(props.getPassword());
5335
}
54-
Duration timeout = timeout();
36+
Duration timeout = props.getTimeout();
5537
if (timeout != null) {
5638
redisURI.setTimeout(timeout);
5739
}
@@ -64,13 +46,13 @@ StatefulRediSearchConnection<String, String> connection(RediSearchClient rediSea
6446
}
6547

6648
@Bean(name = "rediSearchConnectionPool", destroyMethod = "close")
67-
GenericObjectPool<StatefulRediSearchConnection<String, String>> rediSearchConnectionPool(
49+
GenericObjectPool<StatefulRediSearchConnection<String, String>> pool(RedisProperties props,
6850
RediSearchClient rediSearchClient) {
6951
GenericObjectPoolConfig<StatefulRediSearchConnection<String, String>> config = new GenericObjectPoolConfig<StatefulRediSearchConnection<String, String>>();
7052
config.setJmxEnabled(false);
7153
GenericObjectPool<StatefulRediSearchConnection<String, String>> pool = ConnectionPoolSupport
7254
.createGenericObjectPool(() -> rediSearchClient.connect(), config);
73-
Pool poolProps = pool();
55+
Pool poolProps = props.getLettuce().getPool();
7456
if (poolProps != null) {
7557
pool.setMaxTotal(poolProps.getMaxActive());
7658
pool.setMaxIdle(poolProps.getMaxIdle());
@@ -82,38 +64,4 @@ GenericObjectPool<StatefulRediSearchConnection<String, String>> rediSearchConnec
8264
return pool;
8365
}
8466

85-
private Pool pool() {
86-
if (pool == null) {
87-
return props.getLettuce().getPool();
88-
}
89-
return pool;
90-
}
91-
92-
private String host() {
93-
if (host == null) {
94-
return props.getHost();
95-
}
96-
return host;
97-
}
98-
99-
private int port() {
100-
if (port == null) {
101-
return props.getPort();
102-
}
103-
return port;
104-
}
105-
106-
private String password() {
107-
if (password == null) {
108-
return props.getPassword();
109-
}
110-
return password;
111-
}
112-
113-
private Duration timeout() {
114-
if (timeout == null) {
115-
return props.getTimeout();
116-
}
117-
return timeout;
118-
}
11967
}

0 commit comments

Comments
 (0)