goamz icon indicating copy to clipboard operation
goamz copied to clipboard

s3: Move AttemptStrategy into S3 object so callers can change, replace

Open client9 opened this issue 11 years ago • 4 comments

Hi Hashicorp team. Thanks for all your projects and products.

The hardwired default of S3 attempts is a bit problematic for me.

In:

// The S3 type encapsulates operations with an S3 region.
type S3 struct {
    aws.Auth
    aws.Region
    private byte // Reserve the right of using private data.
}

add

Attempts *aws.AttemptStrategy

Then change new to point to the current default attempts that is private and hardwired

func New(auth aws.Auth, region aws.Region) *S3 {
    return &S3{auth, region, 0, &attempts}
}

The caller could then point to another aws.AttemptStrategy objects as needed.

We could also change the New api as well but this seemed like the dumbest solution that unblocks everything.

If ok, then I'll proceed with a pull request.

thanks again!

nickg

client9 avatar Sep 24 '14 07:09 client9

i think that if we change attempts->Attempts, then the user can replace the strategy with another one after import. For example:

import "github.com/mitchellh/goamz/s3"

// swap default attempt strategy with another one
s3.Attempts = aws.AttemptStrategy{
    Min:   10,
    Total: 10 * time.Second,
    Delay: 500 * time.Millisecond,
}

is this your usecase @client9 ?

dqminh avatar Sep 24 '14 07:09 dqminh

oh nice, yeah that will work.

thanks and closing!

client9 avatar Sep 24 '14 08:09 client9

Argh.

attempts is a private variable (lower case) If it were capital then the solution by @dqminh would work.

client9 avatar Sep 24 '14 08:09 client9

See also #80

client9 avatar Sep 24 '14 08:09 client9