forked from awslabs/amazon-sqs-java-temporary-queues-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AmazonSQSRequesterClientBuilder.java
126 lines (95 loc) · 3.92 KB
/
AmazonSQSRequesterClientBuilder.java
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.amazonaws.services.sqs;
import com.amazonaws.services.sqs.util.Constants;
import software.amazon.awssdk.services.sqs.SqsClient;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
public class AmazonSQSRequesterClientBuilder {
private Optional<SqsClient> customSQS = Optional.empty();
private String internalQueuePrefix = "__RequesterClientQueues__";
private Map<String, String> queueAttributes = Collections.emptyMap();
private int idleQueueSweepingPeriod = 5;
private long queueHeartbeatInterval = Constants.HEARTBEAT_INTERVAL_SECONDS_DEFAULT;
private TimeUnit idleQueueSweepingTimeUnit = TimeUnit.MINUTES;
private long idleQueueRetentionPeriodSeconds = AmazonSQSTemporaryQueuesClientBuilder.IDLE_QUEUE_RETENTION_PERIOD_SECONDS_DEFAULT;
private AmazonSQSRequesterClientBuilder() {
}
/**
* @return Create new instance of builder with all defaults set.
*/
public static AmazonSQSRequesterClientBuilder standard() {
return new AmazonSQSRequesterClientBuilder();
}
public static AmazonSQSRequester defaultClient() {
return standard().build();
}
public Optional<SqsClient> getAmazonSQS() {
return customSQS;
}
public void setAmazonSQS(SqsClient sqs) {
this.customSQS = Optional.of(sqs);
}
public AmazonSQSRequesterClientBuilder withAmazonSQS(SqsClient sqs) {
setAmazonSQS(sqs);
return this;
}
public String getInternalQueuePrefix() {
return internalQueuePrefix;
}
public void setInternalQueuePrefix(String internalQueuePrefix) {
this.internalQueuePrefix = internalQueuePrefix;
}
public AmazonSQSRequesterClientBuilder withInternalQueuePrefix(String internalQueuePrefix) {
setInternalQueuePrefix(internalQueuePrefix);
return this;
}
public Map<String, String> getQueueAttributes() {
return Collections.unmodifiableMap(queueAttributes);
}
public void setQueueAttributes(Map<String, String> queueAttributes) {
this.queueAttributes = new HashMap<>(queueAttributes);
}
public AmazonSQSRequesterClientBuilder withQueueAttributes(Map<String, String> queueAttributes) {
setQueueAttributes(queueAttributes);
return this;
}
public int getIdleQueueSweepingPeriod() {
return idleQueueSweepingPeriod;
}
public TimeUnit getIdleQueueSweepingTimeUnit() {
return idleQueueSweepingTimeUnit;
}
public void setIdleQueueSweepingPeriod(int period, TimeUnit timeUnit) {
this.idleQueueSweepingPeriod = period;
this.idleQueueSweepingTimeUnit = timeUnit;
}
public AmazonSQSRequesterClientBuilder withIdleQueueSweepingPeriod(int period, TimeUnit timeUnit) {
setIdleQueueSweepingPeriod(period, timeUnit);
return this;
}
public long getIdleQueueRetentionPeriodSeconds() {
return idleQueueRetentionPeriodSeconds;
}
public void setIdleQueueRetentionPeriodSeconds(long idleQueueRetentionPeriodSeconds) {
this.idleQueueRetentionPeriodSeconds = idleQueueRetentionPeriodSeconds;
}
public AmazonSQSRequesterClientBuilder withIdleQueueRetentionPeriodSeconds(long idleQueueRetentionPeriodSeconds) {
setIdleQueueRetentionPeriodSeconds(idleQueueRetentionPeriodSeconds);
return this;
}
public long getQueueHeartbeatInterval() {
return queueHeartbeatInterval;
}
public void setQueueHeartbeatInterval(long heartbeatIntervalSeconds) {
this.queueHeartbeatInterval = heartbeatIntervalSeconds;
}
public AmazonSQSRequesterClientBuilder withQueueHeartbeatInterval(long heartbeatIntervalSeconds) {
setQueueHeartbeatInterval(heartbeatIntervalSeconds);
return this;
}
public AmazonSQSRequester build() {
return AmazonSQSTemporaryQueuesClient.make(this).getRequester();
}
}