mirror of
https://github.com/distribution/distribution.git
synced 2025-09-08 02:09:39 +00:00
Bump google storage module
Also bump the golangci version Signed-off-by: Milos Gajdos <milosthegajdos@gmail.com>
This commit is contained in:
138
vendor/cloud.google.com/go/storage/option.go
generated
vendored
138
vendor/cloud.google.com/go/storage/option.go
generated
vendored
@@ -15,15 +15,67 @@
|
||||
package storage
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"cloud.google.com/go/storage/experimental"
|
||||
storageinternal "cloud.google.com/go/storage/internal"
|
||||
"google.golang.org/api/option"
|
||||
"google.golang.org/api/option/internaloption"
|
||||
)
|
||||
|
||||
const (
|
||||
dynamicReadReqIncreaseRateEnv = "DYNAMIC_READ_REQ_INCREASE_RATE"
|
||||
dynamicReadReqInitialTimeoutEnv = "DYNAMIC_READ_REQ_INITIAL_TIMEOUT"
|
||||
defaultDynamicReadReqIncreaseRate = 15.0
|
||||
defaultDynamicReqdReqMaxTimeout = 1 * time.Hour
|
||||
defaultDynamicReadReqMinTimeout = 500 * time.Millisecond
|
||||
defaultTargetPercentile = 0.99
|
||||
)
|
||||
|
||||
func init() {
|
||||
// initialize experimental option.
|
||||
storageinternal.WithReadStallTimeout = withReadStallTimeout
|
||||
}
|
||||
|
||||
// getDynamicReadReqIncreaseRateFromEnv returns the value set in the env variable.
|
||||
// It returns defaultDynamicReadReqIncreaseRate if env is not set or the set value is invalid.
|
||||
func getDynamicReadReqIncreaseRateFromEnv() float64 {
|
||||
increaseRate := os.Getenv(dynamicReadReqIncreaseRateEnv)
|
||||
if increaseRate == "" {
|
||||
return defaultDynamicReadReqIncreaseRate
|
||||
}
|
||||
|
||||
val, err := strconv.ParseFloat(increaseRate, 64)
|
||||
if err != nil {
|
||||
return defaultDynamicReadReqIncreaseRate
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
// getDynamicReadReqInitialTimeoutSecFromEnv returns the value set in the env variable.
|
||||
// It returns the passed defaultVal if env is not set or the set value is invalid.
|
||||
func getDynamicReadReqInitialTimeoutSecFromEnv(defaultVal time.Duration) time.Duration {
|
||||
initialTimeout := os.Getenv(dynamicReadReqInitialTimeoutEnv)
|
||||
if initialTimeout == "" {
|
||||
return defaultVal
|
||||
}
|
||||
|
||||
val, err := time.ParseDuration(initialTimeout)
|
||||
if err != nil {
|
||||
return defaultVal
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
// storageConfig contains the Storage client option configuration that can be
|
||||
// set through storageClientOptions.
|
||||
type storageConfig struct {
|
||||
useJSONforReads bool
|
||||
readAPIWasSet bool
|
||||
useJSONforReads bool
|
||||
readAPIWasSet bool
|
||||
disableClientMetrics bool
|
||||
readStallTimeoutConfig *experimental.ReadStallTimeoutConfig
|
||||
}
|
||||
|
||||
// newStorageConfig generates a new storageConfig with all the given
|
||||
@@ -44,10 +96,14 @@ type storageClientOption interface {
|
||||
ApplyStorageOpt(*storageConfig)
|
||||
}
|
||||
|
||||
// WithJSONReads is an option that may be passed to a Storage Client on creation.
|
||||
// It sets the client to use the JSON API for object reads. Currently, the
|
||||
// default API used for reads is XML.
|
||||
// Setting this option is required to use the GenerationNotMatch condition.
|
||||
// WithJSONReads is an option that may be passed to [NewClient].
|
||||
// It sets the client to use the Cloud Storage JSON API for object
|
||||
// reads. Currently, the default API used for reads is XML, but JSON will
|
||||
// become the default in a future release.
|
||||
//
|
||||
// Setting this option is required to use the GenerationNotMatch condition. We
|
||||
// also recommend using JSON reads to ensure consistency with other client
|
||||
// operations (all of which use JSON by default).
|
||||
//
|
||||
// Note that when this option is set, reads will return a zero date for
|
||||
// [ReaderObjectAttrs].LastModified and may return a different value for
|
||||
@@ -56,10 +112,11 @@ func WithJSONReads() option.ClientOption {
|
||||
return &withReadAPI{useJSON: true}
|
||||
}
|
||||
|
||||
// WithXMLReads is an option that may be passed to a Storage Client on creation.
|
||||
// It sets the client to use the JSON API for object reads.
|
||||
// WithXMLReads is an option that may be passed to [NewClient].
|
||||
// It sets the client to use the Cloud Storage XML API for object reads.
|
||||
//
|
||||
// This is the current default.
|
||||
// This is the current default, but the default will switch to JSON in a future
|
||||
// release.
|
||||
func WithXMLReads() option.ClientOption {
|
||||
return &withReadAPI{useJSON: false}
|
||||
}
|
||||
@@ -73,3 +130,66 @@ func (w *withReadAPI) ApplyStorageOpt(c *storageConfig) {
|
||||
c.useJSONforReads = w.useJSON
|
||||
c.readAPIWasSet = true
|
||||
}
|
||||
|
||||
type withDisabledClientMetrics struct {
|
||||
internaloption.EmbeddableAdapter
|
||||
disabledClientMetrics bool
|
||||
}
|
||||
|
||||
// WithDisabledClientMetrics is an option that may be passed to [NewClient].
|
||||
// gRPC metrics are enabled by default in the GCS client and will export the
|
||||
// gRPC telemetry discussed in [gRFC/66] and [gRFC/78] to
|
||||
// [Google Cloud Monitoring]. The option is used to disable metrics.
|
||||
// Google Cloud Support can use this information to more quickly diagnose
|
||||
// problems related to GCS and gRPC.
|
||||
// Sending this data does not incur any billing charges, and requires minimal
|
||||
// CPU (a single RPC every few minutes) or memory (a few KiB to batch the
|
||||
// telemetry).
|
||||
//
|
||||
// The default is to enable client metrics. To opt-out of metrics collected use
|
||||
// this option.
|
||||
//
|
||||
// [gRFC/66]: https://github.com/grpc/proposal/blob/master/A66-otel-stats.md
|
||||
// [gRFC/78]: https://github.com/grpc/proposal/blob/master/A78-grpc-metrics-wrr-pf-xds.md
|
||||
// [Google Cloud Monitoring]: https://cloud.google.com/monitoring/docs
|
||||
func WithDisabledClientMetrics() option.ClientOption {
|
||||
return &withDisabledClientMetrics{disabledClientMetrics: true}
|
||||
}
|
||||
|
||||
func (w *withDisabledClientMetrics) ApplyStorageOpt(c *storageConfig) {
|
||||
c.disableClientMetrics = w.disabledClientMetrics
|
||||
}
|
||||
|
||||
// WithReadStallTimeout is an option that may be passed to [NewClient].
|
||||
// It enables the client to retry the stalled read request, happens as part of
|
||||
// storage.Reader creation. As the name suggest, timeout is adjusted dynamically
|
||||
// based on past observed read-req latencies.
|
||||
//
|
||||
// This is only supported for the read operation and that too for http(XML) client.
|
||||
// Grpc read-operation will be supported soon.
|
||||
func withReadStallTimeout(rstc *experimental.ReadStallTimeoutConfig) option.ClientOption {
|
||||
// TODO (raj-prince): To keep separate dynamicDelay instance for different BucketHandle.
|
||||
// Currently, dynamicTimeout is kept at the client and hence shared across all the
|
||||
// BucketHandle, which is not the ideal state. As latency depends on location of VM
|
||||
// and Bucket, and read latency of different buckets may lie in different range.
|
||||
// Hence having a separate dynamicTimeout instance at BucketHandle level will
|
||||
// be better
|
||||
if rstc.Min == time.Duration(0) {
|
||||
rstc.Min = defaultDynamicReadReqMinTimeout
|
||||
}
|
||||
if rstc.TargetPercentile == 0 {
|
||||
rstc.TargetPercentile = defaultTargetPercentile
|
||||
}
|
||||
return &withReadStallTimeoutConfig{
|
||||
readStallTimeoutConfig: rstc,
|
||||
}
|
||||
}
|
||||
|
||||
type withReadStallTimeoutConfig struct {
|
||||
internaloption.EmbeddableAdapter
|
||||
readStallTimeoutConfig *experimental.ReadStallTimeoutConfig
|
||||
}
|
||||
|
||||
func (wrstc *withReadStallTimeoutConfig) ApplyStorageOpt(config *storageConfig) {
|
||||
config.readStallTimeoutConfig = wrstc.readStallTimeoutConfig
|
||||
}
|
||||
|
Reference in New Issue
Block a user