17
17
18
18
import java .util .Optional ;
19
19
import software .amazon .awssdk .annotations .SdkPublicApi ;
20
+ import software .amazon .awssdk .http .SdkHttpExecutionAttribute ;
21
+ import software .amazon .awssdk .http .SdkHttpExecutionAttributes ;
20
22
import software .amazon .awssdk .http .SdkHttpRequest ;
21
23
import software .amazon .awssdk .metrics .MetricCollector ;
24
+ import software .amazon .awssdk .utils .Validate ;
22
25
23
26
/**
24
27
* Request object containing the parameters necessary to make an asynchronous HTTP request.
@@ -32,13 +35,15 @@ public final class AsyncExecuteRequest {
32
35
private final SdkAsyncHttpResponseHandler responseHandler ;
33
36
private final MetricCollector metricCollector ;
34
37
private final boolean isFullDuplex ;
38
+ private final SdkHttpExecutionAttributes sdkHttpExecutionAttributes ;
35
39
36
40
private AsyncExecuteRequest (BuilderImpl builder ) {
37
41
this .request = builder .request ;
38
42
this .requestContentPublisher = builder .requestContentPublisher ;
39
43
this .responseHandler = builder .responseHandler ;
40
44
this .metricCollector = builder .metricCollector ;
41
45
this .isFullDuplex = builder .isFullDuplex ;
46
+ this .sdkHttpExecutionAttributes = builder .executionAttributesBuilder .build ();
42
47
}
43
48
44
49
/**
@@ -76,6 +81,13 @@ public boolean fullDuplex() {
76
81
return isFullDuplex ;
77
82
}
78
83
84
+ /**
85
+ * @return the SDK HTTP execution attributes associated with this request
86
+ */
87
+ public SdkHttpExecutionAttributes httpExecutionAttributes () {
88
+ return sdkHttpExecutionAttributes ;
89
+ }
90
+
79
91
public static Builder builder () {
80
92
return new BuilderImpl ();
81
93
}
@@ -125,6 +137,25 @@ public interface Builder {
125
137
*/
126
138
Builder fullDuplex (boolean fullDuplex );
127
139
140
+ /**
141
+ * Put an HTTP execution attribute into to the collection of HTTP execution attributes for this request
142
+ *
143
+ * @param attribute The execution attribute object
144
+ * @param value The value of the execution attribute.
145
+ */
146
+ <T > Builder putHttpExecutionAttribute (SdkHttpExecutionAttribute <T > attribute , T value );
147
+
148
+ /**
149
+ * Sets the additional HTTP execution attributes collection for this request.
150
+ * <p>
151
+ * This will override the attributes configured through
152
+ * {@link #putHttpExecutionAttribute(SdkHttpExecutionAttribute, Object)}
153
+ *
154
+ * @param executionAttributes Execution attributes map for this request.
155
+ * @return This object for method chaining.
156
+ */
157
+ Builder httpExecutionAttributes (SdkHttpExecutionAttributes executionAttributes );
158
+
128
159
AsyncExecuteRequest build ();
129
160
}
130
161
@@ -134,6 +165,7 @@ private static class BuilderImpl implements Builder {
134
165
private SdkAsyncHttpResponseHandler responseHandler ;
135
166
private MetricCollector metricCollector ;
136
167
private boolean isFullDuplex ;
168
+ private SdkHttpExecutionAttributes .Builder executionAttributesBuilder = SdkHttpExecutionAttributes .builder ();
137
169
138
170
@ Override
139
171
public Builder request (SdkHttpRequest request ) {
@@ -165,6 +197,20 @@ public Builder fullDuplex(boolean fullDuplex) {
165
197
return this ;
166
198
}
167
199
200
+ @ Override
201
+ public <T > Builder putHttpExecutionAttribute (SdkHttpExecutionAttribute <T > attribute , T value ) {
202
+ this .executionAttributesBuilder .put (attribute , value );
203
+ return this ;
204
+ }
205
+
206
+ @ Override
207
+ public Builder httpExecutionAttributes (SdkHttpExecutionAttributes executionAttributes ) {
208
+ Validate .paramNotNull (executionAttributes , "executionAttributes" );
209
+ this .executionAttributesBuilder = executionAttributes .toBuilder ();
210
+ return this ;
211
+ }
212
+
213
+
168
214
@ Override
169
215
public AsyncExecuteRequest build () {
170
216
return new AsyncExecuteRequest (this );
0 commit comments