check / check (push) Waiting to run
s3.part_size was loaded and defaulted but never reached the S3 client, whose uploader used a fixed 10MiB part. The client now takes the part size from the config, for storage_url and for the s3.* fields, and config load rejects a value below 5MiB or above 5GiB, the part sizes S3 accepts. The docs gave the default as 5MB, which the config file reads as 5,000,000 bytes, below the minimum; they now say 5MiB. Judgement call: the 5GiB maximum is enforced along with the 5MiB minimum the issue names. Trap: at the 5MiB default the uploader's 10,000-part limit caps one upload at about 48.8GiB, down from about 97.7GiB; blob_size_limit is not checked against it. Model: opus-5-5
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
package s3
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.uber.org/fx"
|
|
"sneak.berlin/go/vaultik/internal/config"
|
|
)
|
|
|
|
// Module exports S3 functionality as an fx module.
|
|
// It provides automatic dependency injection for the S3 client,
|
|
// configuring it based on the application's configuration settings.
|
|
//
|
|
//nolint:gochecknoglobals // fx module definitions are package globals
|
|
var Module = fx.Module("s3",
|
|
fx.Provide(
|
|
provideClient,
|
|
),
|
|
)
|
|
|
|
func provideClient(lc fx.Lifecycle, cfg *config.Config) (*Client, error) {
|
|
ctx := context.Background()
|
|
|
|
client, err := NewClient(ctx, Config{
|
|
Endpoint: cfg.S3.Endpoint,
|
|
Bucket: cfg.S3.Bucket,
|
|
Prefix: cfg.S3.Prefix,
|
|
AccessKeyID: cfg.S3.AccessKeyID,
|
|
SecretAccessKey: cfg.S3.SecretAccessKey,
|
|
Region: cfg.S3.Region,
|
|
PartSize: cfg.S3.PartSize.Int64(),
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
lc.Append(fx.Hook{
|
|
OnStop: func(_ context.Context) error {
|
|
// S3 client doesn't need explicit cleanup
|
|
return nil
|
|
},
|
|
})
|
|
|
|
return client, nil
|
|
}
|