Skip to content

CRT HTTP/1 GA - Surface Area Updates - Renaming #3708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/next-release/feature-AWSCRTHTTPClient-61e1148.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"category": "AWS CRT HTTP Client",
"contributor": "",
"type": "feature",
"description": "Renamed: `ConnectionHealthChecksConfiguration` -> `ConnectionHealthConfiguration`\nRenamed: `allowableThroughputFailureInterval` -> `minimumThroughputTimeout`\nRenamed: `minThroughputInBytesPerSecond` -> `minimumThroughputInBps`\nRenamed: `AwsCrtAsyncHttpClient.builder().connectionHealthChecksConfiguration` -> `AwsCrtAsyncHttpClient.builder().connectionHealthConfiguration`"
}
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,20 @@ private AwsCrtAsyncHttpClient(DefaultBuilder builder, AttributeMap config) {
this.tlsContext = registerOwnedResource(clientTlsContext);
this.readBufferSize = builder.readBufferSize == null ? DEFAULT_STREAM_WINDOW_SIZE : builder.readBufferSize;
this.maxConnectionsPerEndpoint = config.get(SdkHttpConfigurationOption.MAX_CONNECTIONS);
this.monitoringOptions = revolveHttpMonitoringOptions(builder.connectionHealthChecksConfiguration);
this.monitoringOptions = revolveHttpMonitoringOptions(builder.connectionHealthConfiguration);
this.maxConnectionIdleInMilliseconds = config.get(SdkHttpConfigurationOption.CONNECTION_MAX_IDLE_TIMEOUT).toMillis();
this.proxyOptions = buildProxyOptions(builder.proxyConfiguration);
}
}

