region

package
v7.20.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnrecognizedServiceName = errors.New("unrecognized service name")
)

Functions

This section is empty.

Types

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

	// 压缩周期(默认: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
}

BucketRegionsQuery 空间区域查询器选项

type Endpoints

type Endpoints struct {
	Preferred   []string `json:"preferred,omitempty"`
	Alternative []string `json:"alternative,omitempty"`
}

服务地址

可以存储域名或 IP,端口和协议可选

func (Endpoints) Clone

func (endpoints Endpoints) Clone() Endpoints

func (Endpoints) GetEndpoints

func (endpoints Endpoints) GetEndpoints(context.Context) (Endpoints, error)

func (Endpoints) IsEmpty

func (endpoints Endpoints) IsEmpty() bool

func (Endpoints) IsEqual

func (left Endpoints) IsEqual(right Endpoints) bool

func (Endpoints) Iter

func (hosts Endpoints) Iter() *EndpointsIter

func (Endpoints) Join

func (left Endpoints) Join(rights ...Endpoints) Endpoints

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()

type EndpointsProvider

type EndpointsProvider interface {
	GetEndpoints(context.Context) (Endpoints, error)
}

服务地址提供者

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"`    // IoSrc 服务域名
	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

func GetRegionByID(regionID string, useHttps bool) *Region

根据 RegionID 获取公有云区域信息

func (*Region) Endpoints

func (region *Region) Endpoints(serviceNames []ServiceName) (Endpoints, error)

func (*Region) EndpointsIter

func (region *Region) EndpointsIter(serviceNames []ServiceName) (*EndpointsIter, error)

func (*Region) GetRegions

func (region *Region) GetRegions(context.Context) ([]*Region, error)

func (*Region) IsEqual

func (left *Region) IsEqual(right *Region) bool

type RegionsProvider

type RegionsProvider interface {
	GetRegions(context.Context) ([]*Region, error)
}

区域提供者

type ServiceName

type ServiceName string

服务名称

const (
	// Up 服务
	ServiceUp ServiceName = "up"
	// Io 服务
	ServiceIo ServiceName = "io"
	// IoSrc 服务
	ServiceIoSrc ServiceName = "io_src"
	// Rs 服务
	ServiceRs ServiceName = "rs"
	// Rsf 服务
	ServiceRsf ServiceName = "rsf"
	// Api 服务
	ServiceApi ServiceName = "api"
	// Bucket 服务
	ServiceBucket ServiceName = "bucket"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL