g3

store

import "github.com/afreidah/g3/internal/store"

Index

type PostgresStore

PostgresStore provides a shared PostgreSQL metadata index for g3 objects and buckets. Implements backend.MetadataStore.

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

func NewPostgres

func NewPostgres(ctx context.Context, cfg *config.DatabaseConfig) (*PostgresStore, error)

NewPostgres connects to PostgreSQL, runs migrations, and returns a store.

func (*PostgresStore) Close

func (s *PostgresStore) Close() error

Close closes the connection pool.

func (*PostgresStore) DeleteObject

func (s *PostgresStore) DeleteObject(ctx context.Context, bucket, key string) error

DeleteObject removes an object record from the index.

func (*PostgresStore) GetBucket

func (s *PostgresStore) GetBucket(ctx context.Context, name string) (*backend.BucketRecord, error)

GetBucket retrieves a bucket record by name. Returns nil if not found.

func (*PostgresStore) GetObject

func (s *PostgresStore) GetObject(ctx context.Context, bucket, key string) (*backend.ObjectRecord, error)

GetObject retrieves an object record by bucket and key. Returns nil if not found.

func (*PostgresStore) ListBuckets

func (s *PostgresStore) ListBuckets(ctx context.Context) ([]*backend.BucketRecord, error)

ListBuckets returns all bucket records ordered by name.

func (*PostgresStore) ListObjects

func (s *PostgresStore) ListObjects(ctx context.Context, bucket, prefix, startAfter string, maxKeys int) ([]*backend.ObjectRecord, error)

ListObjects returns object records matching a bucket and optional key prefix, ordered by key.

func (*PostgresStore) PutBucket

func (s *PostgresStore) PutBucket(ctx context.Context, rec *backend.BucketRecord) error

PutBucket inserts or replaces a bucket record.

func (*PostgresStore) PutObject

func (s *PostgresStore) PutObject(ctx context.Context, rec *backend.ObjectRecord) error

PutObject inserts or replaces an object record.

type SQLiteStore

SQLiteStore provides a local SQLite metadata index for g3 objects and buckets. Implements backend.MetadataStore.

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

func NewSQLite

func NewSQLite(path string) (*SQLiteStore, error)

New opens or creates a SQLite database at the given path and runs schema migrations.

func (*SQLiteStore) Close

func (s *SQLiteStore) Close() error

Close closes the database connection.

func (*SQLiteStore) DeleteObject

func (s *SQLiteStore) DeleteObject(ctx context.Context, bucket, key string) error

DeleteObject removes an object record from the index.

func (*SQLiteStore) GetBucket

func (s *SQLiteStore) GetBucket(ctx context.Context, name string) (*backend.BucketRecord, error)

GetBucket retrieves a bucket record by name. Returns nil if not found.

func (*SQLiteStore) GetObject

func (s *SQLiteStore) GetObject(ctx context.Context, bucket, key string) (*backend.ObjectRecord, error)

GetObject retrieves an object record by bucket and key. Returns nil if not found.

func (*SQLiteStore) ListBuckets

func (s *SQLiteStore) ListBuckets(ctx context.Context) ([]*backend.BucketRecord, error)

ListBuckets returns all bucket records ordered by name.

func (*SQLiteStore) ListObjects

func (s *SQLiteStore) ListObjects(ctx context.Context, bucket, prefix, startAfter string, maxKeys int) ([]*backend.ObjectRecord, error)

ListObjects returns object records matching a bucket and optional key prefix, ordered by key.

func (*SQLiteStore) PutBucket

func (s *SQLiteStore) PutBucket(ctx context.Context, rec *backend.BucketRecord) error

PutBucket inserts or replaces a bucket record.

func (*SQLiteStore) PutObject

func (s *SQLiteStore) PutObject(ctx context.Context, rec *backend.ObjectRecord) error

PutObject inserts or replaces an object record in the index.

Generated by gomarkdoc