Skip to content

Commit 3c185e4

Browse files
committed
use aws http client builder and add back aws cfg settings
1 parent cd834f6 commit 3c185e4

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ require (
3232
)
3333

3434
require (
35-
github.com/aws/aws-sdk-go-v2 v1.26.1
35+
github.com/aws/aws-sdk-go-v2 v1.26.2
3636
github.com/aws/aws-sdk-go-v2/config v1.27.13
3737
github.com/aws/aws-sdk-go-v2/service/timestreamquery v1.23.1
3838
github.com/aws/aws-sdk-go-v2/service/timestreamwrite v1.25.6

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
github.com/aws/aws-sdk-go-v2 v1.26.1 h1:5554eUqIYVWpU0YmeeYZ0wU64H2VLBs8TlhRB2L+EkA=
2-
github.com/aws/aws-sdk-go-v2 v1.26.1/go.mod h1:ffIFB97e2yNsv4aTSGkqtHnppsIJzw7G7BReUZ3jCXM=
1+
github.com/aws/aws-sdk-go-v2 v1.26.2 h1:OTRAL8EPdNoOdiq5SUhCaHhVPBU2wxAUe5uwasoJGRM=
2+
github.com/aws/aws-sdk-go-v2 v1.26.2/go.mod h1:ffIFB97e2yNsv4aTSGkqtHnppsIJzw7G7BReUZ3jCXM=
33
github.com/aws/aws-sdk-go-v2/config v1.27.13 h1:WbKW8hOzrWoOA/+35S5okqO/2Ap8hkkFUzoW8Hzq24A=
44
github.com/aws/aws-sdk-go-v2/config v1.27.13/go.mod h1:XLiyiTMnguytjRER7u5RIkhIqS8Nyz41SwAWb4xEjxs=
55
github.com/aws/aws-sdk-go-v2/credentials v1.17.13 h1:XDCJDzk/u5cN7Aple7D/MiAhx1Rjo/0nueJ0La8mRuE=

timestream.go

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ import (
2222
"context"
2323
"fmt"
2424
"math"
25-
"net"
2625
"net/http"
2726
"strconv"
2827
"strings"
2928
"time"
3029

3130
"github.com/aws/aws-sdk-go-v2/aws"
31+
awshttp "github.com/aws/aws-sdk-go-v2/aws/transport/http"
3232
"github.com/aws/aws-sdk-go-v2/config"
3333
"github.com/aws/aws-sdk-go-v2/service/timestreamquery"
3434
"github.com/aws/aws-sdk-go-v2/service/timestreamwrite"
@@ -82,25 +82,18 @@ func newTimestreamQueryPaginator(client TimestreamQueryApi, params *timestreamqu
8282
}
8383

8484
func newTimeStreamAdapter(ctx context.Context, logger *zap.SugaredLogger, cfg *adapterCfg, newQueryPaginator NewQueryPaginator, writeSvc *timestreamwrite.Client, querySvc *timestreamquery.Client) TimeStreamAdapter {
85-
tr := &http.Transport{
86-
ResponseHeaderTimeout: 20 * time.Second,
87-
// Using DefaultTransport values for other parameters: https://golang.org/pkg/net/http/#RoundTripper
88-
Proxy: http.ProxyFromEnvironment,
89-
DialContext: (&net.Dialer{
90-
KeepAlive: 30 * time.Second,
91-
Timeout: 30 * time.Second,
92-
}).DialContext,
93-
MaxIdleConns: 100,
94-
IdleConnTimeout: 90 * time.Second,
95-
TLSHandshakeTimeout: 10 * time.Second,
96-
ExpectContinueTimeout: 1 * time.Second,
97-
}
85+
if writeSvc == nil || querySvc == nil {
86+
client := awshttp.NewBuildableClient().WithTransportOptions(func(tr *http.Transport) {
87+
tr.ResponseHeaderTimeout = 20 * time.Second
9888

99-
// So client makes HTTP/2 requests
100-
_ = http2.ConfigureTransport(tr)
89+
// Enable HTTP/2
90+
err := http2.ConfigureTransport(tr)
91+
if err != nil {
92+
logger.Fatalw("Unable to configure HTTP/2 transport", "error", err)
93+
}
94+
})
10195

102-
if writeSvc == nil || querySvc == nil {
103-
awsCfg, err := config.LoadDefaultConfig(ctx, config.WithRegion(cfg.awsRegion))
96+
awsCfg, err := config.LoadDefaultConfig(ctx, config.WithRegion(cfg.awsRegion), config.WithHTTPClient(client), config.WithRetryMaxAttempts(10))
10497
if err != nil {
10598
logger.Fatalw("Unable to load AWS SDK config", "error", err)
10699
}

0 commit comments

Comments
 (0)