core

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package core internal/core/executor.go

Package core internal/core/health.go

Package core internal/core/request.go

Package core internal/core/response.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Executor 请求执行器

func NewExecutor

func NewExecutor(config ExecutorConfig) *Executor

NewExecutor 创建新的执行器

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, req *Request) (*http.Response, error)

Execute 执行请求

func (*Executor) HealthCheck

func (e *Executor) HealthCheck(opts *HealthCheckOptions) *HealthCheckResult

HealthCheck 执行健康检查 通过发送一个简单的 HEAD 请求到服务端点来验证连接

func (*Executor) HealthCheckWithRetry

func (e *Executor) HealthCheckWithRetry(opts *HealthCheckOptions, maxRetries int) *HealthCheckResult

HealthCheckWithRetry 执行带重试的健康检查

type ExecutorConfig

type ExecutorConfig struct {
	HTTPClient    *http.Client
	EndpointURL   *url.URL
	Credentials   *credentials.Credentials
	Region        string
	Secure        bool
	BucketLookup  int
	MaxRetries    int
	LocationCache LocationCache
}

ExecutorConfig 执行器配置

type HealthCheckOptions

type HealthCheckOptions struct {
	// 超时时间(默认 5 秒)
	Timeout time.Duration

	// 自定义存储桶名(用于检查,默认不使用存储桶)
	BucketName string

	// 上下文
	Context context.Context
}

HealthCheckOptions 健康检查选项

type HealthCheckResult

type HealthCheckResult struct {
	// 是否健康
	Healthy bool

	// 错误信息
	Error error

	// 响应时间
	ResponseTime time.Duration

	// HTTP 状态码
	StatusCode int

	// 检查时间
	CheckedAt time.Time

	// 端点
	Endpoint string

	// 区域
	Region string
}

HealthCheckResult 健康检查结果

func (*HealthCheckResult) String

func (r *HealthCheckResult) String() string

String 返回健康检查结果的字符串表示

type LocationCache

type LocationCache interface {
	Get(bucketName string) (string, bool)
	Set(bucketName, location string)
	Delete(bucketName string)
}

LocationCache 位置缓存接口

type Request

type Request struct {
	// contains filtered or unexported fields
}

Request 封装的 HTTP 请求

func NewRequest

func NewRequest(ctx context.Context, method string, metadata RequestMetadata) *Request

NewRequest 创建新请求

func (*Request) Context

func (r *Request) Context() context.Context

Context 返回请求上下文

func (*Request) Metadata

func (r *Request) Metadata() RequestMetadata

Metadata 返回请求元数据

func (*Request) Method

func (r *Request) Method() string

Method 返回 HTTP 方法

type RequestMetadata

type RequestMetadata struct {
	// 桶和对象
	BucketName string
	ObjectName string

	// 查询参数
	QueryValues url.Values

	// 请求头
	CustomHeader http.Header

	// 请求体
	ContentBody   io.Reader
	ContentLength int64

	// 内容校验
	ContentMD5Base64 string
	ContentSHA256Hex string

	// 签名选项
	StreamSHA256 bool
	PresignURL   bool
	Expires      int64

	// 预签名额外头
	ExtraPresignHeader http.Header

	// 位置
	BucketLocation string

	// Trailer (用于流式签名)
	Trailer http.Header
	AddCRC  bool

	// 特殊处理
	Expect200OKWithError bool
}

RequestMetadata 请求元数据

type ResponseParser

type ResponseParser struct{}

ResponseParser 响应解析器

func NewResponseParser

func NewResponseParser() *ResponseParser

NewResponseParser 创建响应解析器

func (*ResponseParser) ParseError

func (p *ResponseParser) ParseError(resp *http.Response, bucketName, objectName string) error

ParseError 解析错误响应

func (*ResponseParser) ParseObjectInfo

func (p *ResponseParser) ParseObjectInfo(resp *http.Response, bucketName, objectName string) (types.ObjectInfo, error)

ParseObjectInfo 从响应头解析对象信息

func (*ResponseParser) ParseUploadInfo

func (p *ResponseParser) ParseUploadInfo(resp *http.Response, bucketName, objectName string) (types.UploadInfo, error)

ParseUploadInfo 从响应解析上传信息

func (*ResponseParser) ParseXML

func (p *ResponseParser) ParseXML(resp *http.Response, v interface{}) error

ParseXML 解析 XML 响应

Jump to

Keyboard shortcuts

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