2022-02-24 15:53:53 +00:00
|
|
|
package storage
|
|
|
|
|
|
|
|
// Option for setting params used by chunk manager client.
|
|
|
|
type config struct {
|
|
|
|
address string
|
|
|
|
bucketName string
|
|
|
|
accessKeyID string
|
|
|
|
secretAccessKeyID string
|
|
|
|
useSSL bool
|
|
|
|
createBucket bool
|
|
|
|
rootPath string
|
2022-06-02 11:42:03 +00:00
|
|
|
useIAM bool
|
2022-11-01 03:07:35 +00:00
|
|
|
cloudProvider string
|
2022-06-02 11:42:03 +00:00
|
|
|
iamEndpoint string
|
2023-08-11 02:37:36 +00:00
|
|
|
useVirtualHost bool
|
|
|
|
region string
|
2023-10-23 12:08:08 +00:00
|
|
|
requestTimeoutMs int64
|
2022-02-24 15:53:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func newDefaultConfig() *config {
|
|
|
|
return &config{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Option is used to config the retry function.
|
|
|
|
type Option func(*config)
|
|
|
|
|
|
|
|
func Address(addr string) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.address = addr
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func BucketName(bucketName string) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.bucketName = bucketName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func AccessKeyID(accessKeyID string) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.accessKeyID = accessKeyID
|
|
|
|
}
|
|
|
|
}
|
2023-09-21 01:45:27 +00:00
|
|
|
|
2022-02-24 15:53:53 +00:00
|
|
|
func SecretAccessKeyID(secretAccessKeyID string) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.secretAccessKeyID = secretAccessKeyID
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func UseSSL(useSSL bool) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.useSSL = useSSL
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func CreateBucket(createBucket bool) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.createBucket = createBucket
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func RootPath(rootPath string) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.rootPath = rootPath
|
|
|
|
}
|
|
|
|
}
|
2022-06-02 11:42:03 +00:00
|
|
|
|
|
|
|
func UseIAM(useIAM bool) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.useIAM = useIAM
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-01 03:07:35 +00:00
|
|
|
func CloudProvider(cloudProvider string) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.cloudProvider = cloudProvider
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-02 11:42:03 +00:00
|
|
|
func IAMEndpoint(iamEndpoint string) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.iamEndpoint = iamEndpoint
|
|
|
|
}
|
|
|
|
}
|
2023-08-11 02:37:36 +00:00
|
|
|
|
|
|
|
func UseVirtualHost(useVirtualHost bool) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.useVirtualHost = useVirtualHost
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func Region(region string) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.region = region
|
|
|
|
}
|
|
|
|
}
|
2023-10-23 12:08:08 +00:00
|
|
|
|
|
|
|
func RequestTimeout(requestTimeoutMs int64) Option {
|
|
|
|
return func(c *config) {
|
|
|
|
c.requestTimeoutMs = requestTimeoutMs
|
|
|
|
}
|
|
|
|
}
|