objectstore

package
v0.57.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package objectstore keeps the last valid snapshot of each source in an S3 bucket, the production store of ADR 0005: Scaleway Object Storage in fr-par, shared by the sync job and the API container, which have no volume in common.

Each source is one object whose key is the file name of package store (amf.snapshot) and whose content is its file format, envelope and digest included: Load checks a downloaded object as store.Disk checks a file. A PUT replaces an object at once, so a reader gets the previous snapshot or the new one, never part of one.

Load remembers the entity tag of the last object it accepted for each source and sends it in If-None-Match: while the object is unchanged, the bucket answers 304 and the remembered snapshot is returned without a download. The API reloads every minute; the sync job writes a few times a day.

Requests go path-style to the endpoint host, signed with AWS Signature Version 4, through the given HTTP client: in production the platform client, which allows that host only and bounds time and response size.

Index

Constants

View Source
const (
	Host   = "s3.fr-par.scw.cloud"
	Region = "fr-par"
)

Scaleway Object Storage in fr-par (ADR 0005), the defaults of Options.

View Source
const (
	AWSParisHost   = "s3.eu-west-3.amazonaws.com"
	AWSParisRegion = "eu-west-3"
)

Amazon S3 in Paris, where the backups of the key store go, out of Scaleway (#75).

View Source
const DefaultAttempts = 3

DefaultAttempts is the number of tries of a request the bucket answers with a 5xx, a throttle or a network error, the first one included.

Variables

View Source
var ErrInvalidOptions = errors.New("invalid object store options")

ErrInvalidOptions means New was given Options it cannot use.

Functions

This section is empty.

Types

type Archive added in v0.57.0

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

Archive adds the sealed backups of the key store to a bucket out of Scaleway (#75). Its credentials may only add objects: it never reads, replaces or removes one. It implements app.BackupArchive.

func NewArchive added in v0.57.0

func NewArchive(opts Options) (*Archive, error)

NewArchive returns an Archive for opts, or ErrInvalidOptions.

func (*Archive) Keep added in v0.57.0

func (a *Archive) Keep(ctx context.Context, name string, body []byte) error

Keep adds body as the object name. If-None-Match: * makes the bucket refuse a name already taken, so that a backup never replaces another.

type Options

type Options struct {
	// Endpoint is the HTTPS URL of the S3 API; "https://" + Host when
	// empty.
	Endpoint string

	// Region signs the requests; Region when empty.
	Region string

	// Bucket holds the objects. Required.
	Bucket string

	// AccessKey and SecretKey are the credentials of the bucket. Required.
	AccessKey string
	SecretKey config.Secret

	// HTTP sends the requests: the platform client, which allows the
	// endpoint host only and bounds time and size. Required.
	HTTP s3.HTTPClient

	// Attempts is the number of tries of a request; DefaultAttempts when
	// 0.
	Attempts int
}

Options configures a Store.

type Store

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

Store keeps one object per source in a bucket. It implements app.SnapshotStore and is safe for concurrent use.

func New

func New(opts Options) (*Store, error)

New returns a Store for opts, or ErrInvalidOptions.

func (*Store) Load

func (st *Store) Load(ctx context.Context, source domain.Source) (domain.Snapshot, error)

Load returns the snapshot in the object of source: app.ErrNoSnapshot when there is none, store.ErrCorrupt or store.ErrVersion when it does not check out. An object unchanged since the last Load is not downloaded.

func (*Store) Save

func (st *Store) Save(ctx context.Context, s domain.Snapshot) error

Save replaces the object of s.Source with s.

Jump to

Keyboard shortcuts

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