db

package
v0.0.0-...-61396ba Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxOpenConns    = 100 // Allow more parallel queries
	DefaultMaxIdleConns    = 50  // Keep connections warm to avoid reconnect overhead
	DefaultConnMaxLifetime = 300 // 5 minutes (seconds)
	DefaultConnMaxIdleTime = 120 // 2 minutes - keep idle connections longer (seconds)
)

Connection pool defaults tuned for high-throughput workloads Based on patterns from Vitess, PlanetScale, and CockroachDB recommendations

Variables

View Source
var (
	ErrObjectNotFound = fmt.Errorf("object not found")
	ErrBucketNotFound = fmt.Errorf("bucket not found")
)

Common errors

View Source
var (
	ErrUploadNotFound = fmt.Errorf("multipart upload not found")
	ErrPartNotFound   = fmt.Errorf("part not found")
)

Common multipart errors

View Source
var (
	ErrACLNotFound    = fmt.Errorf("ACL not found")
	ErrPolicyNotFound = fmt.Errorf("policy not found")
)

Common ACL/Policy errors

View Source
var (
	ErrCORSNotFound    = fmt.Errorf("CORS configuration not found")
	ErrWebsiteNotFound = fmt.Errorf("website configuration not found")
)

Common CORS/Website errors

View Source
var (
	ErrTaggingNotFound    = fmt.Errorf("tagging not found")
	ErrEncryptionNotFound = fmt.Errorf("encryption configuration not found")
)

Common Tagging/Encryption errors

View Source
var (
	ErrLifecycleNotFound          = fmt.Errorf("lifecycle configuration not found")
	ErrLifecycleScanStateNotFound = fmt.Errorf("lifecycle scan state not found")
	ErrObjectLockNotFound         = fmt.Errorf("object lock configuration not found")
	ErrRetentionNotFound          = fmt.Errorf("retention not found")
	ErrLegalHoldNotFound          = fmt.Errorf("legal hold not found")
	ErrPublicAccessBlockNotFound  = fmt.Errorf("public access block configuration not found")
	ErrOwnershipControlsNotFound  = fmt.Errorf("ownership controls not found")
	ErrNotificationNotFound       = fmt.Errorf("notification configuration not found")
)

Common Lifecycle/ObjectLock errors

View Source
var (
	ErrChunkNotFound = fmt.Errorf("chunk not found in registry")
)

Common ChunkRegistry errors

View Source
var (
	ErrFederationNotFound = fmt.Errorf("federation configuration not found")
)

Common Federation errors

View Source
var (
	ErrIntelligentTieringNotFound = fmt.Errorf("intelligent tiering configuration not found")
)

Common Intelligent Tiering errors

View Source
var (
	ErrReplicationNotFound = fmt.Errorf("replication configuration not found")
)

Common Replication errors

Functions

func DBMetrics

func DBMetrics() []prometheus.Collector

DBMetrics returns the Prometheus collectors for DB metrics

func IterBuckets

func IterBuckets(ctx context.Context, store BucketStore, params *ListBucketsParams) iter.Seq2[*types.BucketInfo, error]

IterBuckets returns an iterator that yields all buckets from the database. This is more memory-efficient than ListBuckets as it streams results. The iterator handles pagination internally.

func IterObjects

func IterObjects(ctx context.Context, store ObjectStore, params *ListObjectsParams) iter.Seq2[*types.ObjectRef, error]

IterObjects returns an iterator that yields all objects from a bucket. This is more memory-efficient than ListObjectsV2 as it streams results. The iterator handles pagination internally.

func ObjectRefFromJSON

func ObjectRefFromJSON(j *ObjectRefJSON) (*types.ObjectRef, error)

ObjectRefFromJSON converts JSON form back to ObjectRef

func RunMigrations

func RunMigrations(ctx context.Context, migrator Migrator, driver Driver) error

RunMigrations applies all pending migrations for the specified driver

func UpdateConnectionMetrics

func UpdateConnectionMetrics(inUse, idle, total int)

UpdateConnectionMetrics updates connection pool metrics from sql.DBStats

Types

type ACLStore

type ACLStore interface {
	// GetBucketACL retrieves the ACL for a bucket
	GetBucketACL(ctx context.Context, bucket string) (*s3types.AccessControlList, error)

	// SetBucketACL stores the ACL for a bucket
	SetBucketACL(ctx context.Context, bucket string, acl *s3types.AccessControlList) error

	// GetObjectACL retrieves the ACL for an object
	GetObjectACL(ctx context.Context, bucket, key string) (*s3types.AccessControlList, error)

	// SetObjectACL stores the ACL for an object
	SetObjectACL(ctx context.Context, bucket, key string, acl *s3types.AccessControlList) error
}

ACLStore provides operations for access control lists

type BucketLoggingConfig

