Documentation
¶
Overview ¶
Package s3 implements an S3-backed block store: a flat byte address space mapped onto fixed-size chunk objects in an S3 bucket, with an in-memory write-back cache. The *Store type satisfies the go-volumes/pool Backing interface (io.ReaderAt, io.WriterAt, Truncate, Sync, io.Closer), so a copy-on-write volume pool — or any block consumer — can run on S3 with no local file.
Production code here keeps no dependency on go-volumes/pool; the Backing conformance is asserted only in the test file s3_conformance_test.go.
Layout in the bucket (all under a configurable key prefix):
<prefix>/__meta little metadata object: logical size + chunk size <prefix>/<016d chunk index> one object per 4 MiB (default) data chunk
A chunk that was never written reads back as zeros (the store is sparse): the logical size in the metadata object — not the presence of chunk objects — defines the address space. Writes are buffered in the cache and flushed to S3 only on Sync (or Close), which is the durability point.
Index ¶
Constants ¶
const DefaultChunkSize = 4 << 20
DefaultChunkSize is the default chunk-object size (4 MiB).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Client is the S3 client (or any objectStore). Required.
Client objectStore
// Prefix is the key prefix under which chunk objects and metadata live.
Prefix string
// ChunkSize is the chunk-object size in bytes; must be a power of two >= 512.
// Zero means DefaultChunkSize.
ChunkSize int64
// Context is used for all S3 operations. Zero means context.Background().
Context context.Context
}
Config configures Open.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is an S3-backed block store satisfying the pool.Backing shape.
func Open ¶
Open opens (or, if no metadata object exists, initialises) a Store. If the metadata object is present its logical size and chunk size are adopted and the supplied ChunkSize, when non-zero, must match. Otherwise the store starts empty at size 0 with the requested (or default) chunk size.
func (*Store) ReadAt ¶
ReadAt implements io.ReaderAt. Reads past the logical size return io.EOF with the bytes read so far, matching os.File semantics.
func (*Store) Sync ¶
Sync flushes every dirty chunk and then the metadata object to S3, clearing dirty flags. This is the store's durability point.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package client is a minimal S3 client built on net/http and signed with AWS Signature Version 4 (package sigv4).
|
Package client is a minimal S3 client built on net/http and signed with AWS Signature Version 4 (package sigv4). |
|
Package sigv4 signs HTTP requests with AWS Signature Version 4 using only the Go standard library (crypto/sha256, crypto/hmac).
|
Package sigv4 signs HTTP requests with AWS Signature Version 4 using only the Go standard library (crypto/sha256, crypto/hmac). |