meta

package
v1.9.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoSuchKey is returned when the key does not exist.
	ErrNoSuchKey = errors.New("no such key")
)

Functions

This section is empty.

Types

type MetadataStorer

type MetadataStorer interface {
	// RetrieveAttribute retrieves the value of a specific attribute for an object or a bucket.
	// Returns the value of the attribute, or an error if the attribute does not exist.
	RetrieveAttribute(f *os.File, bucket, object, attribute string) ([]byte, error)

	// StoreAttribute stores the value of a specific attribute for an object or a bucket.
	// If attribute already exists, new attribute should replace existing.
	// Returns an error if the operation fails.
	StoreAttribute(f *os.File, bucket, object, attribute string, value []byte) error

	// DeleteAttribute removes the value of a specific attribute for an object or a bucket.
	// Returns an error if the operation fails.
	DeleteAttribute(bucket, object, attribute string) error

	// ListAttributes lists all attributes for an object or a bucket.
	// Returns list of attribute names, or an error if the operation fails.
	ListAttributes(bucket, object string) ([]string, error)

	// DeleteAttributes removes all attributes for an object or a bucket.
	// Returns an error if the operation fails.
	DeleteAttributes(bucket, object string) error

	// RenameObject renames all stored metadata from oldObject to newObject
	// within the given bucket. This must be called whenever the data
	// directory for an object is renamed so that metadata stays in sync.
	RenameObject(bucket, oldObject, newObject string) error

	// ReplaceObject removes the attributes of an object, other than the
	// ones named in keep, when a new file replaces the object's file. This
	// must be called whenever a new file is published at an object's path
	// so that it doesn't inherit the metadata of the replaced file. The
	// attributes in keep are the ones the new file sets anyway: they are
	// overwritten instead of removed, so that they never go missing for
	// concurrent readers.
	ReplaceObject(bucket, object string, keep []string) error
}

MetadataStorer defines the interface for managing metadata. When object == "", the operation is on the bucket.

type NoMeta added in v1.0.10

type NoMeta struct{}

NoMeta is a metadata storer that does not store metadata. This can be useful for read only mounts where attempting to store metadata would fail.

func (NoMeta) DeleteAttribute added in v1.0.10

func (NoMeta) DeleteAttribute(_, _, _ string) error

DeleteAttribute removes the value of a specific attribute for an object or a bucket. always returns nil without deleting the attribute

func (NoMeta) DeleteAttributes added in v1.0.10

func (NoMeta) DeleteAttributes(bucket, object string) error

DeleteAttributes removes all attributes for an object or a bucket. always returns nil without deleting any attributes

func (NoMeta) ListAttributes added in v1.0.10

func (NoMeta) ListAttributes(_, _ string) ([]string, error)

ListAttributes lists all attributes for an object or a bucket. always returns an empty list of attributes

func (NoMeta) RenameObject added in v1.4.1

func (NoMeta) RenameObject(_, _, _ string) error

RenameObject is a no-op because NoMeta does not store metadata.

func (NoMeta) ReplaceObject added in v1.9.0

func (NoMeta) ReplaceObject(_, _ string, _ []string) error

ReplaceObject is a no-op because NoMeta does not store metadata.

func (NoMeta) RetrieveAttribute added in v1.0.10

func (NoMeta) RetrieveAttribute(_ *os.File, _, _, _ string) ([]byte, error)

RetrieveAttribute retrieves the value of a specific attribute for an object or a bucket. always returns ErrNoSuchKey

func (NoMeta) StoreAttribute added in v1.0.10

func (NoMeta) StoreAttribute(_ *os.File, _, _, _ string, _ []byte) error

StoreAttribute stores the value of a specific attribute for an object or a bucket. always returns nil without storing the attribute

type RootDirSetter added in v1.9.0

type RootDirSetter interface {
	WithRootDir(rootdir string) MetadataStorer
}

RootDirSetter is implemented by metadata storers that keep metadata on the bucket and object files themselves and therefore need to know where those files live. A backend that does not change the process working directory to its root calls WithRootDir with the absolute path of the root before using the storer; the returned storer resolves bucket names against that directory instead of the working directory. Storers that keep metadata elsewhere (SideCar, NoMeta) do not implement it.

A type that embeds XattrMeta inherits its WithRootDir, which returns a bare XattrMeta and so drops the outer type; such a type must provide its own WithRootDir.

