backend

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package backend defines the interfaces for object storage backends used by glassdb.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound is returned when an object does not exist in the backend.
	ErrNotFound = errors.New("object not found")
	// ErrPrecondition is returned when a conditional operation's precondition fails.
	ErrPrecondition = errors.New("precondition failed")
	// ErrEOF is returned when there are no more items to iterate over.
	ErrEOF = errors.New("end of file")
)

Functions

This section is empty.

Types

type Backend

type Backend interface {
	ReadIfModified(ctx context.Context, path string, version int64) (ReadReply, error)
	Read(ctx context.Context, path string) (ReadReply, error)
	GetMetadata(ctx context.Context, path string) (Metadata, error)
	SetTagsIf(ctx context.Context, path string, expected Version, t Tags) (Metadata, error)
	Write(ctx context.Context, path string, value []byte, t Tags) (Metadata, error)
	WriteIf(ctx context.Context, path string, value []byte, expected Version, t Tags) (Metadata, error)
	WriteIfNotExists(ctx context.Context, path string, value []byte, t Tags) (Metadata, error)
	Delete(ctx context.Context, path string) error
	DeleteIf(ctx context.Context, path string, expected Version) error

	// List returns an iterator over the objects in the bucket within the given
	// directory (path separator is '/'). Objects will be iterated over
	// lexicographically by name.
	//
	// Note: The returned iterator is not safe for concurrent operations without
	// explicit synchronization.
	List(ctx context.Context, dirPath string) (ListIter, error)
}

Backend defines the interface for object storage operations with conditional reads, writes, and listing capabilities.

type ListIter

type ListIter interface {
	Next() (path string, ok bool)
	Err() error
}

ListIter iterates over objects returned by a list operation.

type Metadata

type Metadata struct {
	Tags    Tags
	Version Version
}

Metadata holds the tags and version information of an object.

type ReadReply

type ReadReply struct {
	Contents []byte
	// TODO: Consider only exposing contents version.
	Version Version
}

ReadReply holds the contents and version of a read object.

type Tags

type Tags map[string]string

Tags represents key-value metadata pairs associated with an object.

type Version

type Version struct {
	Contents int64
	Meta     int64
}

Version represents the content and metadata generation numbers of an object.

func (Version) IsNull

func (v Version) IsNull() bool

IsNull reports whether the version is unset (zero value).

Directories

Path Synopsis
Package gcs implements the backend interface using Google Cloud Storage.
Package gcs implements the backend interface using Google Cloud Storage.
Package memory implements an in-memory backend for testing and development.
Package memory implements an in-memory backend for testing and development.
Package middleware provides decorators for backend implementations, including logging and latency simulation.
Package middleware provides decorators for backend implementations, including logging and latency simulation.

Jump to

Keyboard shortcuts

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