Documentation
¶
Overview ¶
Package dedup provides content-hash deduplication middleware for Trove. It hashes data on write and checks for existing content before storing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dedup ¶
type Dedup struct {
// contains filtered or unexported fields
}
Dedup provides content-hash deduplication middleware.
func (*Dedup) Direction ¶
func (d *Dedup) Direction() middleware.Direction
Direction returns Write since dedup only checks on the write path.
func (*Dedup) WrapWriter ¶
func (d *Dedup) WrapWriter(ctx context.Context, w io.WriteCloser, key string) (io.WriteCloser, error)
WrapWriter wraps a writer to hash content and check for duplicates. If a duplicate is found, the write is skipped (empty data written).
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
MemoryStore is an in-memory Store for testing.
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
NewMemoryStore creates a new in-memory dedup store.
type OnDuplicate ¶
OnDuplicate is called when a duplicate is detected. The handler receives the key being written and the hash that matched.
type Option ¶
type Option func(*Dedup)
Option configures the Dedup middleware.
func WithHashAlgorithm ¶
func WithHashAlgorithm(alg internal.ChecksumAlgorithm) Option
WithHashAlgorithm sets the hash algorithm (default: blake3).
func WithOnDuplicate ¶
func WithOnDuplicate(fn OnDuplicate) Option
WithOnDuplicate sets a callback for duplicate detection.