type SideCar added in v1.0.10

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

SideCar is a metadata storer that uses sidecar files to store metadata.

func NewSideCar added in v1.0.10

func NewSideCar(dir string) (SideCar, error)

NewSideCar creates a new SideCar metadata storer.

func (SideCar) DeleteAttribute added in v1.0.10

func (s SideCar) DeleteAttribute(bucket, object, attribute string) error

DeleteAttribute removes the value of a specific attribute for an object or a bucket.

func (SideCar) DeleteAttributes added in v1.0.10

func (s SideCar) DeleteAttributes(bucket, object string) error

DeleteAttributes removes all attributes for an object or a bucket. When object is empty the entire bucket sidecar directory is removed, cleaning up any orphaned object or multipart metadata within it.

func (SideCar) ListAttributes added in v1.0.10

func (s SideCar) ListAttributes(bucket, object string) ([]string, error)

ListAttributes lists all attributes for an object or a bucket.

func (SideCar) RenameObject added in v1.4.1

func (s SideCar) RenameObject(bucket, oldObject, newObject string) error

RenameObject renames the sidecar metadata directory from oldObject to newObject so that path-based lookups continue to work after the data directory has been renamed.

func (SideCar) ReplaceObject added in v1.9.0

func (s SideCar) ReplaceObject(bucket, object string, keep []string) error

ReplaceObject removes the attributes of the object other than the ones in keep. The attributes are stored at the object's path, so they would otherwise outlive the replaced file. Directories in the metadata directory hold the metadata of the objects under "<object>/meta/" and are left in place.

func (SideCar) RetrieveAttribute added in v1.0.10

func (s SideCar) RetrieveAttribute(_ *os.File, bucket, object, attribute string) ([]byte, error)

RetrieveAttribute retrieves the value of a specific attribute for an object or a bucket.

func (SideCar) StoreAttribute added in v1.0.10

func (s SideCar) StoreAttribute(_ *os.File, bucket, object, attribute string, value []byte) error

StoreAttribute stores the value of a specific attribute for an object or a bucket.

type XattrMeta

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

XattrMeta stores metadata as extended attributes on the bucket and object files. The zero value resolves bucket names against the process working directory, which the posix backend sets to its root directory; a backend that keeps the working directory supplies the root through WithRootDir.

func (XattrMeta) DeleteAttribute

func (x XattrMeta) DeleteAttribute(bucket, object, attribute string) error

DeleteAttribute removes the value of a specific attribute for an object in a bucket.

func (XattrMeta) DeleteAttributes

func (x XattrMeta) DeleteAttributes(bucket, object string) error

DeleteAttributes is not implemented for xattr since xattrs are automatically removed when the file is deleted.

func (XattrMeta) ListAttributes

func (x XattrMeta) ListAttributes(bucket, object string) ([]string, error)

ListAttributes lists all attributes for an object in a bucket.

func (XattrMeta) RenameObject added in v1.4.1

func (x XattrMeta) RenameObject(_, _, _ string) error

RenameObject is a no-op for xattr because extended attributes are stored on the inodes and follow the file/directory when it is renamed.

func (XattrMeta) ReplaceObject added in v1.9.0

func (x XattrMeta) ReplaceObject(_, _ string, _ []string) error

ReplaceObject is a no-op for xattr because extended attributes are stored on the inodes: the replaced file takes its attributes with it, and the new file has only the ones set on it.

func (XattrMeta) RetrieveAttribute

func (x XattrMeta) RetrieveAttribute(f *os.File, bucket, object, attribute string) ([]byte, error)

RetrieveAttribute retrieves the value of a specific attribute for an object in a bucket.

func (XattrMeta) StoreAttribute

func (x XattrMeta) StoreAttribute(f *os.File, bucket, object, attribute string, value []byte) error

StoreAttribute stores the value of a specific attribute for an object in a bucket.

func (XattrMeta) Test

func (x XattrMeta) Test(path string) error

Test is a helper function to test if xattrs are supported.

func (XattrMeta) WithRootDir added in v1.9.0

func (x XattrMeta) WithRootDir(rootdir string) MetadataStorer

WithRootDir returns a copy of x that resolves bucket names against rootdir.

Jump to

Keyboard shortcuts

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