This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var timeout time.Time = 30 * time.Millisecond | |
| var maxRetry int = 3 | |
| func queryWithRetry(ctx context.Context, input *dynamodb.QueryInput) (*dynamodb.QueryOutput, error) { | |
| for i := 0; i < maxRetry; i++ { | |
| res, err := func() (*dynamodb.QueryOutput, error) { | |
| timeoutCtx, cancel := context.WithTimeout(ctx, timeout) | |
| defer cancel() | |
| return dynamoDB.Query(input) | |
| }() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| const ( | |
| envAWSEndpoint = "AWS_ENDPOINT" | |
| envAWSRegion = "AWS_REGION" | |
| ) | |
| func main() { | |
| endPoint := os.Getenv(envAWSEndpoint) | |
| region := os.Getenv(envAWSRegion) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| "sync" | |
| "time" | |
| "github.com/aws/aws-sdk-go/aws" | |
| "github.com/aws/aws-sdk-go/aws/credentials" | |
| "github.com/aws/aws-sdk-go/aws/session" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var startTime time.Time | |
| trace := &httptrace.ClientTrace { | |
| TLSHandshakeStart: func() { | |
| startTime = time.Now() | |
| }, | |
| TLSHandshakeDone: func(s tls.ConnectionState, err error) { | |
| fmt.Sprintf("%v elapsed", time.Now() - startTime) | |
| }, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| const ( | |
| envAWSEndpoint = "AWS_ENDPOINT" | |
| envAWSRegion = "AWS_REGION" | |
| ) | |
| func main() { | |
| endPoint := os.Getenv(envAWSEndpoint) | |
| region := os.Getenv(envAWSRegion) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "github.com/mitchellh/mapstructure" | |
| "github.com/spf13/viper" | |
| ) | |
| type Config struct { | |
| MysqlHost string `mapstructure:"MYSQL_HOST"` | |
| LogLevel string `mapstructure:"LOG_LEVEL"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "context" | |
| "sync" | |
| "time" | |
| "github.com/aws/aws-sdk-go/aws/credentials" | |
| ) |