file

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package file implements the provider interface for local filesystem paths.

Library consumers can use Config and New directly when they need a local provider for tests, examples, or transfer workflows. Config is an explicit per-instance value; the package does not read gonimbus CLI configuration or GONIMBUS_* environment variables as part of provider construction.

IfAbsent publication and reserved staging names

Conditional IfAbsent puts stage the complete body under the destination directory with CreateTemp pattern "gonimbus-ifabsent-*.tmp", then publish with os.Link (atomic no-replace). The final object key is never opened for streaming under O_EXCL, so a hard interrupt mid-write cannot leave a visible partial final. Plain os.Rename is not used for IfAbsent (replace semantics).

List omits only basenames that match the reserved staging shape gonimbus-ifabsent-<nonce>.tmp (non-empty nonce without '.' or path separators). Ordinary object keys that merely contain the token "gonimbus-ifabsent" (for example gonimbus-ifabsent-report.csv) remain listable. Callers must not rely on that reserved basename shape as a durable user key.

See docs/library-consumers.md for the embedded-use contract shared by the supported library packages.

API stability: Stable. Breaking changes to exported symbols or documented behavior follow the Library API protocol in docs/api-stability.md.

Index

Constants

View Source
const (
	DefaultMetadataSidecarSuffix = ".gnb-meta.json"

	SymlinkPolicySkip   = "skip"
	SymlinkPolicyFollow = "follow"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BaseDir               string
	MetadataSidecarSuffix string
	SymlinkPolicy         string
}

func (Config) Validate

func (c Config) Validate() error

type Provider

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

Provider implements provider.Provider for local filesystem paths.

Keys are treated as relative paths under BaseDir.

This provider is intended for bucket-to-local transfer workflows.

func New

func New(cfg Config) (*Provider, error)

func (*Provider) Close

func (p *Provider) Close() error

func (*Provider) ConditionalWriteCapabilities

func (p *Provider) ConditionalWriteCapabilities() provider.ConditionalWriteCapabilities

ConditionalWriteCapabilities declares the conditional-write predicates this file adapter honors: IfAbsent (same-dir temp + no-replace Link publish) and IfMatch (lock + ETag compare-and-swap). The file provider has no multipart path, so conditional multipart completion is not offered.

func (*Provider) DeleteObject

func (p *Provider) DeleteObject(ctx context.Context, key string) error

func (*Provider) GetObject

func (p *Provider) GetObject(ctx context.Context, key string) (io.ReadCloser, int64, error)

func (*Provider) GetObjectRevision

func (p *Provider) GetObjectRevision(ctx context.Context, key string, revision provider.SourceRevision) (io.ReadCloser, provider.ObjectMeta, error)

GetObjectRevision opens the file and refuses if its admitted local revision token no longer matches the opened file.

func (*Provider) GetObjectVersioned

func (p *Provider) GetObjectVersioned(ctx context.Context, key string) (io.ReadCloser, provider.ObjectMeta, error)

func (*Provider) GetRange

func (p *Provider) GetRange(ctx context.Context, key string, start, endInclusive int64) (io.ReadCloser, int64, error)

func (*Provider) Head

func (p *Provider) Head(ctx context.Context, key string) (*provider.ObjectMeta, error)

func (*Provider) List

func (*Provider) PutObject

func (p *Provider) PutObject(ctx context.Context, key string, body io.Reader, contentLength int64) error

func (*Provider) PutObjectConditional

func (p *Provider) PutObjectConditional(ctx context.Context, key string, body io.Reader, contentLength int64, precond provider.PutPrecondition) (provider.PutResult, error)

func (*Provider) PutObjectConditionalWithOptions

func (p *Provider) PutObjectConditionalWithOptions(ctx context.Context, key string, body io.Reader, contentLength int64, precond provider.PutPrecondition, opts provider.PutOptions) (provider.PutResult, error)

func (*Provider) PutObjectWithOptions

func (p *Provider) PutObjectWithOptions(ctx context.Context, key string, body io.Reader, contentLength int64, opts provider.PutOptions) error

Jump to

Keyboard shortcuts

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