MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / createBucketClient

Method createBucketClient

storage/s3/storage.go:124–150  ·  view source on GitHub ↗
(bucket, region string)

Source from the content-addressed store, hash-verified

122}
123
124func (t *Storage) createBucketClient(bucket, region string) (s3Client, error) {
125 t.mu.Lock()
126 defer t.mu.Unlock()
127
128 // Check again if someone did this before us
129 if client := t.clientsByBucket[bucket]; client != nil {
130 return client, nil
131 }
132
133 if client := t.clientsByRegion[region]; client != nil {
134 t.clientsByBucket[bucket] = client
135 return client, nil
136 }
137
138 conf := t.defaultConfig.Copy()
139 conf.Region = region
140
141 client, err := createClient(conf, t.clientOptions, t.config)
142 if err != nil {
143 return nil, errctx.Wrap(err, errctx.WithPrefix("can't create regional S3 client"))
144 }
145
146 t.clientsByRegion[region] = client
147 t.clientsByBucket[bucket] = client
148
149 return client, nil
150}
151
152func createClient(conf aws.Config, opts []func(*s3.Options), config *Config) (s3Client, error) {
153 client := s3.NewFromConfig(conf, opts...)

Callers 1

callWithClientFunction · 0.80

Calls 3

WrapFunction · 0.92
WithPrefixFunction · 0.92
createClientFunction · 0.85

Tested by

no test coverage detected