@@ -25,31 +25,13 @@ type Config struct {
2525
2626 // The maximum number of bytes that the Writer will attempt to send in a single request.
2727 // https://pkg.go.dev/cloud.google.com/go/storage#Writer
28- ChunkSize int `bson:"chunkSize,omitempty" json:"chunkSize,omitempty" yaml:"chunkSize,omitempty"`
29- MaxObjSizeGB * float64 `bson:"maxObjSizeGB,omitempty" json:"maxObjSizeGB,omitempty" yaml:"maxObjSizeGB,omitempty"`
30-
31- ParallelUpload * ParallelUpload `bson:"parallelUpload,omitempty" json:"parallelUpload,omitempty" yaml:"parallelUpload,omitempty"`
28+ ChunkSize int `bson:"chunkSize,omitempty" json:"chunkSize,omitempty" yaml:"chunkSize,omitempty"`
29+ ParallelUploadConcurrency int `bson:"parallelUploadConcurrency,omitempty" json:"parallelUploadConcurrency,omitempty" yaml:"parallelUploadConcurrency,omitempty"`
30+ MaxObjSizeGB * float64 `bson:"maxObjSizeGB,omitempty" json:"maxObjSizeGB,omitempty" yaml:"maxObjSizeGB,omitempty"`
3231
3332 Retryer * Retryer `bson:"retryer,omitempty" json:"retryer,omitempty" yaml:"retryer,omitempty"`
3433}
3534
36- // ParallelUpload configures the experimental Google Cloud Storage parallel upload feature.
37- //
38- // Parallel uploads are supported only by the Google SDK gRPC client.
39- // HMAC credentials continue to use the MinIO client and are not affected by this setting.
40- type ParallelUpload struct {
41- // Enabled enables Writer parallel uploads when clientType is grpc.
42- Enabled bool `bson:"enabled,omitempty" json:"enabled,omitempty" yaml:"enabled,omitempty"`
43-
44- // PartSize is the size of each temporary part in bytes.
45- // If unset, PBM uses the computed ChunkSize for the uploaded object.
46- PartSize int `bson:"partSize,omitempty" json:"partSize,omitempty" yaml:"partSize,omitempty"`
47-
48- // MaxConcurrency is the number of goroutines used to upload parts in parallel.
49- // If unset, the Google SDK chooses a value based on the number of CPUs.
50- MaxConcurrency int `bson:"maxConcurrency,omitempty" json:"maxConcurrency,omitempty" yaml:"maxConcurrency,omitempty"`
51- }
52-
5335//nolint:lll
5436type Credentials struct {
5537 // Workload Identity Federation (allows missing JSON/HMAC credentials)
@@ -100,10 +82,6 @@ func (cfg *Config) Clone() *Config {
10082 v := * cfg .MaxObjSizeGB
10183 rv .MaxObjSizeGB = & v
10284 }
103- if cfg .ParallelUpload != nil {
104- v := * cfg .ParallelUpload
105- rv .ParallelUpload = & v
106- }
10785 if cfg .Retryer != nil {
10886 v := * cfg .Retryer
10987 rv .Retryer = & v
@@ -129,10 +107,10 @@ func (cfg *Config) Equal(other *Config) bool {
129107 if cfg .ChunkSize != other .ChunkSize {
130108 return false
131109 }
132- if ! reflect . DeepEqual ( cfg .MaxObjSizeGB , other .MaxObjSizeGB ) {
110+ if cfg .ParallelUploadConcurrency != other .ParallelUploadConcurrency {
133111 return false
134112 }
135- if ! reflect .DeepEqual (cfg .ParallelUpload , other .ParallelUpload ) {
113+ if ! reflect .DeepEqual (cfg .MaxObjSizeGB , other .MaxObjSizeGB ) {
136114 return false
137115 }
138116 if ! reflect .DeepEqual (cfg .Credentials , other .Credentials ) {
@@ -173,17 +151,11 @@ func (cfg *Config) Cast() error {
173151 return errors .Errorf ("invalid clientType %q" , cfg .ClientType )
174152 }
175153
176- if cfg .ChunkSize == 0 {
177- cfg .ChunkSize = defaultChunkSize
154+ if cfg .ChunkSize == 0 && cfg . parallelUploadEnabled () {
155+ cfg .ChunkSize = defaultParallelUploadChunkSize
178156 }
179-
180- if cfg .ParallelUpload != nil {
181- if cfg .ParallelUpload .PartSize < 0 {
182- return errors .New ("parallelUpload.partSize cannot be negative" )
183- }
184- if cfg .ParallelUpload .MaxConcurrency < 0 {
185- return errors .New ("parallelUpload.maxConcurrency cannot be negative" )
186- }
157+ if cfg .ChunkSize == 0 && ! cfg .parallelUploadEnabled () {
158+ cfg .ChunkSize = defaultChunkSize
187159 }
188160
189161 if cfg .Retryer == nil {
@@ -223,5 +195,5 @@ func (cfg *Config) GetMaxObjSizeGB() float64 {
223195}
224196
225197func (cfg * Config ) parallelUploadEnabled () bool {
226- return cfg .ClientType == ClientTypeGRPC && cfg .ParallelUpload != nil && cfg . ParallelUpload . Enabled
198+ return cfg .ClientType == ClientTypeGRPC && cfg .ParallelUploadConcurrency > 1
227199}
0 commit comments