You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue details how the v2 AWS SDK for Go's API client packages can be updated as a step towards improving generated serializers performance. The proposed changes in this design seek to improve the v2 SDK package layout to group service enums, types in their own respective packages.
We'd like to hear your feedback on this proposed refactor to the v2 SDK package layout.
Motivation
We aim to improve the generated serializers performance for the AWS SDK for Go. A step towards this goal is to create stand-alone operation serializer functions and reduce use of reflection/ run-time assertions in the SDK. This would require us to refactor the Service client package and group enums, types in their own respective packages to avoid cyclic dependencies in the Go SDK.
Currently, the Go SDK's API Client Package is cluttered with client operations, types, enums, errors and client specific customizations. The proposed change of moving the types, enums in their own respective packages would also help improve their discoverability.
Proposed Changes
We propose a refactor to the SDK's API Client package layout. The changes proposes splitting the API Client package in three primary packages with canonical dependency.
For example for s3 service, the three packages would be :
Package s3
Package types
Package enums
The dependency flow would be as follows:
Given a set of objects S and a transitive relation R ⊆ S × S with ( a , b ) ∈ R modeling a dependency "a depends on b"
S = { s3 pkg , types pkg , enums pkg}
R = {(s3 pkg , types pkg), (s3 pkg , enums pkg), (types pkg , enums pkg)}
s3 package will depend on both types and enums packages
types package might depend on enums packages.
The enums package would not depend on any of the above two packages. This packaging layout helps avoid circular reference
The proposed refactor of the SDK's API Client package would create a package layout as follows :
The following example invokes the Amazon S3 API Client's Create Bucket Request using the new types, enums package.
// To create a bucket in a specific region//// The following example creates a bucket. The request specifies an AWS region// where to create the bucket.package main
import (
"context""fmt""github.com/aws/aws-sdk-go-v2/aws""github.com/aws/aws-sdk-go-v2/aws/awserr""github.com/aws/aws-sdk-go-v2/service/s3""github.com/aws/aws-sdk-go-v2/service/s3/enums""github.com/aws/aws-sdk-go-v2/service/s3/types"
)
funcExampleClient_CreateBucketRequest() {
cfg, err:=external.LoadDefaultAWSConfig()
iferr!=nil {
panic("failed to load config, "+err.Error())
}
svc:=s3.New(cfg)
input:=&types.CreateBucketInput{
Bucket: aws.String("examplebucket"),
CreateBucketConfiguration: &types.CreateBucketConfiguration{
LocationConstraint: enums.BucketLocationConstraintEuWest1,
},
}
req:=svc.CreateBucketRequest(input)
result, err:=req.Send(context.Background())
iferr!=nil {
ifaerr, ok:=err.(awserr.Error); ok {
switchaerr.Code() {
cases3.ErrCodeBucketAlreadyExists:
fmt.Println(s3.ErrCodeBucketAlreadyExists, aerr.Error())
cases3.ErrCodeBucketAlreadyOwnedByYou:
fmt.Println(s3.ErrCodeBucketAlreadyOwnedByYou, aerr.Error())
default:
fmt.Println(aerr.Error())
}
} else {
// Print the error, cast err to awserr.Error to get the Code and// Message from an error.fmt.Println(err.Error())
}
return
}
fmt.Println(result)
}
We have created a PR #441 that includes this change.
The text was updated successfully, but these errors were encountered:
This issue details how the v2 AWS SDK for Go's API client packages can be updated as a step towards improving generated serializers performance. The proposed changes in this design seek to improve the v2 SDK package layout to group service enums, types in their own respective packages.
We'd like to hear your feedback on this proposed refactor to the v2 SDK package layout.
Motivation
We aim to improve the generated serializers performance for the AWS SDK for Go. A step towards this goal is to create stand-alone operation serializer functions and reduce use of reflection/ run-time assertions in the SDK. This would require us to refactor the Service client package and group enums, types in their own respective packages to avoid cyclic dependencies in the Go SDK.
Currently, the Go SDK's API Client Package is cluttered with client operations, types, enums, errors and client specific customizations. The proposed change of moving the types, enums in their own respective packages would also help improve their discoverability.
Proposed Changes
We propose a refactor to the SDK's API Client package layout. The changes proposes splitting the API Client package in three primary packages with canonical dependency.
For example for s3 service, the three packages would be :
The dependency flow would be as follows:
The enums package would not depend on any of the above two packages. This packaging layout helps avoid circular reference
The proposed refactor of the SDK's API Client package would create a package layout as follows :
Usage example
The following example invokes the Amazon S3 API Client's Create Bucket Request using the new types, enums package.
We have created a PR #441 that includes this change.
The text was updated successfully, but these errors were encountered: