Help us shape the future of Go! Take the 2026 Go Developer Survey

objstore

package
v1.37.1-stratum.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package objstore is a thin S3 client (AWS SDK for Go v2) for offloading etcd snapshots to an S3-compatible object store — AWS S3, MinIO, Ceph RGW, etc. A custom BaseEndpoint + path-style addressing makes the non-AWS stores work. Credentials are passed in a Target (loaded from /etc/stratum/snapshot.conf or the environment) — never on the command line.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RemoveStaleTemps

func RemoveStaleTemps(root *os.Root, name string, olderThan time.Duration) error

RemoveStaleTemps removes from root the regular files named like the temp files Download makes for name (".<name>.<digits>") that were last written more than olderThan ago: what a SIGKILL or power loss mid-download leaves, a partial copy of a snapshot. Younger ones may be a concurrent download's.

Types

type Object

type Object struct {
	Name     string // base name (prefix stripped)
	Size     int64
	Modified time.Time
}

Object is one item in the store.

type Target

type Target struct {
	Endpoint  string // custom endpoint for S3-compatible stores; empty = real AWS
	Region    string // default "us-east-1"
	Bucket    string
	Prefix    string // key prefix (folder within the bucket)
	AccessKey string
	SecretKey string
	PathStyle bool // true for MinIO/Ceph and most non-AWS endpoints
}

Target describes an S3-compatible destination for snapshots.

func (*Target) Download

func (t *Target) Download(ctx context.Context, root *os.Root, name string) error

Download fetches object `name` into root (multipart), as a file called name. The file is written 0600 to a temp file beside it and renamed into place once complete, so a failed download leaves an existing file untouched, and a symlink at that name is replaced, never followed. root is a directory handle, not a path, so the directory that was checked is the one written even if its name is swapped meanwhile.

func (*Target) Enabled

func (t *Target) Enabled() bool

Enabled reports whether an S3 target is configured (a bucket is set).

func (*Target) Key

func (t *Target) Key(name string) string

Key returns the full object key for a snapshot base name under the prefix.

func (*Target) List

func (t *Target) List(ctx context.Context) ([]Object, error)

List returns the objects under the target's prefix, sorted by name.

func (*Target) Prune

func (t *Target) Prune(ctx context.Context, owned func(name string) bool, keep int) error

Prune deletes objects whose base name owned accepts, keeping the newest `keep` by LastModified with the name breaking ties, and tries every older one even when a delete fails. keep <= 0 is a no-op (never prune-all).

func (*Target) Upload

func (t *Target) Upload(ctx context.Context, localPath, name string) error

Upload streams localPath to the target as object `name` (multipart for large files).

Jump to

Keyboard shortcuts

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