private HttpMonitoringOptions revolveHttpMonitoringOptions(ConnectionHealthChecksConfiguration config) {
private HttpMonitoringOptions revolveHttpMonitoringOptions(ConnectionHealthConfiguration config) {
if (config == null) {
return null;
}

HttpMonitoringOptions httpMonitoringOptions = new HttpMonitoringOptions();
httpMonitoringOptions.setMinThroughputBytesPerSecond(config.minThroughputInBytesPerSecond());
int seconds = (int) config.allowableThroughputFailureInterval().getSeconds();
httpMonitoringOptions.setMinThroughputBytesPerSecond(config.minimumThroughputInBps());
int seconds = (int) config.minimumThroughputTimeout().getSeconds();
httpMonitoringOptions.setAllowableThroughputFailureIntervalSeconds(seconds);
return httpMonitoringOptions;
}
Expand Down Expand Up @@ -355,25 +355,25 @@ public interface Builder extends SdkAsyncHttpClient.Builder<AwsCrtAsyncHttpClien
*
* <p>
* You can set a throughput threshold for a connection to be considered healthy.
* If a connection falls below this threshold ({@link ConnectionHealthChecksConfiguration#minThroughputInBytesPerSecond()
* If a connection falls below this threshold ({@link ConnectionHealthConfiguration#minimumThroughputInBps()
* }) for the configurable amount
* of time ({@link ConnectionHealthChecksConfiguration#allowableThroughputFailureInterval()}),
* of time ({@link ConnectionHealthConfiguration#minimumThroughputTimeout()}),
* then the connection is considered unhealthy and will be shut down.
*
* @param healthChecksConfiguration The health checks config to use
* @return The builder of the method chaining.
*/
Builder connectionHealthChecksConfiguration(ConnectionHealthChecksConfiguration healthChecksConfiguration);
Builder connectionHealthConfiguration(ConnectionHealthConfiguration healthChecksConfiguration);

/**
* A convenience method that creates an instance of the {@link ConnectionHealthChecksConfiguration} builder, avoiding the
* need to create one manually via {@link ConnectionHealthChecksConfiguration#builder()}.
* A convenience method that creates an instance of the {@link ConnectionHealthConfiguration} builder, avoiding the
* need to create one manually via {@link ConnectionHealthConfiguration#builder()}.
*
* @param healthChecksConfigurationBuilder The health checks config builder to use
* @return The builder of the method chaining.
* @see #connectionHealthChecksConfiguration(ConnectionHealthChecksConfiguration)
* @see #connectionHealthConfiguration(ConnectionHealthConfiguration)
*/
Builder connectionHealthChecksConfiguration(Consumer<ConnectionHealthChecksConfiguration.Builder>
Builder connectionHealthConfiguration(Consumer<ConnectionHealthConfiguration.Builder>
healthChecksConfigurationBuilder);

/**
Expand Down Expand Up @@ -428,7 +428,7 @@ private static final class DefaultBuilder implements Builder {
private final AttributeMap.Builder standardOptions = AttributeMap.builder();
private Integer readBufferSize;
private ProxyConfiguration proxyConfiguration;
private ConnectionHealthChecksConfiguration connectionHealthChecksConfiguration;
private ConnectionHealthConfiguration connectionHealthConfiguration;
private TcpKeepAliveConfiguration tcpKeepAliveConfiguration;

private DefaultBuilder() {
Expand Down Expand Up @@ -470,17 +470,17 @@ public Builder proxyConfiguration(ProxyConfiguration proxyConfiguration) {
}

@Override
public Builder connectionHealthChecksConfiguration(ConnectionHealthChecksConfiguration monitoringOptions) {
this.connectionHealthChecksConfiguration = monitoringOptions;
public Builder connectionHealthConfiguration(ConnectionHealthConfiguration monitoringOptions) {
this.connectionHealthConfiguration = monitoringOptions;
return this;
}

@Override
public Builder connectionHealthChecksConfiguration(Consumer<ConnectionHealthChecksConfiguration.Builder>
public Builder connectionHealthConfiguration(Consumer<ConnectionHealthConfiguration.Builder>
configurationBuilder) {
ConnectionHealthChecksConfiguration.Builder builder = ConnectionHealthChecksConfiguration.builder();
ConnectionHealthConfiguration.Builder builder = ConnectionHealthConfiguration.builder();
configurationBuilder.accept(builder);
return connectionHealthChecksConfiguration(builder.build());
return connectionHealthConfiguration(builder.build());
}

@Override
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

package software.amazon.awssdk.http.crt;

import java.time.Duration;
import software.amazon.awssdk.annotations.SdkPreviewApi;
import software.amazon.awssdk.annotations.SdkPublicApi;
import software.amazon.awssdk.utils.Validate;

/**
* Configuration that defines health checks for all connections established by
* the {@link ConnectionHealthConfiguration}.
*
* <b>NOTE:</b> This is a Preview API and is subject to change so it should not be used in production.
*/
@SdkPublicApi
@SdkPreviewApi
public final class ConnectionHealthConfiguration {
private final long minimumThroughputInBps;
private final Duration minimumThroughputTimeout;

private ConnectionHealthConfiguration(DefaultConnectionHealthConfigurationBuilder builder) {
this.minimumThroughputInBps = Validate.paramNotNull(builder.minimumThroughputInBps,
"minimumThroughputInBps");
this.minimumThroughputTimeout = Validate.isPositive(builder.minimumThroughputTimeout,
"minimumThroughputTimeout");
}

/**
* @return the minimum amount of throughput, in bytes per second, for a connection to be considered healthy.
*/
public long minimumThroughputInBps() {
return minimumThroughputInBps;
}

/**
* @return How long a connection is allowed to be unhealthy before getting shut down.
*/
public Duration minimumThroughputTimeout() {
return minimumThroughputTimeout;
}

public static Builder builder() {
return new DefaultConnectionHealthConfigurationBuilder();
}

/**
* A builder for {@link ConnectionHealthConfiguration}.
*
* <p>All implementations of this interface are mutable and not thread safe.</p>
*/
public interface Builder {

/**
* Sets a throughput threshold for connections. Throughput below this value will be considered unhealthy.
*
* @param minimumThroughputInBps minimum amount of throughput, in bytes per second, for a connection to be
* considered healthy.
* @return Builder
*/
Builder minimumThroughputInBps(Long minimumThroughputInBps);

/**
* Sets how long a connection is allowed to be unhealthy before getting shut down.
*
* <p>
* It only supports seconds precision
*
* @param minimumThroughputTimeout How long a connection is allowed to be unhealthy
* before getting shut down.
* @return Builder
*/
Builder minimumThroughputTimeout(Duration minimumThroughputTimeout);

ConnectionHealthConfiguration build();
}

/**
* An SDK-internal implementation of {@link Builder}.
*/
private static final class DefaultConnectionHealthConfigurationBuilder implements Builder {
private Long minimumThroughputInBps;
private Duration minimumThroughputTimeout;

private DefaultConnectionHealthConfigurationBuilder() {
}

@Override
public Builder minimumThroughputInBps(Long minimumThroughputInBps) {
this.minimumThroughputInBps = minimumThroughputInBps;
return this;
}

@Override
public Builder minimumThroughputTimeout(Duration minimumThroughputTimeout) {
this.minimumThroughputTimeout = minimumThroughputTimeout;
return this;
}

@Override
public ConnectionHealthConfiguration build() {
return new ConnectionHealthConfiguration(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public class AwsCrtHttpClientSpiVerificationTest {
@BeforeClass
public static void setup() throws Exception {
client = AwsCrtAsyncHttpClient.builder()
.connectionHealthChecksConfiguration(b -> b.minThroughputInBytesPerSecond(4068L)
.allowableThroughputFailureInterval(Duration.ofSeconds(3)))
.connectionHealthConfiguration(b -> b.minimumThroughputInBps(4068L)
.minimumThroughputTimeout(Duration.ofSeconds(3)))
.build();
}

Expand Down
Loading