Documentation
¶
Overview ¶
Package fakes3 是一个内存版 S3 兼容端点,仅供测试使用(不参与二进制构建)。 它覆盖 sail serve 用到的子集:HeadObject / GetObject(Range) / PutObject / CopyObject / DeleteObject / DeleteObjects / ListObjectsV2 (含 Delimiter 与分页) / multipart 三件套,并统计各类请求次数, 便于断言「列目录不发 GetObject」这类行为约束。
Index ¶
- type Counts
- type Object
- type Server
- func (s *Server) Close()
- func (s *Server) Get(bucket, key string) (Object, bool)
- func (s *Server) Keys(bucket string) []string
- func (s *Server) Put(bucket, key string, data []byte, contentType string)
- func (s *Server) PutWithMetadata(bucket, key string, data []byte, contentType string, md map[string]string)
- func (s *Server) URL() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Counts ¶
type Counts struct {
Head atomic.Int64
Get atomic.Int64
Put atomic.Int64
List atomic.Int64
Delete atomic.Int64
DeleteBatch atomic.Int64
Copy atomic.Int64
Multipart atomic.Int64
}
Counts 记录各类请求次数。
type Object ¶
type Object struct {
Data []byte
ContentType string
// Metadata 是用户元数据(x-amz-meta-*),键为去前缀后的小写名。
// sail serve 的 payload 元数据判定依赖它,故 fake 端必须能往返。
Metadata map[string]string
ModTime time.Time
}
Object 是一个朴素对象:1 key = 1 份完整数据。
type Server ¶
type Server struct {
Counts Counts
// BatchDeleteStatus 是 FailBatchDelete 生效时返回的状态码;0 表示 500
// (多数网关代答「不支持」的形态),测试可显式设为 501 等。
BatchDeleteStatus atomic.Int64
// FailBatchDeleteKeys 置真时,批量删除返回 200 但每个 key 都带 <Error>
// ——模拟「端点可用、部分对象删不掉」的真实形态。
FailBatchDeleteKeys atomic.Bool
// FailBatchDelete 置真时,批量删除端点(?delete)返回 500——模拟不支持
// DeleteObjects 的 S3 兼容服务(如某些自建网关),用于验证回退路径。
FailBatchDelete atomic.Bool
// DeleteDelay 是单对象删除的注入延迟,用于把并发回退与串行回退区分开:
// 并发执行时总耗时应接近单个延迟而非 N 倍。
DeleteDelay atomic.Int64
// CopyDelay 是单对象复制的注入延迟,用途同 DeleteDelay。
CopyDelay atomic.Int64
// contains filtered or unexported fields
}
Server 是内存 S3 端点。
Click to show internal directories.
Click to hide internal directories.