Documentation
¶
Index ¶
- Variables
- type AllRegionsProviderOptions
- type BucketRegionsQuery
- type BucketRegionsQueryOptions
- type Endpoints
- func (endpoints Endpoints) Clone() Endpoints
- func (endpoints Endpoints) GetEndpoints(context.Context) (Endpoints, error)
- func (endpoints Endpoints) HostsLength() int
- func (endpoints Endpoints) IsEmpty() bool
- func (left Endpoints) IsEqual(right Endpoints) bool
- func (hosts Endpoints) Iter() *EndpointsIter
- func (left Endpoints) Join(rights ...Endpoints) Endpoints
- func (endpoints Endpoints) ToHostProvider() hostprovider.HostProvider
- type EndpointsIter
- type EndpointsProvider
- type Region
- type RegionsProvider
- type ServiceName
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrUnrecognizedServiceName = errors.New("unrecognized service name")
)
Functions ¶
This section is empty.
Types ¶
type AllRegionsProviderOptions ¶ added in v7.23.0
type AllRegionsProviderOptions struct {
// 使用 HTTP 协议
UseInsecureProtocol bool
// 压缩周期(默认:60s)
CompactInterval time.Duration
// 持久化路径(默认:$TMPDIR/qiniu-golang-sdk/regions_v4_01.cache.json)
PersistentFilePath string
// 持久化周期(默认:60s)
PersistentDuration time.Duration
// 单域名重试次数(默认:2)
RetryMax int
// 主备域名冻结时间(默认:600s),当一个域名请求失败(单个域名会被重试 RetryMax 次),会被冻结一段时间,使用备用域名进行重试,在冻结时间内,域名不能被使用,当一个操作中所有域名竣备冻结操作不在进行重试,返回最后一次操作的错误。
HostFreezeDuration time.Duration
// HTTP 客户端,如果不配置则使用默认的 HTTP 客户端
Client clientv2.Client
// 域名解析器,如果不配置则使用默认的域名解析器
Resolver resolver.Resolver
// 域名选择器,如果不配置则使用默认的域名选择器
Chooser chooser.Chooser
// 退避器,如果不配置则使用默认的退避器
Backoff backoff.Backoff
// 签名前回调函数
BeforeSign func(*http.Request)
// 签名后回调函数
AfterSign func(*http.Request)
// 签名错误回调函数
SignError func(*http.Request, error)
// 域名解析前回调函数
BeforeResolve func(*http.Request)
// 域名解析后回调函数
AfterResolve func(*http.Request, []net.IP)
// 域名解析错误回调函数
ResolveError func(*http.Request, error)
// 退避前回调函数
BeforeBackoff func(*http.Request, *retrier.RetrierOptions, time.Duration)
// 退避后回调函数
AfterBackoff func(*http.Request, *retrier.RetrierOptions, time.Duration)
// 请求前回调函数
BeforeRequest func(*http.Request, *retrier.RetrierOptions)
// 请求后回调函数
AfterResponse func(*http.Response, *retrier.RetrierOptions, error)
}
AllRegionsProviderOptions 所有区域提供者选项
type BucketRegionsQuery ¶
type BucketRegionsQuery interface {
Query(accessKey, bucketName string) RegionsProvider
}
BucketRegionsQuery 空间区域查询器
func NewBucketRegionsQuery ¶
func NewBucketRegionsQuery(bucketHosts Endpoints, opts *BucketRegionsQueryOptions) (BucketRegionsQuery, error)
NewBucketRegionsQuery 创建空间区域查询器
type BucketRegionsQueryOptions ¶
type BucketRegionsQueryOptions struct {
// 使用 HTTP 协议
UseInsecureProtocol bool
// 是否加速上传
AccelerateUploading bool
// 压缩周期(默认:60s)
CompactInterval time.Duration
// 持久化路径(默认:$TMPDIR/qiniu-golang-sdk/query_v4_01.cache.json)
PersistentFilePath string
// 持久化周期(默认:60s)
PersistentDuration time.Duration
// 单域名重试次数(默认:2)
RetryMax int
// 主备域名冻结时间(默认:600s),当一个域名请求失败(单个域名会被重试 RetryMax 次),会被冻结一段时间,使用备用域名进行重试,在冻结时间内,域名不能被使用,当一个操作中所有域名竣备冻结操作不在进行重试,返回最后一次操作的错误。
HostFreezeDuration time.Duration
// HTTP 客户端,如果不配置则使用默认的 HTTP 客户端
Client clientv2.Client
// 域名解析器,如果不配置则使用默认的域名解析器
Resolver resolver.Resolver
// 域名选择器,如果不配置则使用默认的域名选择器
Chooser chooser.Chooser
// 退避器,如果不配置则使用默认的退避器
Backoff backoff.Backoff
// 域名解析前回调函数
BeforeResolve func(*http.Request)
// 域名解析后回调函数
AfterResolve func(*http.Request, []net.IP)
// 域名解析错误回调函数
ResolveError func(*http.Request, error)
// 退避前回调函数
BeforeBackoff func(*http.Request, *retrier.RetrierOptions, time.Duration)
// 退避后回调函数
AfterBackoff func(*http.Request, *retrier.RetrierOptions, time.Duration)
// 请求前回调函数
BeforeRequest func(*http.Request, *retrier.RetrierOptions)
// 请求后回调函数
AfterResponse func(*http.Response, *retrier.RetrierOptions, error)
}
BucketRegionsQueryOptions 空间区域查询器选项
type Endpoints ¶
type Endpoints struct {
Preferred []string `json:"preferred,omitempty"` // 首选服务地址
Alternative []string `json:"alternative,omitempty"` // 备选服务地址
Accelerated []string `json:"accelerated,omitempty"` // 加速服务地址
}
服务地址
可以存储域名或 IP,端口和协议可选
func (Endpoints) GetEndpoints ¶
func (Endpoints) HostsLength ¶ added in v7.23.0
func (Endpoints) Iter ¶
func (hosts Endpoints) Iter() *EndpointsIter
func (Endpoints) ToHostProvider ¶
func (endpoints Endpoints) ToHostProvider() hostprovider.HostProvider
type EndpointsIter ¶
type EndpointsIter struct {
// contains filtered or unexported fields
}
服务地址迭代器
func (*EndpointsIter) More ¶
func (iter *EndpointsIter) More() bool
func (*EndpointsIter) Next ¶
func (iter *EndpointsIter) Next(nextHost *string) bool
func (*EndpointsIter) SwitchToAlternative ¶
func (iter *EndpointsIter) SwitchToAlternative()
func (*EndpointsIter) SwitchToPreferred ¶ added in v7.23.0
func (iter *EndpointsIter) SwitchToPreferred()
type EndpointsProvider ¶
服务地址提供者
type Region ¶
type Region struct {
RegionID string `json:"region_id,omitempty"` // 区域 ID
Up Endpoints `json:"up,omitempty"` // Up 服务域名
Io Endpoints `json:"io,omitempty"` // Io 服务域名
IoSrc Endpoints `json:"io_src,omitempty"` // Io 源站服务域名
Rs Endpoints `json:"rs,omitempty"` // Rs 服务域名
Rsf Endpoints `json:"rsf,omitempty"` // Rsf 服务域名
Api Endpoints `json:"api,omitempty"` // Api 服务域名
Bucket Endpoints `json:"bucket,omitempty"` // Bucket 服务域名
}
区域信息
可能有多个机房信息,每个机房可能有多个服务地址
如果使用公有云,建议使用 GetRegionByID 方法直接获取获取区域实例,不建议手动设置服务地址
func GetRegionByID ¶
根据 RegionID 获取公有云区域信息
func (*Region) Endpoints ¶
func (region *Region) Endpoints(serviceNames []ServiceName) (Endpoints, error)
func (*Region) EndpointsIter ¶
func (region *Region) EndpointsIter(serviceNames []ServiceName) (*EndpointsIter, error)
type RegionsProvider ¶
区域提供者
func NewAllRegionsProvider ¶ added in v7.23.0
func NewAllRegionsProvider(credentials credentials.CredentialsProvider, bucketHosts Endpoints, opts *AllRegionsProviderOptions) (RegionsProvider, error)
NewAllRegionsProvider 创建所有空间提供者
type ServiceName ¶
type ServiceName string
服务名称
const ( // Up 服务 ServiceUp ServiceName = "up" // Io 服务 ServiceIo ServiceName = "io" // Io 源站服务 ServiceIoSrc ServiceName = "io_src" // Rs 服务 ServiceRs ServiceName = "rs" // Rsf 服务 ServiceRsf ServiceName = "rsf" // Api 服务 ServiceApi ServiceName = "api" // Bucket 服务 ServiceBucket ServiceName = "bucket" )
Click to show internal directories.
Click to hide internal directories.