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

storage

package
v1.26.6 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package storage provides functionality for the TDTP framework.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsRemote

func IsRemote(path string) bool

IsRemote returns true if the path is a supported remote storage URI (e.g. s3://).

func ParseURI

func ParseURI(uri string) (scheme, bucket, key string, remote bool)

ParseURI parses a remote storage URI like "s3://bucket/path/to/key". Returns (scheme, bucket, key, true) for known remote schemes; ("", "", "", false) for local paths.

func Register

func Register(storageType string, fn StorageConstructor)

Register registers a storage constructor for a given storage type. Called from init() functions of driver packages.

Types

type Config

type Config struct {
	Type string   `yaml:"type"`
	S3   S3Config `yaml:"s3,omitempty"`
}

Config is the top-level storage configuration passed to the factory.

type ObjectInfo

type ObjectInfo struct {
	Key      string
	Size     int64
	ModTime  time.Time
	Metadata map[string]string
}

ObjectInfo holds metadata about a stored object.

type ObjectStorage

type ObjectStorage interface {
	Put(ctx context.Context, key string, reader io.Reader, meta map[string]string) error
	Get(ctx context.Context, key string) (io.ReadCloser, error)
	Stat(ctx context.Context, key string) (*ObjectInfo, error)
	List(ctx context.Context, prefix string) ([]ObjectInfo, error)
	Delete(ctx context.Context, key string) error
	Close() error
}

ObjectStorage is the interface for object storage backends (S3, SeaweedFS, etc.).

func New

func New(cfg Config) (ObjectStorage, error)

New creates an ObjectStorage instance for the given Config.

type S3Config

type S3Config struct {
	Endpoint   string `yaml:"endpoint"`
	Region     string `yaml:"region"`
	Bucket     string `yaml:"bucket"`
	AccessKey  string `yaml:"access_key"`
	SecretKey  string `yaml:"secret_key"`
	DisableSSL bool   `yaml:"disable_ssl,omitempty"`
}

S3Config holds S3-compatible storage settings.

type StorageConstructor

type StorageConstructor func(cfg Config) (ObjectStorage, error)

StorageConstructor creates an ObjectStorage from a Config.

Directories

Path Synopsis
Package s3 provides S3-compatible object storage for the TDTP framework.
Package s3 provides S3-compatible object storage for the TDTP framework.

Jump to

Keyboard shortcuts

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