-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathDbOptions.java
More file actions
42 lines (35 loc) · 1.2 KB
/
DbOptions.java
File metadata and controls
42 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package in.projecteka.consentmanager.properties;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.ConstructorBinding;
@ConstructorBinding
@ConfigurationProperties("consentmanager.db")
@Getter
@AllArgsConstructor
public class DbOptions {
private final String host;
private final int port;
private final String schema;
private final String user;
private final String password;
private final int poolSize;
private final boolean replicaReadEnabled;
private final Replica replica;
public Replica getReplica() {
return replica != null && replicaReadEnabled
? replica
: new Replica(host, port, user, password, getReadPoolSize());
}
private int getReadPoolSize() {
return poolSize / 2 + poolSize % 2;
}
public int getPoolSize() {
return replica != null && replicaReadEnabled
? poolSize
: poolSize / 2;
}
public in.projecteka.library.common.DbOptions toHeartBeat() {
return new in.projecteka.library.common.DbOptions(host, port);
}
}