storage

package
v0.29.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: CC0-1.0 Imports: 12 Imported by: 0

Documentation

Overview

Package storage wraps the Postgres pool and the S3-compatible object store. Both Open helpers run the necessary setup (migrations for Postgres; bucket creation for S3) so the caller only sees "ready" handles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenPG

func OpenPG(ctx context.Context, dbURL string) (*pgxpool.Pool, error)

OpenPG opens a pooled Postgres connection and applies pending migrations. The pool is returned even on migration failure so the caller can close it.

Types

type ObjectStore

type ObjectStore struct {
	Client *minio.Client
	Bucket string
	Region string
}

ObjectStore wraps a minio-go client + bucket. The same code path works against MinIO, R2, B2, or AWS S3 — only the endpoint and credentials differ.

func OpenS3

func OpenS3(ctx context.Context, endpoint, accessKey, secretKey, bucket, region string, useSSL bool) (*ObjectStore, error)

OpenS3 connects to the configured S3-compatible endpoint and ensures the target bucket exists. Idempotent; safe to call on every boot.

func (*ObjectStore) Exists

func (s *ObjectStore) Exists(ctx context.Context, key string) (bool, error)

Exists reports whether an object is present under key. A "not found" response is reported as (false, nil); any other failure (network, auth) is returned as an error so callers can distinguish "absent" from "couldn't tell".

func (*ObjectStore) Get

func (s *ObjectStore) Get(ctx context.Context, key string) (io.ReadCloser, error)

Get fetches an object. The caller MUST close the returned reader.

func (*ObjectStore) Put

func (s *ObjectStore) Put(ctx context.Context, key string, body io.Reader, size int64) (string, error)

Put uploads body under key and returns a canonical s3://bucket/key URI. Content-type is application/octet-stream; body is arbitrary raw text or binary depending on agent.

func (*ObjectStore) Remove

func (s *ObjectStore) Remove(ctx context.Context, key string) error

Remove deletes the object under key. Removing a missing key is not an error (minio treats DELETE as idempotent).

Jump to

Keyboard shortcuts

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