core

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 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 executes HTTP requests against RustFS/S3 endpoints

func NewExecutor

func NewExecutor(config ExecutorConfig) *Executor

NewExecutor creates a new Executor

func (*Executor) Execute

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

Execute performs the request with retries and signing

func (*Executor) HealthCheck

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

HealthCheck performs health check Sends a simple HEAD request to the endpoint to verify connectivity

func (*Executor) HealthCheckWithRetry

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

HealthCheckWithRetry performs health check with retries

func (*Executor) Presign added in v1.0.3

func (e *Executor) Presign(ctx context.Context, req *Request) (*url.URL, http.Header, error)

Presign builds and signs the request, returning the presigned URL and signed headers without executing it.

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 configures an Executor

type HealthCheckOptions

type HealthCheckOptions struct {
	// Timeout (default 5 seconds)
	Timeout time.Duration

	// Optional bucket name for check (default none)
	BucketName string

	// Context
	Context context.Context
}

HealthCheckOptions health check options

type HealthCheckResult

type HealthCheckResult struct {
	// Whether healthy
	Healthy bool

	// Error detail
	Error error

	// Response time
	ResponseTime time.Duration

	// HTTP status code
	StatusCode int

	// Checked time
	CheckedAt time.Time

	// Endpoint
	Endpoint string

	// Region
	Region string
}

HealthCheckResult holds health check result

func (*HealthCheckResult) String

func (r *HealthCheckResult) String() string

String returns formatted health check result

type LocationCache

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

LocationCache caches bucket locations

type Request

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

Request encapsulated HTTP request

func NewRequest

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

NewRequest creates a new Request

func (*Request) Context

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

Context returns request context

func (*Request) Metadata

func (r *Request) Metadata() RequestMetadata

Metadata returns request metadata

func (*Request) Method

func (r *Request) Method() string

Method returns HTTP method

type RequestMetadata

type RequestMetadata struct {
	// Bucket and object
	BucketName string
	ObjectName string

	// Query parameters
	QueryValues url.Values

	// Request headers
	CustomHeader http.Header

	// Request body
	ContentBody   io.Reader
	ContentLength int64

	// Content validation
	ContentMD5Base64 string
	ContentSHA256Hex string

	// Signing options
	StreamSHA256 bool
	PresignURL   bool
	Expires      int64

	// Extra headers for presign
	ExtraPresignHeader http.Header

	// Location
	BucketLocation string

	// Trailer (for streaming signature)
	Trailer http.Header
	AddCRC  bool

	// Special handling
	Expect200OKWithError bool
}

RequestMetadata holds request metadata

type ResponseParser

type ResponseParser struct{}

ResponseParser parses HTTP responses

func NewResponseParser

func NewResponseParser() *ResponseParser

NewResponseParser creates a ResponseParser

func (*ResponseParser) ParseError

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

ParseError parses error response

func (*ResponseParser) ParseObjectInfo

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

ParseObjectInfo parses object info from response headers

func (*ResponseParser) ParseUploadInfo

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

ParseUploadInfo parses upload info from response

func (*ResponseParser) ParseXML

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

ParseXML decodes XML response

Jump to

Keyboard shortcuts

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