type BucketLoggingConfig struct {
	ID           string
	SourceBucket string
	TargetBucket string
	TargetPrefix string
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

BucketLoggingConfig holds the logging configuration for a bucket.

type BucketStore

type BucketStore interface {
	// CreateBucket creates a new bucket
	CreateBucket(ctx context.Context, bucket *types.BucketInfo) error

	// GetBucket retrieves bucket metadata by name
	GetBucket(ctx context.Context, name string) (*types.BucketInfo, error)

	// DeleteBucket removes a bucket (must be empty)
	DeleteBucket(ctx context.Context, name string) error

	// ListBuckets returns buckets with full pagination support
	ListBuckets(ctx context.Context, params *ListBucketsParams) (*ListBucketsResult, error)

	// UpdateBucketVersioning updates the versioning state of a bucket
	UpdateBucketVersioning(ctx context.Context, bucket string, versioning string) error

	// CountBuckets returns the total number of buckets in the database.
	// Used by metadata service to report bucket count to manager for data loss detection.
	CountBuckets(ctx context.Context) (int64, error)
}

BucketStore provides CRUD operations for bucket metadata

type CORSStore

type CORSStore interface {
	// GetBucketCORS retrieves the CORS configuration for a bucket
	GetBucketCORS(ctx context.Context, bucket string) (*s3types.CORSConfiguration, error)

	// SetBucketCORS stores the CORS configuration for a bucket
	SetBucketCORS(ctx context.Context, bucket string, cors *s3types.CORSConfiguration) error

	// DeleteBucketCORS removes the CORS configuration for a bucket
	DeleteBucketCORS(ctx context.Context, bucket string) error
}

CORSStore provides operations for CORS configurations

type ChunkInfo

type ChunkInfo struct {
	ChunkID   string
	Size      int64
	ServerID  string
	BackendID string
}

ChunkInfo contains information about a chunk for registry operations

type ChunkRegistryStore

type ChunkRegistryStore interface {

	// IncrementChunkRefCount increments the reference count for a chunk.
	// If the chunk doesn't exist, it creates it with ref_count=1.
	// Clears zero_ref_since if the chunk was previously at ref_count=0.
	IncrementChunkRefCount(ctx context.Context, chunkID string, size int64) error

	// DecrementChunkRefCount decrements the reference count for a chunk.
	// If ref_count reaches 0, sets zero_ref_since to current time for GC grace period.
	DecrementChunkRefCount(ctx context.Context, chunkID string) error

	// IncrementChunkRefCountBatch increments ref counts for multiple chunks atomically.
	IncrementChunkRefCountBatch(ctx context.Context, chunks []ChunkInfo) error

	// DecrementChunkRefCountBatch decrements ref counts for multiple chunks atomically.
	DecrementChunkRefCountBatch(ctx context.Context, chunkIDs []string) error

	// GetChunkRefCount returns the current reference count for a chunk.
	// Used by GC to re-check ref count within a transaction before deleting.
	GetChunkRefCount(ctx context.Context, chunkID string) (int, error)

	// AddChunkReplica records that a chunk exists on a specific file server.
	AddChunkReplica(ctx context.Context, chunkID, serverID, backendID string) error

	// RemoveChunkReplica removes the record of a chunk on a file server.
	RemoveChunkReplica(ctx context.Context, chunkID, serverID string) error

	// GetChunkReplicas returns all replica locations for a chunk.
	GetChunkReplicas(ctx context.Context, chunkID string) ([]ReplicaInfo, error)

	// GetChunksByServer returns all chunk IDs stored on a specific server.
	// Used for server decommissioning and rebalancing.
	GetChunksByServer(ctx context.Context, serverID string) ([]string, error)

	// GetZeroRefChunks returns chunks with ref_count=0 where zero_ref_since is older
	// than the given time (past the grace period). Includes replica info for deletion.
	GetZeroRefChunks(ctx context.Context, olderThan time.Time, limit int) ([]ZeroRefChunk, error)

	// DeleteChunkRegistry removes a chunk from the registry.
	// The chunk_replicas entries are automatically deleted via CASCADE.
	DeleteChunkRegistry(ctx context.Context, chunkID string) error
}

ChunkRegistryStore provides operations for centralized chunk reference counting. This eliminates the need for distributed gc_decrement tasks by tracking RefCount in the metadata database rather than on individual file servers.

type Config

type Config struct {
	// Driver specifies the database backend (memory, vitess, mysql, postgres, cockroachdb)
	Driver Driver

	// DSN is the data source name for SQL databases
	// Format varies by driver:
	//   - vitess/mysql: "user:pass@tcp(host:port)/database"
	//   - postgres: "postgres://user:pass@host:port/database?sslmode=disable"
	//   - cockroachdb: "postgres://user:pass@host:port/database?sslmode=disable"
	DSN string

	// Connection pool settings
	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxLifetime int // seconds
	ConnMaxIdleTime int // seconds
}

Config holds database configuration

func DefaultConfig

func DefaultConfig(driver Driver) Config

DefaultConfig returns a Config with sensible defaults for the given driver

type DB

type DB interface {
	// Object operations
	ObjectStore

	// Bucket operations
	BucketStore

	// Multipart upload operations
	MultipartStore

	// Version operations
	VersionStore

	// ACL operations
	ACLStore

	// Policy operations
	PolicyStore

	// CORS operations
	CORSStore

	// Website operations
	WebsiteStore

	// Tagging operations
	TaggingStore

	// Encryption operations
	EncryptionStore

	// Lifecycle operations
	LifecycleStore

	// Lifecycle scanner state
	LifecycleScanStore

	// Intelligent Tiering operations
	IntelligentTieringStore

	// Object Lock operations
	ObjectLockStore

	// Public Access Block operations
	PublicAccessBlockStore

	// Ownership Controls operations
	OwnershipControlsStore

	// Bucket Logging operations (access log configuration)
	LoggingStore

	// Notification operations (event notifications)
	NotificationStore

	// Replication operations (cross-region replication - Enterprise)
	ReplicationStore

	// Federation operations (S3 passthrough/migration)
	FederationStore

	// Chunk registry operations (centralized RefCount tracking)
	ChunkRegistryStore

	// Transaction support - executes fn within a transaction.
	// If fn returns an error, the transaction is rolled back.
	// If fn returns nil, the transaction is committed.
	WithTx(ctx context.Context, fn func(tx TxStore) error) error

	// Migrations
	Migrate(ctx context.Context) error

	// Close closes the database connection
	Close() error
}

DB is the main database interface for the metadata service

func NewMetricsDB

func NewMetricsDB(db DB) DB

NewMetricsDB creates a new metrics-instrumented DB wrapper

type Driver

type Driver string

Driver identifies a database driver type

const (
	DriverVitess    Driver = "vitess"
	DriverMySQL     Driver = "mysql"
	DriverPostgres  Driver = "postgres"
	DriverCockroach Driver = "cockroachdb"
)

type EncryptionStore

type EncryptionStore interface {
	// GetBucketEncryption retrieves the encryption config for a bucket
	GetBucketEncryption(ctx context.Context, bucket string) (*s3types.ServerSideEncryptionConfig, error)

	// SetBucketEncryption stores the encryption config for a bucket
	SetBucketEncryption(ctx context.Context, bucket string, config *s3types.ServerSideEncryptionConfig) error

	// DeleteBucketEncryption removes the encryption config for a bucket
	DeleteBucketEncryption(ctx context.Context, bucket string) error
}

EncryptionStore provides operations for bucket encryption configurations

type FederationStore

type FederationStore interface {
	// GetFederationConfig retrieves the federation config for a bucket.
	// Returns ErrFederationNotFound if no configuration exists.
	GetFederationConfig(ctx context.Context, bucket string) (*s3types.FederationConfig, error)

	// SetFederationConfig stores or updates the federation config for a bucket.
	SetFederationConfig(ctx context.Context, config *s3types.FederationConfig) error

	// DeleteFederationConfig removes the federation config for a bucket.
	DeleteFederationConfig(ctx context.Context, bucket string) error

	// ListFederatedBuckets returns all buckets with federation configurations.
	ListFederatedBuckets(ctx context.Context) ([]*s3types.FederationConfig, error)

	// UpdateMigrationProgress updates the migration progress counters for a bucket.
	// This is called frequently during migration and only updates the progress fields.
	UpdateMigrationProgress(ctx context.Context, bucket string, objectsSynced, bytesSynced int64, lastSyncKey string) error

	// SetMigrationPaused sets the migration_paused flag for a bucket.
	SetMigrationPaused(ctx context.Context, bucket string, paused bool) error

	// SetDualWriteEnabled sets the dual_write_enabled flag for a bucket.
	SetDualWriteEnabled(ctx context.Context, bucket string, enabled bool) error

	// GetFederatedBucketsNeedingSync returns buckets that are in migrating mode and not paused.
	// Used by migration workers to find work.
	GetFederatedBucketsNeedingSync(ctx context.Context, limit int) ([]*s3types.FederationConfig, error)
}

FederationStore provides operations for S3 bucket federation configurations. Used for passthrough mode (proxy to external S3) and migration mode (ingest from external S3).

type IntelligentTieringStore

type IntelligentTieringStore interface {
	// GetIntelligentTieringConfiguration retrieves a configuration by ID
	GetIntelligentTieringConfiguration(ctx context.Context, bucket, configID string) (*s3types.IntelligentTieringConfiguration, error)

	// PutIntelligentTieringConfiguration stores a configuration
	PutIntelligentTieringConfiguration(ctx context.Context, bucket string, config *s3types.IntelligentTieringConfiguration) error

	// DeleteIntelligentTieringConfiguration removes a configuration by ID
	DeleteIntelligentTieringConfiguration(ctx context.Context, bucket, configID string) error

	// ListIntelligentTieringConfigurations lists all configurations for a bucket
	ListIntelligentTieringConfigurations(ctx context.Context, bucket string) ([]*s3types.IntelligentTieringConfiguration, error)
}

IntelligentTieringStore provides operations for intelligent tiering configurations

type LifecycleScanState

type LifecycleScanState struct {
	Bucket            string
	LastKey           string
	LastVersionID     string
	ScanStartedAt     time.Time
	ScanCompletedAt   time.Time
	ObjectsScanned    int
	ActionsEnqueued   int
	LastError         string
	ConsecutiveErrors int
}

LifecycleScanState tracks scan progress for a bucket

type LifecycleScanStore

type LifecycleScanStore interface {
	// GetScanState retrieves scan state for a bucket
	GetScanState(ctx context.Context, bucket string) (*LifecycleScanState, error)

	// UpdateScanState updates scan progress (upsert)
	UpdateScanState(ctx context.Context, state *LifecycleScanState) error

	// ListBucketsWithLifecycle returns buckets that have lifecycle configs
	ListBucketsWithLifecycle(ctx context.Context) ([]string, error)

	// GetBucketsNeedingScan returns buckets that need scanning
	// (completed scan older than minAge, or never scanned)
	GetBucketsNeedingScan(ctx context.Context, minAge time.Duration, limit int) ([]string, error)

	// ResetScanState clears scan state for a bucket (for fresh start)
	ResetScanState(ctx context.Context, bucket string) error
}

LifecycleScanStore tracks lifecycle scanner progress

type LifecycleStore

type LifecycleStore interface {
	// GetBucketLifecycle retrieves the lifecycle config for a bucket
	GetBucketLifecycle(ctx context.Context, bucket string) (*s3types.Lifecycle, error)

	// SetBucketLifecycle stores the lifecycle config for a bucket
	SetBucketLifecycle(ctx context.Context, bucket string, lifecycle *s3types.Lifecycle) error

	// DeleteBucketLifecycle removes the lifecycle config for a bucket
	DeleteBucketLifecycle(ctx context.Context, bucket string) error
}

LifecycleStore provides operations for lifecycle configurations

type ListBucketsParams

type ListBucketsParams struct {
	OwnerID           string
	Prefix            string // Filter by bucket name prefix
	BucketRegion      string // Filter by bucket region
	MaxBuckets        int    // Pagination limit (1-10000)
	ContinuationToken string // Pagination token
}

ListBucketsParams contains parameters for ListBuckets

type ListBucketsResult

type ListBucketsResult struct {
	Buckets               []*types.BucketInfo
	IsTruncated           bool
	NextContinuationToken string
}

ListBucketsResult contains the result of ListBuckets

type ListObjectsParams

type ListObjectsParams struct {
	Bucket            string
	Prefix            string
	Delimiter         string
	MaxKeys           int
	Marker            string // For ListObjects v1
	ContinuationToken string // For ListObjects v2
	StartAfter        string // For ListObjects v2
	FetchOwner        bool
}

ListObjectsParams contains parameters for ListObjectsV2

type ListObjectsResult

type ListObjectsResult struct {
	Objects               []*types.ObjectRef
	CommonPrefixes        []string // Aggregated prefixes when delimiter is used
	IsTruncated           bool
	NextMarker            string // For v1
	NextContinuationToken string // For v2
}

ListObjectsResult contains the result of ListObjectsV2

type LoggingStore

type LoggingStore interface {
	// GetBucketLogging retrieves the logging configuration for a bucket.
	// Returns nil, nil if no logging is configured.
	GetBucketLogging(ctx context.Context, bucket string) (*BucketLoggingConfig, error)

	// SetBucketLogging stores the logging configuration for a bucket.
	// If config.TargetBucket is empty, logging is disabled for the bucket.
	SetBucketLogging(ctx context.Context, config *BucketLoggingConfig) error

	// DeleteBucketLogging removes the logging configuration for a bucket.
	DeleteBucketLogging(ctx context.Context, bucket string) error

	// ListLoggingConfigs returns all bucket logging configurations.
	ListLoggingConfigs(ctx context.Context) ([]*BucketLoggingConfig, error)
}

LoggingStore provides operations for bucket access logging configuration.

type MetricsDB

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

MetricsDB wraps a DB implementation and adds metrics instrumentation

func (*MetricsDB) AddChunkReplica

func (m *MetricsDB) AddChunkReplica(ctx context.Context, chunkID, serverID, backendID string) error

func (*MetricsDB) Close

func (m *MetricsDB) Close() error

Close closes the database connection

func (*MetricsDB) CompleteRestore

func (m *MetricsDB) CompleteRestore(ctx context.Context, objectID string, expiryDate int64) error

func (*MetricsDB) CountBuckets

func (m *MetricsDB) CountBuckets(ctx context.Context) (int64, error)

func (*MetricsDB) CreateBucket

func (m *MetricsDB) CreateBucket(ctx context.Context, bucket *types.BucketInfo) error

func (*MetricsDB) CreateMultipartUpload

func (m *MetricsDB) CreateMultipartUpload(ctx context.Context, upload *types.MultipartUpload) error

func (*MetricsDB) DecrementChunkRefCount

func (m *MetricsDB) DecrementChunkRefCount(ctx context.Context, chunkID string) error

func (*MetricsDB) DecrementChunkRefCountBatch

func (m *MetricsDB) DecrementChunkRefCountBatch(ctx context.Context, chunkIDs []string) error

func (*MetricsDB) DeleteBucket

func (m *MetricsDB) DeleteBucket(ctx context.Context, name string) error

func (*MetricsDB) DeleteBucketCORS

func (m *MetricsDB) DeleteBucketCORS(ctx context.Context, bucket string) error

func (*MetricsDB) DeleteBucketEncryption

func (m *MetricsDB) DeleteBucketEncryption(ctx context.Context, bucket string) error

func (*MetricsDB) DeleteBucketLifecycle

func (m *MetricsDB) DeleteBucketLifecycle(ctx context.Context, bucket string) error

func (*MetricsDB) DeleteBucketLogging

func (m *MetricsDB) DeleteBucketLogging(ctx context.Context, bucket string) error

func (*MetricsDB) DeleteBucketPolicy

func (m *MetricsDB) DeleteBucketPolicy(ctx context.Context, bucket string) error

func (*MetricsDB) DeleteBucketTagging

func (m *MetricsDB) DeleteBucketTagging(ctx context.Context, bucket string) error

func (*MetricsDB) DeleteBucketWebsite

func (m *MetricsDB) DeleteBucketWebsite(ctx context.Context, bucket string) error

func (*MetricsDB) DeleteChunkRegistry

func (m *MetricsDB) DeleteChunkRegistry(ctx context.Context, chunkID string) error

func (*MetricsDB) DeleteFederationConfig

func (m *MetricsDB) DeleteFederationConfig(ctx context.Context, bucket string) error

func (*MetricsDB) DeleteIntelligentTieringConfiguration

func (m *MetricsDB) DeleteIntelligentTieringConfiguration(ctx context.Context, bucket string, configID string) error

func (*MetricsDB) DeleteMultipartUpload

func (m *MetricsDB) DeleteMultipartUpload(ctx context.Context, bucket, key, uploadID string) error

func (*MetricsDB) DeleteNotificationConfiguration

func (m *MetricsDB) DeleteNotificationConfiguration(ctx context.Context, bucket string) error

func (*MetricsDB) DeleteObject

func (m *MetricsDB) DeleteObject(ctx context.Context, bucket, key string) error

func (*MetricsDB) DeleteObjectTagging

func (m *MetricsDB) DeleteObjectTagging(ctx context.Context, bucket, key string) error

func (*MetricsDB) DeleteObjectVersion

func (m *MetricsDB) DeleteObjectVersion(ctx context.Context, bucket, key, versionID string) error

func (*MetricsDB) DeleteOwnershipControls

func (m *MetricsDB) DeleteOwnershipControls(ctx context.Context, bucket string) error

func (*MetricsDB) DeleteParts

func (m *MetricsDB) DeleteParts(ctx context.Context, uploadID string) error

func (*MetricsDB) DeletePublicAccessBlock

func (m *MetricsDB) DeletePublicAccessBlock(ctx context.Context, bucket string) error

func (*MetricsDB) DeleteReplicationConfiguration

func (m *MetricsDB) DeleteReplicationConfiguration(ctx context.Context, bucket string) error

func (*MetricsDB) GetBucket

func (m *MetricsDB) GetBucket(ctx context.Context, name string) (*types.BucketInfo, error)

func (*MetricsDB) GetBucketACL

func (m *MetricsDB) GetBucketACL(ctx context.Context, bucket string) (*s3types.AccessControlList, error)

func (*MetricsDB) GetBucketCORS

func (m *MetricsDB) GetBucketCORS(ctx context.Context, bucket string) (*s3types.CORSConfiguration, error)

func (*MetricsDB) GetBucketEncryption

func (m *MetricsDB) GetBucketEncryption(ctx context.Context, bucket string) (*s3types.ServerSideEncryptionConfig, error)

func (*MetricsDB) GetBucketLifecycle

func (m *MetricsDB) GetBucketLifecycle(ctx context.Context, bucket string) (*s3types.Lifecycle, error)

func (*MetricsDB) GetBucketLogging

func (m *MetricsDB) GetBucketLogging(ctx context.Context, bucket string) (*BucketLoggingConfig, error)

func (*MetricsDB) GetBucketPolicy

func (m *MetricsDB) GetBucketPolicy(ctx context.Context, bucket string) (*s3types.BucketPolicy, error)

func (*MetricsDB) GetBucketTagging

func (m *MetricsDB) GetBucketTagging(ctx context.Context, bucket string) (*s3types.TagSet, error)

func (*MetricsDB) GetBucketWebsite

func (m *MetricsDB) GetBucketWebsite(ctx context.Context, bucket string) (*s3types.WebsiteConfiguration, error)

func (*MetricsDB) GetBucketsNeedingScan

func (m *MetricsDB) GetBucketsNeedingScan(ctx context.Context, minAge time.Duration, limit int) ([]string, error)

func (*MetricsDB) GetChunkRefCount

func (m *MetricsDB) GetChunkRefCount(ctx context.Context, chunkID string) (int, error)

func (*MetricsDB) GetChunkReplicas

func (m *MetricsDB) GetChunkReplicas(ctx context.Context, chunkID string) ([]ReplicaInfo, error)

func (*MetricsDB) GetChunksByServer

func (m *MetricsDB) GetChunksByServer(ctx context.Context, serverID string) ([]string, error)

func (*MetricsDB) GetColdIntelligentTieringObjects

func (m *MetricsDB) GetColdIntelligentTieringObjects(ctx context.Context, threshold int64, minSize int64, limit int) ([]*types.ObjectRef, error)

func (*MetricsDB) GetExpiredRestores

func (m *MetricsDB) GetExpiredRestores(ctx context.Context, now int64, limit int) ([]*types.ObjectRef, error)

func (*MetricsDB) GetFederatedBucketsNeedingSync

func (m *MetricsDB) GetFederatedBucketsNeedingSync(ctx context.Context, limit int) ([]*s3types.FederationConfig, error)

func (*MetricsDB) GetFederationConfig

func (m *MetricsDB) GetFederationConfig(ctx context.Context, bucket string) (*s3types.FederationConfig, error)

func (*MetricsDB) GetIntelligentTieringConfiguration

func (m *MetricsDB) GetIntelligentTieringConfiguration(ctx context.Context, bucket string, configID string) (*s3types.IntelligentTieringConfiguration, error)

func (*MetricsDB) GetMultipartUpload

func (m *MetricsDB) GetMultipartUpload(ctx context.Context, bucket, key, uploadID string) (*types.MultipartUpload, error)

func (*MetricsDB) GetNotificationConfiguration

func (m *MetricsDB) GetNotificationConfiguration(ctx context.Context, bucket string) (*s3types.NotificationConfiguration, error)

func (*MetricsDB) GetObject

func (m *MetricsDB) GetObject(ctx context.Context, bucket, key string) (*types.ObjectRef, error)

func (*MetricsDB) GetObjectACL

func (m *MetricsDB) GetObjectACL(ctx context.Context, bucket, key string) (*s3types.AccessControlList, error)

func (*MetricsDB) GetObjectByID

func (m *MetricsDB) GetObjectByID(ctx context.Context, id uuid.UUID) (*types.ObjectRef, error)

func (*MetricsDB) GetObjectLegalHold

func (m *MetricsDB) GetObjectLegalHold(ctx context.Context, bucket, key string) (*s3types.ObjectLockLegalHold, error)

func (*MetricsDB) GetObjectLockConfiguration

func (m *MetricsDB) GetObjectLockConfiguration(ctx context.Context, bucket string) (*s3types.ObjectLockConfiguration, error)

func (*MetricsDB) GetObjectRetention

func (m *MetricsDB) GetObjectRetention(ctx context.Context, bucket, key string) (*s3types.ObjectLockRetention, error)

func (*MetricsDB) GetObjectTagging

func (m *MetricsDB) GetObjectTagging(ctx context.Context, bucket, key string) (*s3types.TagSet, error)

func (*MetricsDB) GetObjectVersion

func (m *MetricsDB) GetObjectVersion(ctx context.Context, bucket, key, versionID string) (*types.ObjectRef, error)

func (*MetricsDB) GetOwnershipControls

func (m *MetricsDB) GetOwnershipControls(ctx context.Context, bucket string) (*s3types.OwnershipControls, error)

func (*MetricsDB) GetPart

func (m *MetricsDB) GetPart(ctx context.Context, uploadID string, partNumber int) (*types.MultipartPart, error)

func (*MetricsDB) GetPublicAccessBlock

func (m *MetricsDB) GetPublicAccessBlock(ctx context.Context, bucket string) (*s3types.PublicAccessBlockConfig, error)

func (*MetricsDB) GetReplicationConfiguration

func (m *MetricsDB) GetReplicationConfiguration(ctx context.Context, bucket string) (*s3types.ReplicationConfiguration, error)

func (*MetricsDB) GetScanState

func (m *MetricsDB) GetScanState(ctx context.Context, bucket string) (*LifecycleScanState, error)

func (*MetricsDB) GetZeroRefChunks

func (m *MetricsDB) GetZeroRefChunks(ctx context.Context, olderThan time.Time, limit int) ([]ZeroRefChunk, error)

func (*MetricsDB) IncrementChunkRefCount

func (m *MetricsDB) IncrementChunkRefCount(ctx context.Context, chunkID string, size int64) error

func (*MetricsDB) IncrementChunkRefCountBatch

func (m *MetricsDB) IncrementChunkRefCountBatch(ctx context.Context, chunks []ChunkInfo) error

func (*MetricsDB) ListBuckets

func (m *MetricsDB) ListBuckets(ctx context.Context, params *ListBucketsParams) (*ListBucketsResult, error)

func (*MetricsDB) ListBucketsWithLifecycle

func (m *MetricsDB) ListBucketsWithLifecycle(ctx context.Context) ([]string, error)

func (*MetricsDB) ListDeletedObjects

func (m *MetricsDB) ListDeletedObjects(ctx context.Context, olderThan int64, limit int) ([]*types.ObjectRef, error)

func (*MetricsDB) ListFederatedBuckets

func (m *MetricsDB) ListFederatedBuckets(ctx context.Context) ([]*s3types.FederationConfig, error)

func (*MetricsDB) ListIntelligentTieringConfigurations

func (m *MetricsDB) ListIntelligentTieringConfigurations(ctx context.Context, bucket string) ([]*s3types.IntelligentTieringConfiguration, error)

func (*MetricsDB) ListLoggingConfigs

func (m *MetricsDB) ListLoggingConfigs(ctx context.Context) ([]*BucketLoggingConfig, error)

func (*MetricsDB) ListMultipartUploads

func (m *MetricsDB) ListMultipartUploads(ctx context.Context, bucket, prefix, keyMarker, uploadIDMarker string, maxUploads int) ([]*types.MultipartUpload, bool, error)

func (*MetricsDB) ListObjectVersions

func (m *MetricsDB) ListObjectVersions(ctx context.Context, bucket, prefix, keyMarker, versionIDMarker, delimiter string, maxKeys int) ([]*types.ObjectVersion, bool, string, string, error)

func (*MetricsDB) ListObjects

func (m *MetricsDB) ListObjects(ctx context.Context, bucket, prefix string, limit int) ([]*types.ObjectRef, error)

func (*MetricsDB) ListObjectsV2

func (m *MetricsDB) ListObjectsV2(ctx context.Context, params *ListObjectsParams) (*ListObjectsResult, error)

func (*MetricsDB) ListParts

func (m *MetricsDB) ListParts(ctx context.Context, uploadID string, partNumberMarker, maxParts int) ([]*types.MultipartPart, bool, error)

func (*MetricsDB) MarkObjectDeleted

func (m *MetricsDB) MarkObjectDeleted(ctx context.Context, bucket, key string, deletedAt int64) error

func (*MetricsDB) Migrate

func (m *MetricsDB) Migrate(ctx context.Context) error

Migrate runs database migrations

func (*MetricsDB) PutDeleteMarker

func (m *MetricsDB) PutDeleteMarker(ctx context.Context, bucket, key, ownerID string) (string, error)

func (*MetricsDB) PutIntelligentTieringConfiguration

func (m *MetricsDB) PutIntelligentTieringConfiguration(ctx context.Context, bucket string, config *s3types.IntelligentTieringConfiguration) error

func (*MetricsDB) PutObject

func (m *MetricsDB) PutObject(ctx context.Context, obj *types.ObjectRef) error

func (*MetricsDB) PutPart

func (m *MetricsDB) PutPart(ctx context.Context, part *types.MultipartPart) error

func (*MetricsDB) RemoveChunkReplica

func (m *MetricsDB) RemoveChunkReplica(ctx context.Context, chunkID, serverID string) error

func (*MetricsDB) ResetRestoreStatus

func (m *MetricsDB) ResetRestoreStatus(ctx context.Context, objectID string) error

func (*MetricsDB) ResetScanState

func (m *MetricsDB) ResetScanState(ctx context.Context, bucket string) error

func (*MetricsDB) SetBucketACL

func (m *MetricsDB) SetBucketACL(ctx context.Context, bucket string, acl *s3types.AccessControlList) error

func (*MetricsDB) SetBucketCORS

func (m *MetricsDB) SetBucketCORS(ctx context.Context, bucket string, cors *s3types.CORSConfiguration) error

func (*MetricsDB) SetBucketEncryption

func (m *MetricsDB) SetBucketEncryption(ctx context.Context, bucket string, config *s3types.ServerSideEncryptionConfig) error

func (*MetricsDB) SetBucketLifecycle

func (m *MetricsDB) SetBucketLifecycle(ctx context.Context, bucket string, lifecycle *s3types.Lifecycle) error

func (*MetricsDB) SetBucketLogging

func (m *MetricsDB) SetBucketLogging(ctx context.Context, config *BucketLoggingConfig) error

func (*MetricsDB) SetBucketPolicy

func (m *MetricsDB) SetBucketPolicy(ctx context.Context, bucket string, policy *s3types.BucketPolicy) error

func (*MetricsDB) SetBucketTagging

func (m *MetricsDB) SetBucketTagging(ctx context.Context, bucket string, tagSet *s3types.TagSet) error

func (*MetricsDB) SetBucketWebsite

func (m *MetricsDB) SetBucketWebsite(ctx context.Context, bucket string, website *s3types.WebsiteConfiguration) error

func (*MetricsDB) SetDualWriteEnabled

func (m *MetricsDB) SetDualWriteEnabled(ctx context.Context, bucket string, enabled bool) error

func (*MetricsDB) SetFederationConfig

func (m *MetricsDB) SetFederationConfig(ctx context.Context, config *s3types.FederationConfig) error

func (*MetricsDB) SetMigrationPaused

func (m *MetricsDB) SetMigrationPaused(ctx context.Context, bucket string, paused bool) error

func (*MetricsDB) SetNotificationConfiguration

func (m *MetricsDB) SetNotificationConfiguration(ctx context.Context, bucket string, config *s3types.NotificationConfiguration) error

func (*MetricsDB) SetObjectACL

func (m *MetricsDB) SetObjectACL(ctx context.Context, bucket, key string, acl *s3types.AccessControlList) error

func (*MetricsDB) SetObjectLegalHold

func (m *MetricsDB) SetObjectLegalHold(ctx context.Context, bucket, key string, legalHold *s3types.ObjectLockLegalHold) error

func (*MetricsDB) SetObjectLockConfiguration

func (m *MetricsDB) SetObjectLockConfiguration(ctx context.Context, bucket string, config *s3types.ObjectLockConfiguration) error

func (*MetricsDB) SetObjectRetention

func (m *MetricsDB) SetObjectRetention(ctx context.Context, bucket, key string, retention *s3types.ObjectLockRetention) error

func (*MetricsDB) SetObjectTagging

func (m *MetricsDB) SetObjectTagging(ctx context.Context, bucket, key string, tagSet *s3types.TagSet) error

func (*MetricsDB) SetOwnershipControls

func (m *MetricsDB) SetOwnershipControls(ctx context.Context, bucket string, controls *s3types.OwnershipControls) error

func (*MetricsDB) SetPublicAccessBlock

func (m *MetricsDB) SetPublicAccessBlock(ctx context.Context, bucket string, config *s3types.PublicAccessBlockConfig) error

func (*MetricsDB) SetReplicationConfiguration

func (m *MetricsDB) SetReplicationConfiguration(ctx context.Context, bucket string, config *s3types.ReplicationConfiguration) error

func (*MetricsDB) Unwrap

func (m *MetricsDB) Unwrap() DB

Unwrap returns the underlying DB implementation

func (*MetricsDB) UpdateBucketVersioning

func (m *MetricsDB) UpdateBucketVersioning(ctx context.Context, bucket string, versioning string) error

func (*MetricsDB) UpdateLastAccessedAt

func (m *MetricsDB) UpdateLastAccessedAt(ctx context.Context, objectID string, accessedAt int64) error

func (*MetricsDB) UpdateMigrationProgress

func (m *MetricsDB) UpdateMigrationProgress(ctx context.Context, bucket string, objectsSynced, bytesSynced int64, lastSyncKey string) error

func (*MetricsDB) UpdateObjectTransition

func (m *MetricsDB) UpdateObjectTransition(ctx context.Context, objectID string, storageClass string, transitionedAt int64, transitionedRef string) error

func (*MetricsDB) UpdateRestoreExpiry

func (m *MetricsDB) UpdateRestoreExpiry(ctx context.Context, objectID string, expiryDate int64) error

func (*MetricsDB) UpdateRestoreStatus

func (m *MetricsDB) UpdateRestoreStatus(ctx context.Context, objectID string, status string, tier string, requestedAt int64) error

func (*MetricsDB) UpdateScanState

func (m *MetricsDB) UpdateScanState(ctx context.Context, state *LifecycleScanState) error

func (*MetricsDB) WithTx

func (m *MetricsDB) WithTx(ctx context.Context, fn func(tx TxStore) error) error

WithTx executes fn within a transaction

type Migration

type Migration struct {
	Version int
	Name    string
	SQL     string
}

Migration represents a database migration

func LoadMigrations

func LoadMigrations(driver Driver) ([]Migration, error)

LoadMigrations loads all migration files for a specific driver from the embedded filesystem. The driver parameter should be one of: mysql, postgres, cockroachdb. CockroachDB uses the postgres migrations since they're compatible.

type Migrator

type Migrator interface {
	// CurrentVersion returns the current migration version
	CurrentVersion(ctx context.Context) (int, error)
	// Apply applies a migration
	Apply(ctx context.Context, m Migration) error
	// SetVersion records that a migration has been applied
	SetVersion(ctx context.Context, version int) error
}

Migrator handles database migrations

type MultipartStore

type MultipartStore interface {
	// CreateMultipartUpload creates a new multipart upload
	CreateMultipartUpload(ctx context.Context, upload *types.MultipartUpload) error

	// GetMultipartUpload retrieves a multipart upload by upload ID
	GetMultipartUpload(ctx context.Context, bucket, key, uploadID string) (*types.MultipartUpload, error)

	// DeleteMultipartUpload removes a multipart upload and all its parts
	DeleteMultipartUpload(ctx context.Context, bucket, key, uploadID string) error

	// ListMultipartUploads lists in-progress uploads for a bucket
	ListMultipartUploads(ctx context.Context, bucket, prefix, keyMarker, uploadIDMarker string, maxUploads int) ([]*types.MultipartUpload, bool, error)

	// PutPart stores a part of a multipart upload
	PutPart(ctx context.Context, part *types.MultipartPart) error

	// GetPart retrieves a specific part
	GetPart(ctx context.Context, uploadID string, partNumber int) (*types.MultipartPart, error)

	// ListParts lists all parts for an upload
	ListParts(ctx context.Context, uploadID string, partNumberMarker, maxParts int) ([]*types.MultipartPart, bool, error)

	// DeleteParts removes all parts for an upload
	DeleteParts(ctx context.Context, uploadID string) error
}

MultipartStore provides operations for multipart uploads

type NotificationStore

type NotificationStore interface {
	// GetNotificationConfiguration retrieves the notification config for a bucket.
	// Returns nil, nil if no configuration exists.
	GetNotificationConfiguration(ctx context.Context, bucket string) (*s3types.NotificationConfiguration, error)

	// SetNotificationConfiguration stores the notification config for a bucket.
	SetNotificationConfiguration(ctx context.Context, bucket string, config *s3types.NotificationConfiguration) error

	// DeleteNotificationConfiguration removes the notification config for a bucket.
	DeleteNotificationConfiguration(ctx context.Context, bucket string) error
}

NotificationStore provides operations for bucket notification configurations.

type ObjectLockStore

type ObjectLockStore interface {
	// GetObjectLockConfiguration retrieves the Object Lock config for a bucket
	GetObjectLockConfiguration(ctx context.Context, bucket string) (*s3types.ObjectLockConfiguration, error)

	// SetObjectLockConfiguration stores the Object Lock config for a bucket
	SetObjectLockConfiguration(ctx context.Context, bucket string, config *s3types.ObjectLockConfiguration) error

	// GetObjectRetention retrieves the retention settings for an object
	GetObjectRetention(ctx context.Context, bucket, key string) (*s3types.ObjectLockRetention, error)

	// SetObjectRetention stores the retention settings for an object
	SetObjectRetention(ctx context.Context, bucket, key string, retention *s3types.ObjectLockRetention) error

	// GetObjectLegalHold retrieves the legal hold status for an object
	GetObjectLegalHold(ctx context.Context, bucket, key string) (*s3types.ObjectLockLegalHold, error)

	// SetObjectLegalHold stores the legal hold status for an object
	SetObjectLegalHold(ctx context.Context, bucket, key string, legalHold *s3types.ObjectLockLegalHold) error
}

ObjectLockStore provides operations for Object Lock (WORM) configurations

type ObjectRefJSON

type ObjectRefJSON struct {
	ID         string `json:"id"`
	Bucket     string `json:"bucket"`
	Key        string `json:"key"`
	Size       uint64 `json:"size"`
	Version    uint64 `json:"version"`
	ETag       string `json:"etag"`
	CreatedAt  int64  `json:"created_at"`
	DeletedAt  int64  `json:"deleted_at,omitempty"`
	ProfileID  string `json:"profile_id,omitempty"`
	ChunkRefs  string `json:"chunk_refs,omitempty"`   // JSON-encoded []ChunkRef
	ECGroupIDs string `json:"ec_group_ids,omitempty"` // JSON-encoded []uuid.UUID
}

ObjectRefJSON is used for JSON serialization in SQL databases

func ObjectRefToJSON

func ObjectRefToJSON(obj *types.ObjectRef) (*ObjectRefJSON, error)

ObjectRefToJSON converts ObjectRef to JSON-serializable form

type ObjectStore

type ObjectStore interface {
	// PutObject stores or updates object metadata
	PutObject(ctx context.Context, obj *types.ObjectRef) error

	// GetObject retrieves object metadata by bucket and key
	GetObject(ctx context.Context, bucket, key string) (*types.ObjectRef, error)

	// GetObjectByID retrieves object metadata by ID
	GetObjectByID(ctx context.Context, id uuid.UUID) (*types.ObjectRef, error)

	// DeleteObject removes object metadata (hard delete)
	DeleteObject(ctx context.Context, bucket, key string) error

	// MarkObjectDeleted sets the deleted timestamp (soft delete)
	MarkObjectDeleted(ctx context.Context, bucket, key string, deletedAt int64) error

	// ListObjects returns objects in a bucket with optional prefix filter.
	// This is a convenience method that wraps ListObjectsV2 for simple use cases.
	// For full pagination support, use ListObjectsV2 directly.
	ListObjects(ctx context.Context, bucket, prefix string, limit int) ([]*types.ObjectRef, error)

	// ListObjectsV2 returns objects with full pagination support
	ListObjectsV2(ctx context.Context, params *ListObjectsParams) (*ListObjectsResult, error)

	// ListDeletedObjects returns soft-deleted objects for GC
	ListDeletedObjects(ctx context.Context, olderThan int64, limit int) ([]*types.ObjectRef, error)

	// UpdateObjectTransition updates an object's storage class and transition metadata.
	// Used by lifecycle transitions to record that an object has been moved to tier storage.
	// Parameters:
	//   - objectID: the UUID of the object to update
	//   - storageClass: the new storage class (e.g., "GLACIER", "DEEP_ARCHIVE")
	//   - transitionedAt: Unix timestamp (nanos) when the transition occurred
	//   - transitionedRef: the key in the tier backend where the object data is stored
	UpdateObjectTransition(ctx context.Context, objectID string, storageClass string, transitionedAt int64, transitionedRef string) error

	// UpdateRestoreStatus updates the restore status for an archived object.
	// Called when a restore is initiated or when status changes during restore.
	UpdateRestoreStatus(ctx context.Context, objectID string, status string, tier string, requestedAt int64) error

	// UpdateRestoreExpiry extends the expiry date of a restored object copy.
	// Used when a restore request is made on an already-restored object to extend availability.
	UpdateRestoreExpiry(ctx context.Context, objectID string, expiryDate int64) error

	// CompleteRestore marks a restore as complete and updates the object with restored copy info.
	// The restoredChunkRefs are the chunk references for the restored copy in hot storage.
	CompleteRestore(ctx context.Context, objectID string, expiryDate int64) error

	// ResetRestoreStatus clears the restore status after a restored copy expires.
	// Called by the restore cleanup job when restore_expiry_date has passed.
	ResetRestoreStatus(ctx context.Context, objectID string) error

	// GetExpiredRestores returns objects with expired restore copies for cleanup.
	// Returns up to 'limit' objects where restore_status='completed' and restore_expiry_date < now.
	GetExpiredRestores(ctx context.Context, now int64, limit int) ([]*types.ObjectRef, error)

	// UpdateLastAccessedAt updates the last access timestamp for an object.
	// Called asynchronously on GET for intelligent tiering to track access patterns.
	UpdateLastAccessedAt(ctx context.Context, objectID string, accessedAt int64) error

	// GetColdIntelligentTieringObjects returns objects with INTELLIGENT_TIERING storage class
	// that haven't been accessed since the threshold time, for automatic demotion.
	// Returns up to 'limit' objects where:
	// - storage_class = 'INTELLIGENT_TIERING'
	// - (last_accessed_at < threshold OR (last_accessed_at = 0 AND created_at < threshold))
	// - size >= minSize (to skip small objects, AWS uses 128KB)
	GetColdIntelligentTieringObjects(ctx context.Context, threshold int64, minSize int64, limit int) ([]*types.ObjectRef, error)
}

ObjectStore provides CRUD operations for object metadata

type OwnershipControlsStore

type OwnershipControlsStore interface {
	// GetOwnershipControls retrieves the ownership controls for a bucket
	GetOwnershipControls(ctx context.Context, bucket string) (*s3types.OwnershipControls, error)

	// SetOwnershipControls stores the ownership controls for a bucket
	SetOwnershipControls(ctx context.Context, bucket string, controls *s3types.OwnershipControls) error

	// DeleteOwnershipControls removes the ownership controls for a bucket
	DeleteOwnershipControls(ctx context.Context, bucket string) error
}

OwnershipControlsStore provides operations for bucket ownership controls

type PolicyStore

type PolicyStore interface {
	// GetBucketPolicy retrieves the policy for a bucket
	GetBucketPolicy(ctx context.Context, bucket string) (*s3types.BucketPolicy, error)

	// SetBucketPolicy stores the policy for a bucket
	SetBucketPolicy(ctx context.Context, bucket string, policy *s3types.BucketPolicy) error

	// DeleteBucketPolicy removes the policy for a bucket
	DeleteBucketPolicy(ctx context.Context, bucket string) error
}

PolicyStore provides operations for bucket policies

type PublicAccessBlockStore

type PublicAccessBlockStore interface {
	// GetPublicAccessBlock retrieves the public access block config for a bucket
	GetPublicAccessBlock(ctx context.Context, bucket string) (*s3types.PublicAccessBlockConfig, error)

	// SetPublicAccessBlock stores the public access block config for a bucket
	SetPublicAccessBlock(ctx context.Context, bucket string, config *s3types.PublicAccessBlockConfig) error

	// DeletePublicAccessBlock removes the public access block config for a bucket
	DeletePublicAccessBlock(ctx context.Context, bucket string) error
}

PublicAccessBlockStore provides operations for public access block configurations

type ReplicaInfo

type ReplicaInfo struct {
	ServerID   string
	BackendID  string
	VerifiedAt int64
}

ReplicaInfo contains information about a chunk replica location

type ReplicationStore

type ReplicationStore interface {
	// GetReplicationConfiguration retrieves the replication config for a bucket.
	// Returns ErrReplicationNotFound if no configuration exists.
	GetReplicationConfiguration(ctx context.Context, bucket string) (*s3types.ReplicationConfiguration, error)

	// SetReplicationConfiguration stores the replication config for a bucket.
	SetReplicationConfiguration(ctx context.Context, bucket string, config *s3types.ReplicationConfiguration) error

	// DeleteReplicationConfiguration removes the replication config for a bucket.
	DeleteReplicationConfiguration(ctx context.Context, bucket string) error
}

ReplicationStore provides operations for bucket replication configurations (Enterprise).

type TaggingStore

type TaggingStore interface {
	// GetBucketTagging retrieves the tag set for a bucket
	GetBucketTagging(ctx context.Context, bucket string) (*s3types.TagSet, error)

	// SetBucketTagging stores the tag set for a bucket
	SetBucketTagging(ctx context.Context, bucket string, tagSet *s3types.TagSet) error

	// DeleteBucketTagging removes the tag set for a bucket
	DeleteBucketTagging(ctx context.Context, bucket string) error

	// GetObjectTagging retrieves the tag set for an object
	GetObjectTagging(ctx context.Context, bucket, key string) (*s3types.TagSet, error)

	// SetObjectTagging stores the tag set for an object
	SetObjectTagging(ctx context.Context, bucket, key string, tagSet *s3types.TagSet) error

	// DeleteObjectTagging removes the tag set for an object
	DeleteObjectTagging(ctx context.Context, bucket, key string) error
}

TaggingStore provides operations for resource tagging

type TxStore

TxStore provides transactional access to object and bucket stores. All operations within a transaction are atomic.

type VersionStore

type VersionStore interface {
	// ListObjectVersions lists all versions of objects in a bucket
	// Returns: versions, isTruncated, nextKeyMarker, nextVersionIDMarker, error
	ListObjectVersions(ctx context.Context, bucket, prefix, keyMarker, versionIDMarker, delimiter string, maxKeys int) ([]*types.ObjectVersion, bool, string, string, error)

	// GetObjectVersion retrieves a specific version of an object
	GetObjectVersion(ctx context.Context, bucket, key, versionID string) (*types.ObjectRef, error)

	// DeleteObjectVersion permanently deletes a specific version
	DeleteObjectVersion(ctx context.Context, bucket, key, versionID string) error

	// PutDeleteMarker creates a delete marker for an object (versioning enabled)
	PutDeleteMarker(ctx context.Context, bucket, key, ownerID string) (versionID string, err error)
}

VersionStore provides operations for object versioning

type WebsiteStore

type WebsiteStore interface {
	// GetBucketWebsite retrieves the website configuration for a bucket
	GetBucketWebsite(ctx context.Context, bucket string) (*s3types.WebsiteConfiguration, error)

	// SetBucketWebsite stores the website configuration for a bucket
	SetBucketWebsite(ctx context.Context, bucket string, website *s3types.WebsiteConfiguration) error

	// DeleteBucketWebsite removes the website configuration for a bucket
	DeleteBucketWebsite(ctx context.Context, bucket string) error
}

WebsiteStore provides operations for website configurations

type ZeroRefChunk

type ZeroRefChunk struct {
	ChunkID  string
	Size     int64
	Replicas []ReplicaInfo
}

ZeroRefChunk contains a chunk with zero references and its replicas (for GC)

Directories

Path Synopsis
Package memory provides an in-memory implementation of db.DB for testing.
Package memory provides an in-memory implementation of db.DB for testing.
Package postgres provides a PostgreSQL/CockroachDB implementation of the db.DB interface.
Package postgres provides a PostgreSQL/CockroachDB implementation of the db.DB interface.
Package sql provides a dialect-aware SQL database implementation.
Package sql provides a dialect-aware SQL database implementation.
Package vitess provides a Vitess/MySQL implementation of the db.DB interface.
Package vitess provides a Vitess/MySQL implementation of the db.DB interface.

Jump to

Keyboard shortcuts

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