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

persistence

package
v0.0.0-...-cc1069a Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Overview

Package persistence publishes immutable checkpoints outside the hot path.

Index

Constants

View Source
const BlockBytes int64 = 64 << 10

Complete blocks are uploaded once. Only the bounded partial block repeats.

View Source
const MaxObjectBytes = 2 << 20

Variables

This section is empty.

Functions

func PermanentError

func PermanentError(err error) bool

PermanentError stops background retries until the operator fixes credentials or the bucket and explicitly requests synchronization again.

Types

type Archive

type Archive struct {
	Objects         Objects
	Metadata        Metadata
	MaxSessionBytes int64
}

func (*Archive) Delete

func (a *Archive) Delete(ctx context.Context, tenant, id string) error

func (*Archive) List

func (a *Archive) List(ctx context.Context, tenant, after string, limit int) ([]core.Session, error)

List returns the optional eventual discovery index. An archive without an index contributes no remote rows; local discovery remains authoritative.

func (*Archive) Publish

func (a *Archive) Publish(ctx context.Context, s Snapshot) (Manifest, error)

Publish is serialized by the session owner. Snapshot files must retain their captured prefixes until this call returns; appending is safe during upload.

func (*Archive) Restore

func (a *Archive) Restore(ctx context.Context, tenant, id, reference, parent string) (Manifest, string, error)

Restore writes into a new staging directory. It never opens a harness.

type Artifact

type Artifact struct {
	Path       string `json:"path"`
	Generation string `json:"generation"`
	Size       int64  `json:"size"`
	Tail       string `json:"tail,omitempty"`
}

type FileObjects

type FileObjects struct{ Root string }

func (FileObjects) DeletePrefix

func (s FileObjects) DeletePrefix(ctx context.Context, prefix string) error

func (FileObjects) Get

func (s FileObjects) Get(ctx context.Context, key string) ([]byte, error)

func (FileObjects) Put

func (s FileObjects) Put(ctx context.Context, key string, data []byte, immutable bool) error

type GCSObjects

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

func (*GCSObjects) Close

func (s *GCSObjects) Close() error

func (*GCSObjects) DeletePrefix

func (s *GCSObjects) DeletePrefix(ctx context.Context, prefix string) error

func (*GCSObjects) Get

func (s *GCSObjects) Get(ctx context.Context, key string) ([]byte, error)

func (*GCSObjects) Put

func (s *GCSObjects) Put(ctx context.Context, key string, data []byte, immutable bool) error

type Manifest

type Manifest struct {
	Credentials  []core.CredentialRecord `json:"credentials,omitempty"`
	ID           string                  `json:"id"`
	Tenant       string                  `json:"tenant"`
	Session      core.Session            `json:"session"`
	HistoryBytes int64                   `json:"history_bytes"`
	Files        []Artifact              `json:"files"`
	Time         time.Time               `json:"time"`
}

func ReadState

func ReadState(dir string) (*Manifest, error)

type Metadata

Metadata is an eventual discovery index, never a session ownership lock.

type Objects

type Objects interface {
	DeletePrefix(context.Context, string) error
	Put(context.Context, string, []byte, bool) error
	Get(context.Context, string) ([]byte, error)
}

func NewObjects

func NewObjects(ctx context.Context, s Settings) (Objects, error)

type Postgres

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

func NewPostgres

func NewPostgres(dsn string) (*Postgres, error)

func (*Postgres) Close

func (p *Postgres) Close() error

func (*Postgres) Delete

func (p *Postgres) Delete(ctx context.Context, tenant, id string) error

func (*Postgres) Get

func (p *Postgres) Get(ctx context.Context, tenant, id string) (core.Session, string, error)

func (*Postgres) List

func (p *Postgres) List(ctx context.Context, tenant, after string, limit int) ([]core.Session, error)

func (*Postgres) Put

func (p *Postgres) Put(ctx context.Context, s core.Session, reference string) error

type S3Objects

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

func (*S3Objects) DeletePrefix

func (s *S3Objects) DeletePrefix(ctx context.Context, prefix string) error

func (*S3Objects) Get

func (s *S3Objects) Get(ctx context.Context, key string) ([]byte, error)

func (*S3Objects) Put

func (s *S3Objects) Put(ctx context.Context, key string, data []byte, immutable bool) error

type Settings

type Settings struct {
	Provider        string `json:"provider"`
	Directory       string `json:"directory,omitempty"`
	Bucket          string `json:"bucket,omitempty"`
	Region          string `json:"region,omitempty"`
	Endpoint        string `json:"endpoint,omitempty"`
	Prefix          string `json:"prefix,omitempty"`
	AccessKeyEnv    string `json:"access_key_env,omitempty"`
	SecretKeyEnv    string `json:"secret_key_env,omitempty"`
	PostgresEnv     string `json:"postgres_env,omitempty"`
	IntervalSeconds int    `json:"interval_seconds,omitempty"`
	Queue           int    `json:"queue,omitempty"`
}

func (*Settings) Validate

func (s *Settings) Validate() error

type Snapshot

type Snapshot struct {
	Session      core.Session
	Directory    string
	HistoryBytes int64
}

Jump to

Keyboard shortcuts

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